def sendTransform(self, translation, rotation, time, child, parent): """ :param translation: the translation of the transformtion as a tuple (x, y, z) :param rotation: the rotation of the transformation as a tuple (x, y, z, w) :param time: the time of the transformation, as a rospy.Time() :param child: child frame in tf, string :param parent: parent frame in tf, string Broadcast the transformation from tf frame child to parent on ROS topic ``"/tf"``. """ t = TransformStamped() t.header.frame_id = parent t.header.stamp = time t.child_frame_id = child t.transform.translation.x = translation[0] t.transform.translation.y = translation[1] t.transform.translation.z = translation[2] t.transform.rotation.x = rotation[0] t.transform.rotation.y = rotation[1] t.transform.rotation.z = rotation[2] t.transform.rotation.w = rotation[3] tfm = tfMessage([t]) self.pub_tf.publish(tfm)
def post_tf(self, component_instance): component_name = component_instance.blender_obj.name frame_id = self._properties[component_name]['frame_id'] child_frame_id = self._properties[component_name]['child_frame_id'] euler = mathutils.Euler((component_instance.local_data['roll'], component_instance.local_data['pitch'], component_instance.local_data['yaw'])) quaternion = euler.to_quaternion() t = TransformStamped() t.header.frame_id = frame_id t.header.stamp = rospy.Time.now() t.child_frame_id = child_frame_id t.transform.translation.x = component_instance.local_data['x'] t.transform.translation.y = component_instance.local_data['y'] t.transform.translation.z = component_instance.local_data['z'] t.transform.rotation = quaternion tfm = tfMessage([t]) for topic in self._topics: # publish the message on the correct topic if str(topic.name) == str("/tf"): topic.publish(tfm)
def sendTransform(self, translation, rotation, time, child, parent): """ :param translation: the translation of the transformtion as geometry_msgs/Vector3 :param rotation: the rotation of the transformation as a geometry_msgs/Quaternion :param time: the time of the transformation, as a rospy.Time() :param child: child frame in tf, string :param parent: parent frame in tf, string Broadcast the transformation from tf frame child to parent on ROS topic ``"/tf"``. """ t = TransformStamped() t.header.frame_id = parent t.header.stamp = time t.child_frame_id = child t.transform.translation = translation t.transform.rotation = rotation tfm = tfMessage([t]) self.publish_tf(tfm)