What we are going to learn
- How to make a ROS-based robot navigate using RViz’s 2D Nav Goal
- How to solve the ROSject Of The Week Challenge #2, making a robot move to a specific position
List of resources used in this post
- The ROSject of the project with the simulation and the ROS Packages: https://buff.ly/32HGTis
- The ROS Discourse post where the challenge was posted: https://discourse.ros.org/t/rosject-of-the-week-challenge-2/11474
- Robot Ignite Academy courses: www.robotigniteacademy.com/en/
What is the ROS Mini Challenge
It’s a ROS-related problem in which the first person who solves wins a prize. Different challenges are published every week.
Launching the Simulation
When you click in the ROSject Link (www.rosject.io/l/e0bc374/), you will get a copy of it. You can then download it if you want to use it on our local computer, or you can just click Open to have it opened in ROSDS.
Once you have it open, go to the top menu and select Simulations. On the menu that appears, click on the Choose launch file… button.
Now, from the launch files list, select the launch file named main.launch from the summit_xl_gazebo package.
The problem to solve
source ~/catkin_ws/devel/setup.bash roslaunch my_summit_path_planning move_base.launch
rosrun rviz rviz
When you load the Rviz configuration file, you should get something like this:
Ok, but the problem doesn’t move as expected, so… where’s the problem? If you have tried to reproduce the steps described above you have already seen that it DOES NOT WORK. When you follow the pipeline and set a navigation goal, this goal is not reached successfully. Why? Let’s figure it out in the section below.
Solving the ROS Mini Challenge
According to the instructions, we need to have a look at the my_summit_path_planning package and try to find there the errors are. If you want to try to solve it by yourself and you don’t have all the ROS Navigation knowledge, we highly recommend you trying Robot Ignite Academy.
If you already have some ROS knowledge, you will notice some errors after running the command below:
source ~/catkin_ws/devel/setup.bash roslaunch my_summit_path_planning move_base.launch
From the error messages, the most important is:
[ INFO] [1580755905.369676908, 45.878000000]: Subscribed to Topics: hokuyo_laser [FATAL] [1580755905.422091274, 45.888000000]: Only topics that use point clouds or laser scans are currently supported terminate called after throwing an instance of 'std::runtime_error' what(): Only topics that use point clouds or laser scans are currently supported
which says that only PonitCloud or LaserScan message types are supported when loading the obstacle_layer plugin, right after trying to subscribe to the hokuyo_laser topic.
Now we have to find where the plugin is defined and check the topic names and types. In the instructions, we have a hint to check the my_summit_path_planning package.
In that package, we can see that the plugin is loaded by the my_summit_path_planning/config/local_costmap_params.yaml file, but the plugin is defined in the config/costmap_common_params.yaml file:
obstacle_range: 2.5 raytrace_range: 3.0 footprint: [[0.35, -0.3], [0.35, 0.3], [-0.35,0.3], [-0.35, -0.3]] publish_frequency: 1.0 inflation_layer: inflation_radius: 0.5 obstacle_layer: observation_sources: hokuyo_laser hokuyo_laser: {sensor_frame: hokuyo_base_link, data_type: Odometry, topic: /scanner, marking: true, clearing: true} static: map_topic: /map subscribe_to_updates: true
In the configuration, we can see that the obstacle_layer laser defines hokuyo_laser, which subscribes to the /scanner topic of type Odometry.
If we try to find that /scanner topic, the topic doesn’t exist:
rostopic list | grep scanner
Normally the topics that contain Laser data have the scan in their name. Let’s try to find a topic with that name:
$ rostopic list | grep scan /hokuyo_base/scan
Hey, there we have. The topic name is /hokuyo_base/scan. Let’s see whether there is data being published in this topic:
rostopic echo -n1 /hokuyo_base/scan
After running the command above, we can see that data is correctly being published, so, it seems this is really the topic we are looking for. Let’s now check the topic type to see whether it has something related to laser:
$ rostopic info /hokuyo_base/scan Type: sensor_msgs/LaserScan Publishers: * /gazebo (http://rosdscomputer:38225/) Subscribers: * /amcl (http://rosdscomputer:36673/)
There you go. The topic type is sensor_msgs/LaserScan.
Let’s then copy the topic name /hokuyo_base/scan and paste it in place of the /scanner in the my_summit_path_planning/config/costmap_common_params.yaml file. In the same file, let’s also change the Odometry data_type by LaserScan, which is the type of topic we will use.
Now, after saving the file, let’s launch our move base node with the same command used previously:
roslaunch my_summit_path_planning move_base.launch
Now you should see no errors in the output. You can know go again to RViz and correctly estimate the pose of the robot by clicking 2D Pose Estimate, and then move the robot with the 2D Nav Goal.
Now the robot should move as expected:
Congratulations. You know how to solve the ROS Mini Challenge #2, in which you have to make the robot navigate to a given location.
Youtube video
So this is the post for today. Remember that we have the live version of this post on YouTube. If you liked the content, please consider subscribing to our youtube channel. We are publishing new content ~every day.
Keep pushing your ROS Learning.
0 Comments