Complete the code to publish a velocity command on the cmd_vel topic.
pub = rospy.Publisher('cmd_vel', [1], queue_size=10)
The cmd_vel topic expects messages of type Twist which contain linear and angular velocity commands.
Complete the code to set the linear x velocity to 0.5 m/s.
vel_msg = Twist() vel_msg.linear.[1] = 0.5
The linear velocity along the x-axis controls forward/backward movement.
Fix the error in publishing the velocity message.
pub.publish([1])You must publish the message object, which is vel_msg in this case.
Fill both blanks to create a velocity message with angular z velocity 1.0 and linear x velocity 0.2.
vel_msg = Twist() vel_msg.linear.[1] = 0.2 vel_msg.angular.[2] = 1.0
Linear velocity forward is on the x-axis, angular velocity rotation is around the z-axis.
Fill all three blanks to create a dictionary of velocity commands with keys 'linear_x', 'linear_y', and 'angular_z'.
vel_dict = {
'[1]': vel_msg.linear.x,
'[2]': vel_msg.linear.y,
'[3]': vel_msg.angular.z
}The dictionary keys should match the velocity components they represent.
