Robotics StackExchange | Archived questions

How does move_base publish to cmd_vel?

Hi,

I was wondering if someone out there can give me some clarification on the move_base.launch.

To explain what I am doing, I have a robot car using RPLidar and Hector SLAM with no Odometry. I am able to control my robot using the teleoptwistkeyboard node and have it drive around and create a map. Now I am trying to have it be autonomous and I heard that using move_base is a method to do this.

I have created costmapcommonparams.yaml, globalcostmapparams.yaml, localcostmapparams.yaml, and baselocalplannerparams.yaml and my own movebase.launch file following this tutorial: http://wiki.ros.org/navigation/Tutorials/RobotSetup

However, I do not understand how this will publish to the cmd_vel topic. I do not see anywhere on the tutorial where it publishes.

Can anyone give me some clarification?

Thanks in advance!

Asked by KennyxD on 2020-11-30 20:49:29 UTC

Comments

Did you go over the wiki and the documentation therein, especially http://wiki.ros.org/move_base? There, it is pretty evident, where the publishing happens.

Asked by mgruhler on 2020-12-01 02:05:29 UTC

Hi mgruhler!

Thank you for your reply.

Yes, I have seen that documentation but I am still a bit confused. You see, I am new to ROS and I learned from the tutorial (http://wiki.ros.org/ROS/Tutorials/WritingPublisherSubscriber%28python%29) that to create a publisher node you need a code something like this:

pub = rospy.Publisher('chatter', String, queue_size=10)

So I guess why I am confused about is that I do not see this line of code anywhere for move_base. Which makes me wonder how does it publish to cmd_vel?

Asked by KennyxD on 2020-12-01 17:53:50 UTC

Well, I guess you didn't look at the source code? The publisher is created here

Note that move_base is quite a complex piece of software, so if you are new to ROS and, maybe, not very experienced in programming, this might be hard to step through bit by bit. The tutorial you link in your question only shows how to configure the various pieces that make up a fully working navigation setup...

Asked by mgruhler on 2020-12-02 03:51:54 UTC

Oh, thank you so much for sending me the source code!

Yes, I do agree that this is a difficult task for a newcomer like me.

I have looked at how other people autonomously navigate their robot and I kept seeing them run 3 things: 1. RPLidar, 2. Hector slam launch file, and 3. move_base launch file. And from there, they would use the 2D Pose Estimate button to identify the initial position of the robot and then use the 2D Nav Goal on Rviz and their robot would start moving. I guess I misunderstood how they did their coding and didn't realize they had another code that is also called move_base that is not the launch file.

Thank you for the clarification!

Asked by KennyxD on 2020-12-02 11:17:45 UTC

Well, yes. A launch file is not "code" in itself (well, it is XML, but anyways...). A launch file is used to easily configure and run nodes, whether they have been programmed with C++, Python or any other ROS supported language (in the end, it just launches executables, so you could launch any executable file, like e.g. shell scripts). This should be the main take away here. A launch file can also launch multiple nodes.

Asked by mgruhler on 2020-12-04 01:42:08 UTC

Answers

Move base works with goal. When move_base gets goal ( in rviz 2D nav goal button or terminal ) , it starts publishing cmd_vel..

This is the detailed information

http://wiki.ros.org/navigation/Tutorials/SendingSimpleGoals

Asked by bfdmetu on 2020-12-02 01:54:00 UTC

Comments

Thank you for this link! I will definitely use it to create a node that sends the goal.

Asked by KennyxD on 2020-12-02 14:18:56 UTC

Hi,

move_base uses a navigation goal in order to send out cmd_vel messages to the robot, and gets updated with the /odom topic that it subscribes to and the amcl node that aids localization.

If you want an in depth explanation, I made this video that might help:

https://www.youtube.com/watch?v=G5_sAMGmC44&ab_channel=TheConstruct

Asked by rodrigo55 on 2020-12-02 04:18:58 UTC

Comments

Thank you so much for making the video! Definitely clarified some concepts for me!.

I probably can't use exactly everything that you showed since I don't have odometry for my robot. Also, I believe that Hector Slam uses hector mapping which does SLAM and AMCL for localization. So with this, I don't think need to save my map prior to using move_base.

Let me know if I got it wrong. Thanks!

Asked by KennyxD on 2020-12-02 14:15:11 UTC

You're welcome! I haven't worked with Hector SLAM, but you're right, the name implies that it's already doing simultaneous localization and mapping.

Asked by rodrigo55 on 2020-12-07 04:01:33 UTC

Can you please update your answer with main points from the video? If your video goes down or isn't available for certain regions then your answer/solution isn't as useful. Also, some prefer text to 20+ minute video

Asked by jayess on 2021-03-11 01:13:47 UTC

if you successfully used move base with hector slam without any use of Odom can you write the main steps and files on how to do so (i am also using lidar )and finished building the map any help will be appreciated as it is for my graduation project

Asked by mada63 on 2021-04-17 09:12:03 UTC

@rodrigo55, tries to follow your video to create a rosject. but catkin_make failed to build it. it stopped at "-- BUILD_SHARED_LIBS is on". Any suggestion? Thank you.

Asked by gzpROS on 2021-05-22 00:48:31 UTC