Ask Your Question

In the turtlesim tutorial "Moving in a straightline", which instructions actually move the turtle?

asked 2018-11-26 01:43:49 -0600

updated 2018-11-26 01:59:19 -0600

I am reading the turtlesim tutorial "Moving in a straightline".

I do not understand how the software moves the simulated turtle. The only relevant program segment in the tutorial seems to be in lines 8 and 37-38 (see below). But those lines are about publishing a message, vel_msg, to a channel turtle1/cmd_vel . So, I would like to know which instructions actually make the turtle move (since publishing a message does not do the job). Any clarification?

 8     velocity_publisher = rospy.Publisher('/turtle1/cmd_vel', Twist, queue_size=10)
37             #Publish the velocity
38             velocity_publisher.publish(vel_msg)
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2018-11-26 02:04:14 -0600

Delb gravatar image

Publishing on the topic /turtleX/cmd_vel allows you to send a velocity command (linear and angular). The node turtlesim subscribes to this topic and set the position of the turtlebot according to the command (code here).

(since publishing a message does not do the job)

It doesn't actually do the job but that's how you can send easy instructions instead of manually calculate the new pose of the turtle for each command.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-11-26 01:43:49 -0600

Seen: 870 times

Last updated: Nov 26 '18