Go to the documentation of this file.00001
00002 import geometry_msgs.msg
00003 import rospy
00004 import tf2_ros
00005
00006 if __name__ == '__main__':
00007 """
00008 Broadcast a transform from parent_frame to target_frame forever,
00009 with changing translation.
00010 """
00011
00012 rospy.init_node('dummy_transform_publisher', anonymous=True)
00013 br = tf2_ros.TransformBroadcaster()
00014 current_transform = geometry_msgs.msg.TransformStamped()
00015 current_transform.header.frame_id = rospy.get_param('~parent_frame')
00016 current_transform.child_frame_id = rospy.get_param('~child_frame')
00017
00018 current_transform.transform.rotation.w = 1.0
00019
00020 osc_rate_hz = rospy.get_param('~osc_rate')
00021 update_rate_hz = rospy.get_param('~update_rate')
00022
00023
00024 step_size = (1.0 * osc_rate_hz) / update_rate_hz
00025 update_rate = rospy.Rate(update_rate_hz)
00026 counting_up = True
00027
00028 while not rospy.is_shutdown():
00029 current_transform.header.stamp = rospy.Time.now()
00030 if counting_up:
00031 current_transform.transform.translation.x += step_size
00032 if current_transform.transform.translation.x >= 1.0:
00033 counting_up = False
00034 else:
00035 current_transform.transform.translation.x -= step_size
00036 if current_transform.transform.translation.x <= 0.0:
00037 counting_up = True
00038 br.sendTransform(current_transform)
00039 update_rate.sleep()
00040
00041
00042