diff --git a/frame_editor/src/frame_editor/editor.py b/frame_editor/src/frame_editor/editor.py index 4b1a880..6d8b648 100755 --- a/frame_editor/src/frame_editor/editor.py +++ b/frame_editor/src/frame_editor/editor.py @@ -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)) diff --git a/frame_editor/src/frame_editor/interface_tf.py b/frame_editor/src/frame_editor/interface_tf.py index e67db54..c9b36cd 100644 --- a/frame_editor/src/frame_editor/interface_tf.py +++ b/frame_editor/src/frame_editor/interface_tf.py @@ -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 diff --git a/frame_editor/src/frame_editor/objects.py b/frame_editor/src/frame_editor/objects.py index f3c0716..a2b81fb 100644 --- a/frame_editor/src/frame_editor/objects.py +++ b/frame_editor/src/frame_editor/objects.py @@ -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)