6 from geometry_msgs.msg
import Twist
7 from ackermann_msgs.msg
import AckermannDriveStamped
11 if omega == 0
or v == 0:
15 return math.atan(wheelbase / radius)
20 global ackermann_cmd_topic
27 msg = AckermannDriveStamped()
28 msg.header.stamp = rospy.Time.now()
29 msg.header.frame_id = frame_id
30 msg.drive.steering_angle = steering
39 if __name__ ==
'__main__':
42 rospy.init_node(
'cmd_vel_to_ackermann_drive')
44 twist_cmd_topic = rospy.get_param(
'~twist_cmd_topic',
'/cmd_vel')
45 ackermann_cmd_topic = rospy.get_param(
'~ackermann_cmd_topic',
'/ackermann_cmd')
46 wheelbase = rospy.get_param(
'~wheelbase', 1.0)
47 frame_id = rospy.get_param(
'~frame_id',
'odom')
49 rospy.Subscriber(twist_cmd_topic, Twist, cmd_callback, queue_size=1)
50 pub = rospy.Publisher(ackermann_cmd_topic, AckermannDriveStamped, queue_size=1)
52 rospy.loginfo(
"Node 'cmd_vel_to_ackermann_drive' started.\nListening to %s, publishing to %s. Frame id: %s, wheelbase: %f",
"/cmd_vel", ackermann_cmd_topic, frame_id, wheelbase)
56 except rospy.ROSInterruptException:
def convert_trans_rot_vel_to_steering_angle(v, omega, wheelbase)