# ROS2 Nav2 Course project problems

**URL:** <https://get-help.theconstruct.ai/t/ros2-nav2-course-project-problems/18128>\
**Category:** ROSDS Support\
**Created:** [July 8, 2022, 2:00pm UTC](https://get-help.theconstruct.ai/t/ros2-nav2-course-project-problems/18128 "2022-07-08T14:00:17Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![romzn](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/romzn/32/5033_2.png) [@romzn](https://get-help.theconstruct.ai/u/romzn)\
**Post date:** [July 8, 2022, 2:00pm UTC](https://get-help.theconstruct.ai/t/ros2-nav2-course-project-problems/18128/1 "2022-07-08T14:00:17Z")

</div>

Hello,  
i have some problems regarding the course project regarding the new nav2 course project

- The map built with cartographer looks horrible, maybe it’s gazebos fault which performes at around 1.5 fps
- Rviz2 is not able to display the particle cloud because there is no plugin installed

The course project is a little bit frustrating so far, because all terminals run really slow caused by gazebos resource usage.

The course itself is okay so far.

[https://i.ibb.co/wY6NvnM/rviz-map.png](https://i.ibb.co/wY6NvnM/rviz-map.png)

---

<div class="post-metadata">

**Author:** ![rtellez](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/rtellez/32/9813_2.png) [@rtellez](https://get-help.theconstruct.ai/u/rtellez)\
**Post date:** [July 11, 2022, 11:06am UTC](https://get-help.theconstruct.ai/t/ros2-nav2-course-project-problems/18128/2 "2022-07-11T11:06:26Z")

</div>

Hi Roman,  
so cool that you are pushing through the ROS2 Nav2 project! That is the way to go, since, by doing the project you will encounter a lot of other problems that do not appear in the controlled environment of the course.

Like for example, this one about the map!

- Definitely, there is something wrong in your map. First of all, the walls doesn’t look straight. That could be because your parameters on the cartographer lua file are not correct, so you do not detect the walls until you are very close to them (that is not correct because the range of the Turtlebot3 lidar can detect the whole environment from any position of that environment).  
Another possible reason is that you are providing to the robot a very high speed, then, there is a large space between each laser lecture, so the odometry condition for the SLAM algorithm is not maintained.

Second, you are not showing the obstacles in the middle. That also makes me suspect you don’t have the proper values in the parameters:

```auto
TRAJECTORY_BUILDER_2D.max_rang

```

I know the simulation goes slow, that is what we have now. Take into account that you are launching:

- the simulation
- the bridge
- the rviz
- the slam algorithm
- the keyboard teleop  
That’s a lot!

Please [check the video of this link](https://youtu.be/3iTrzw9P8gc) to see how it works on my case. I just did this example with a proper configuration file. You can see my `real time factor` is 0.35, even worst than yours. But that is not important for what we are doing here in the project. The speed at which the simulation runs is not important as long as you do not stress the speed of the robot. Try not to provide linear speed larger than 0.05m/s and angular velocities larger than 0.2 rad/s

About the particles plugin, let us install it and come back when done.

![turtlebot_area](https://get-help.robotigniteacademy.com/uploads/default/original/2X/d/d73de7963271168ba6b2bf671fa09149469e18b8.jpeg)

---

<div class="post-metadata">

**Author:** ![romzn](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/romzn/32/5033_2.png) [@romzn](https://get-help.theconstruct.ai/u/romzn)\
**Post date:** [July 12, 2022, 3:57pm UTC](https://get-help.theconstruct.ai/t/ros2-nav2-course-project-problems/18128/3 "2022-07-12T15:57:13Z")

</div>

Hi Ricardo,

yes i encounter a lot of problems through the courses. Most times they are easy to solve.  
But for the actual problem i’m happy to have experienced support.

I already set the max\_range parameter to 3.5.

Altough i used an extrem low speed my map isn’t as fine as yours.

![rviz_map_2](https://get-help.robotigniteacademy.com/uploads/default/original/2X/4/4ac97c76183536c07c61c2753f12d76105f6bbcb.png)

One thing i noticed is that the robot tf-frames are outside of nowhere.  
The Odom\<-Map transformation is corrupt.

Maybe this explains the inaccuracy.

---

<div class="post-metadata">

**Author:** ![rtellez](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/rtellez/32/9813_2.png) [@rtellez](https://get-help.theconstruct.ai/u/rtellez)\
**Post date:** [July 13, 2022, 1:30pm UTC](https://get-help.theconstruct.ai/t/ros2-nav2-course-project-problems/18128/4 "2022-07-13T13:30:19Z")

</div>

Yes that transform is very strange. Where is the robot’s base\_fooprint?

- Where is the laser? It should match with the map walls but I don’t see it there?
- Can you share your cartographer lua config file?

Don’t worry, we are going to find the error, and you are going to learn a lot in the process!!

---

<div class="post-metadata">

**Author:** ![romzn](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/romzn/32/5033_2.png) [@romzn](https://get-help.theconstruct.ai/u/romzn)\
**Post date:** [July 14, 2022, 1:46pm UTC](https://get-help.theconstruct.ai/t/ros2-nav2-course-project-problems/18128/5 "2022-07-14T13:46:18Z")

</div>

Here is the config:

```auto
include "map_builder.lua"
include "trajectory_builder.lua"

options = {
  map_builder = MAP_BUILDER,
  trajectory_builder = TRAJECTORY_BUILDER,
  map_frame = "map",
  tracking_frame = "imu_link",
  published_frame = "odom",
  odom_frame = "odom",
  provide_odom_frame = false,
  publish_frame_projected_to_2d = true,
  use_odometry = true,
  use_nav_sat = false,
  use_landmarks = false,
  num_laser_scans = 1,
  num_multi_echo_laser_scans = 0,
  num_subdivisions_per_laser_scan = 1,
  num_point_clouds = 0,
  lookup_transform_timeout_sec = 0.2,
  submap_publish_period_sec = 0.3,
  pose_publish_period_sec = 5e-3,
  trajectory_publish_period_sec = 30e-3,
  rangefinder_sampling_ratio = 1.,
  odometry_sampling_ratio = 1.,
  fixed_frame_pose_sampling_ratio = 1.,
  imu_sampling_ratio = 1.,
  landmarks_sampling_ratio = 1.,
}

MAP_BUILDER.use_trajectory_builder_2d = true

TRAJECTORY_BUILDER_2D.min_range = 0.1
TRAJECTORY_BUILDER_2D.max_range = 3.5
TRAJECTORY_BUILDER_2D.missing_data_ray_length = 3.
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = false 
TRAJECTORY_BUILDER_2D.motion_filter.max_angle_radians = math.rad(0.1)

POSE_GRAPH.constraint_builder.min_score = 0.65
POSE_GRAPH.constraint_builder.global_localization_min_score = 0.7

-- POSE_GRAPH.optimize_every_n_nodes = 0

return options

```

How to figure out where the frame is? Here The TF-Tree

 ![tf_tree](https://get-help.robotigniteacademy.com/uploads/default/original/2X/e/ebf94f2d5cbcf2f7e4c835b13893dac84113e632.png)

---

<div class="post-metadata">

**Author:** ![romzn](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/romzn/32/5033_2.png) [@romzn](https://get-help.theconstruct.ai/u/romzn)\
**Post date:** [July 14, 2022, 1:46pm UTC](https://get-help.theconstruct.ai/t/ros2-nav2-course-project-problems/18128/6 "2022-07-14T13:46:52Z")

</div>

Additionally, here is a strange warning which says that some of the links has no transformation to the base\_link

![tf_warning](https://get-help.robotigniteacademy.com/uploads/default/original/2X/f/f2ff97cc53a588be6df7683b9c42a9b06cf79f59.png)

* * *

---

<div class="post-metadata">

**Author:** ![rtellez](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/rtellez/32/9813_2.png) [@rtellez](https://get-help.theconstruct.ai/u/rtellez)\
**Post date:** [July 15, 2022, 7:45pm UTC](https://get-help.theconstruct.ai/t/ros2-nav2-course-project-problems/18128/7 "2022-07-15T19:45:05Z")

</div>

Ok let’s go step by step:

1. The only two strange things that I see in your LUA config file are:

- the parameter `tracking_frame` should be the frame of the center of the robot, that usually is `base_footprint` or `base_link`. You set it to `imu_link`. Even if that may work, it is not a good idea to set that when you are not using an IMU for the mapping (which is the case here). So change this to `base_footprint`.

- You set to `false` the `TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching`parameter. That is an important parameter because it indicates if we have to use a scan matching or not. Scan matching helps the algorithm determine the amount of movement done by the robot, so it can check if the odometry is good or not. If you disconnect it (set to `false`) then you are putting it more difficult to the mapper. Please set it to `true`.

Try again with those two modifications and let’s see.

1. About the frame, what you are showing me is the TF-tree of your robot, which looks correct. I meant, display the TF frames in Rviz. You are already doing that (because I can see the `map` frame in your rviz picture, but I cannot see the `odom`. That is why I wanted you to show me where it is in rviz (it is at the end of the yellow arrow. That arrow indicates the connection between the `map` frame and the `odom` frame.

Also there is something strange because the `base_footprint` doesn’t appear in rviz.

1. Something is wrong here: Have you seen the video I put on my first answer in this thread? There you can see that I am in mapping phase. During mapping phase, you should be able to see the robot creating the map. You should see the laser, the robot and the map being created. Please, do that and send me a picture of the robot doing the map (not when completely done, but when in the process of doing it).  
During that state, you should not see the Warning in the TF display. Everything must be `transform ok`. If it is not, then there is a problem with the simulation, something is broken. In that case, kill the mapping, and then restart the simulation (with the restart button of the right).

PLEASE, PLEASE, PLEASE, very important: when taking screenshots, take them of the full screen, not only of the small window with the image, because you are leaving a lot of information of what is happening out, so it is more difficult to understand your problem.

---

<div class="post-metadata">

**Author:** ![romzn](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/romzn/32/5033_2.png) [@romzn](https://get-help.theconstruct.ai/u/romzn)\
**Post date:** [July 17, 2022, 3:29pm UTC](https://get-help.theconstruct.ai/t/ros2-nav2-course-project-problems/18128/8 "2022-07-17T15:29:08Z")

</div>

Thank you very much for your support!

1. I changed the tracking\_frame to `base_footprint` and also the `TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching` to true.  
As a result the map quality is much better. Thank you.

2. Sorry i can’t visualize it in a proper way because the odom frame is so much away from the map frame that it gets unvisible when i scroll out.  

Then i figured out why the map-\>odom frame transformation is corrupt.  
I launched the cartographer without setting the `use_sim_time` argument to `true`.

Thank you very much ! Next time i better check my launches.

---

<div class="post-metadata">

**Author:** ![romzn](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/romzn/32/5033_2.png) [@romzn](https://get-help.theconstruct.ai/u/romzn)\
**Post date:** [July 17, 2022, 3:29pm UTC](https://get-help.theconstruct.ai/t/ros2-nav2-course-project-problems/18128/9 "2022-07-17T15:29:38Z")

</div>

All frames are on the right place now! This is great!

![rviz_map_4](https://get-help.robotigniteacademy.com/uploads/default/original/2X/8/8ae56e646a7d836b92961853cf1914393b0c8b6d.png)

---

<div class="post-metadata">

**Author:** ![rtellez](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/rtellez/32/9813_2.png) [@rtellez](https://get-help.theconstruct.ai/u/rtellez)\
**Post date:** [July 17, 2022, 8:42pm UTC](https://get-help.theconstruct.ai/t/ros2-nav2-course-project-problems/18128/10 "2022-07-17T20:42:41Z")

</div>

Awesome Roman!!! You are on track!!! Go for the rest.

---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [July 18, 2022, 9:31am UTC](https://get-help.theconstruct.ai/t/ros2-nav2-course-project-problems/18128/11 "2022-07-18T09:31:43Z")

</div>



---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [July 18, 2022, 9:31am UTC](https://get-help.theconstruct.ai/t/ros2-nav2-course-project-problems/18128/12 "2022-07-18T09:31:46Z")

</div>



---

<div class="post-metadata">

**Author:** ![bayodesegun](https://get-help.theconstruct.ai/user_avatar/get-help.theconstruct.ai/bayodesegun/32/10684_2.png) [@bayodesegun](https://get-help.theconstruct.ai/u/bayodesegun)\
**Post date:** [July 23, 2022, 7:00am UTC](https://get-help.theconstruct.ai/t/ros2-nav2-course-project-problems/18128/13 "2022-07-23T07:00:24Z")

</div>

This topic was automatically closed after 4 days. New replies are no longer allowed.
