Go to the documentation of this file.00001
00002 import rospy
00003 from geometry_msgs.msg import Twist
00004 from ackermann_msgs.msg import AckermannDriveStamped
00005 from math import atan
00006
00007 def cmd_vel_callback(msg):
00008
00009 spin = 1.0
00010 ack_msg.header.stamp = rospy.Time.now()
00011 ack_msg.header.frame_id = "odom"
00012
00013 if msg.linear.x >0.0:
00014 spin = 1.0
00015 else:
00016 spin = -1.0
00017
00018
00019
00020 L = 1.650
00021 if msg.angular.z == 0:
00022 delta = 0
00023 else:
00024 R = msg.linear.x / msg.angular.z
00025 delta = atan(L/R)
00026
00027
00028
00029 ack_msg.drive.steering_angle = delta;
00030 ack_msg.drive.steering_angle_velocity = 0.0
00031 ack_msg.drive.speed = msg.linear.x
00032 ack_msg.drive.acceleration = 0.0
00033 ack_msg.drive.jerk = 0.0
00034
00035
00036
00037 ack_msg = AckermannDriveStamped()
00038 cmd_sub = rospy.Subscriber('/cmd_vel_out', Twist, cmd_vel_callback)
00039 ack_pub = rospy.Publisher('/rbcar_robot_control/command', AckermannDriveStamped, latch=True)
00040 rospy.init_node('twist2ack')
00041
00042 r = rospy.Rate(10)
00043 while not rospy.is_shutdown():
00044 ack_pub.publish(ack_msg)
00045 r.sleep()
00046 rospy.loginfo("node has shutdown!")
00047
00048
00049
00050