[ROS Mini Challenge] #2 – Make a robot navigate to a specific location

ROS Mini Challenge #2

Written by Ruben Alves

08/02/2020

 

 

 

 

 

 

 

 

What we are going to learn

  1. How to make a ROS-based robot navigate using RViz’s 2D Nav Goal
  2. 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

  1.  The ROSject of the project with the simulation and the ROS Packages: https://buff.ly/32HGTis
  2.  The ROS Discourse post where the challenge was posted: https://discourse.ros.org/t/rosject-of-the-week-challenge-2/11474
  3. 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.

Open ROSject of the Week number 2 in ROSDS

Open ROSject of the Week number 2 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.

Choose lunch file to open simulation in ROSDS

Choose lunch file to open simulation in ROSDS

 

Now, from the launch files list, select the launch file named main.launch from the summit_xl_gazebo package.

Summit XL gazebo in ROSDS, ROSject of the week

Summit XL gazebo in ROSDS, ROSject of the week

Finally, click on the Launch button to start the simulation. In the end, you should get something like this:

Summit XL gazebo simulation in ROSDS, ROSject of the week

Summit XL gazebo simulation in ROSDS, ROSject of the week

The problem to solve

As you can see, this ROSject contains 3 packages inside its catkin_ws workspace: my_summit_mapping, my_summit_localization, and my_summit_path_planning. The purpose of all these packages is to make the Summit XL robot autonomously navigate through the environment.So, the main purpose of this ROSject is to be able to send a Navigation Goal to the robot, and the Summit XL robot computes and executes a trajectory plan in order to reach this goal. The steps in order to achieve this are the following:
First, you launch the Navigation system by executing the following command in the terminal (Tools -> Shell):
source ~/catkin_ws/devel/setup.bash
roslaunch my_summit_path_planning move_base.launch
Second, in a different terminal, you launch RViz in order to visualize all the required elements:
rosrun rviz rviz
Now, in order to be able to visualize the RViz screen, you will need to open the Graphical Tools window, in the Tools menu.

Launching Graphical Tools in ROSDS

Launching Graphical Tools in ROSDS

Also, in order to speed up the process, we have already created an RViz configuration that you can load. To do so, just click on the Open Config button in RViz, and select the RViz configuration in the following path: /home/user/catkin_ws/src/my_summit_path_planning/rviz/rotw2.rviz.

File -> Open Config button in RViz

File -> Open Config button in RViz

 

Opening rotw2.rviz config file in RViz

Opening rotw2.rviz config file in RViz

 

When you load the Rviz configuration file, you should get something like this:

ROS Mini Challenge #2 - RViz

ROS Mini Challenge #2 – RViz

Now, all you need to do is to set the initial localization of the robot, using the 2D Pose Estimate tool, and then set a navigation goal for the robot, using the 2D Nav Goal tool.
RViz Pose Estimate - ROS Mini Challenge

RViz Pose Estimate – ROS Mini Challenge

RViz 3D Nav Goal - ROS Mini Challenge

RViz 3D Nav Goal – ROS Mini Challenge

As you can see in the animations below, when setting the Nav Goal for the robot, you should see how it starts moving towards the goal, both in RViz and in the simulation!
ROS Mini Challenge #2 - RViz

ROS Mini Challenge #2 – RViz animation

Robot moving - ROS Mini Challenge

Robot moving simulation – ROS Mini Challenge #2

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.

RViz Pose Estimate - ROS Mini Challenge

RViz Pose Estimate – ROS Mini Challenge

RViz 3D Nav Goal - ROS Mini Challenge

RViz 3D Nav Goal – ROS Mini Challenge

Now the robot should move as expected:

ROS Mini Challenge #2 - RViz

ROS Mini Challenge #2 – RViz animation

Robot moving - ROS Mini Challenge

Robot moving simulation – ROS Mini Challenge #2

 

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.

You May Also Like…

0 Comments

Share This