Skip to content

Commit

Permalink
Use static tf frames instead of publishing with fix rate
Browse files Browse the repository at this point in the history
  • Loading branch information
ipa-jsk committed Nov 11, 2024
1 parent ff6a724 commit 399f6b3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion frame_editor/src/frame_editor/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def parse_args(self, argv):
parser.add_argument("-l", "--load", action="append",
dest="file",
help="Load a file at startup. [rospack filepath/file]")
parser.add_argument("-r", "--rate", type=int)
parser.add_argument("-r", "--rate", type=int, help="Rate for broadcasting. Does not involve tf frames.")

args, unknowns = parser.parse_known_args(argv)
print('arguments: {}'.format(args))
Expand Down
17 changes: 9 additions & 8 deletions frame_editor/src/frame_editor/interface_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ def __init__(self, frame_editor):
self.editor = frame_editor
self.editor.observers.append(self)

def broadcast(self, editor):
#print "> Broadcasting"
def update(self, editor, level, elements):
now = rospy.Time.now()
transforms = [
ToTransformStamped(
f.position, f.orientation, now, f.name, f.parent)
for f in editor.frames.values()]
Frame.tf_broadcaster.sendTransform(transforms)

transforms = []
for element in elements:
if element is not None and (level & 1 == 1 or level & 4 == 4):
print(f"updating element {element.name}")
transforms.append(ToTransformStamped(
element.position, element.orientation, now, element.name, element.parent))
if len(transforms) > 0:
Frame.tf_broadcaster.sendTransform(transforms)
# eof
2 changes: 1 addition & 1 deletion frame_editor/src/frame_editor/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self, name, position=(0,0,0), orientation=(0,0,0,1), parent="world"
@staticmethod
def init_tf():
if Frame.tf_buffer is None:
Frame.tf_broadcaster = tf2_ros.TransformBroadcaster()
Frame.tf_broadcaster = tf2_ros.StaticTransformBroadcaster()
Frame.tf_buffer = tf2_ros.Buffer()
Frame.tf_listener = tf2_ros.TransformListener(Frame.tf_buffer)

Expand Down

0 comments on commit 399f6b3

Please sign in to comment.