Ask Your Question

Moving Turtlebot 3 burger to few meters

asked 2019-07-15 08:36:59 -0600

enthusiast.australia gravatar image

Hello everyone. I am using turtlebot 3 burger with ros kinetic kame with ubuntu 16.04 in my PC. I am a beginner. I have successfully installed ros and i can move my robot using keyboard. Now i want to move robot to few meters by giving him a command. My question is that is there a specific python api with which i can do that. Or anyway else i can move my robot autonomously.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-07-15 08:54:54 -0600

alsora gravatar image

updated 2019-07-16 07:22:22 -0600

You should have a look at the ROS Navigation Stack, that contains the components to implement a full autonomous navigation.

Among these packages, the one responsible for moving the robot is MoveBase. This provides you API for moving the robot toward a goal. This goal could be computed in local coordinates and it could easily represent the concept of "X meters in front of the robot". The "problem" is that you will also need a localization package in order to understand when the robot has really traveled that distance. Something very simple could be dead reckoning, i.e. just looking at the wheel encoders.

The Navigation stack contains tutorial for setting up all what you need.

However, in an extremely oversimplified scenario, if you know that your robot moves at 1m/s you can create a function that publishes the "move forward command" that you are executing through the keyboard for the required amount of time to cover your distance. This "command" will be a message of type geometry_msgs/Twist on topic cmd_vel.


I don't advise you to run something as "move randomly for 30 seconds" on a turtlebot, if you don't want to crash it against a wall. Anyhow, you can do something like

import rospy
from geometry_msgs.msg import Twist

pub = rospy.Publisher('cmd_vel', Twist, queue_size=10)
r = rospy.Rate(30) # 30hz

total_time = 10 #seconds
start_time = time.time()

while not rospy.is_shutdown() or (time.time() - start_time < total_time):

    msg = Twist()

    # here you should fill the msg fields
    # you can fill it randomly or with a direction in mind

edit flag offensive delete link more


Thanks alot for your help. Actually i am looking for a simplified thing. I have turtlebot. I have removed LiDAR sensor, now it is just pi3 and a micro controller. I just want to move robot with commands rather than keyboard. for example move 1 meter forward or may be to start random motion for 30 seconds.

enthusiast.australia gravatar image enthusiast.australia  ( 2019-07-16 05:17:40 -0600 )edit

This is not an answer. You should edit your initial post or comment my answer if you want to add details. If you find my answer complete, mark it as accepted. Thanks

alsora gravatar image alsora  ( 2019-07-16 07:11:50 -0600 )edit

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: 2019-07-15 08:36:59 -0600

Seen: 1,281 times

Last updated: Jul 16 '19