Listener file
Hi, I am trying to create a loop that performs a look up transform from a map to another frame. I am also trying to output this information on the terminal when the node is running. Everything is working fine. I am just wondering how I can log this information on the terminal when the node is running?
SOME IMPORTS
if name == 'main': rospy.init_node('TransformListener')
tfBuffer = tf2_ros.Buffer()
listener = tf2_ros.TransformListener(tfBuffer)
rate = rospy.Rate(10.0)
while not rospy.is_shutdown():
try:
trans = tfBuffer.lookup_transform('base_footprint', 'map', rospy.Time())
except (tf2_ros.LookupException, tf2_ros.ConnectivityException, tf2_ros.ExtrapolationException):
rate.sleep()
continue
msg = geometry_msgs.msg.Twist()
msg.angular.z = 4 * math.atan2(trans.transform.translation.y, trans.transform.translation.x)
msg.linear.x = 0.5 * math.sqrt(trans.transform.translation.x ** 2 + trans.transform.translation.y ** 2)
# turtle_vel.publish(msg)
rate.sleep()
Asked by Matlab on 2023-01-14 19:52:01 UTC
Comments