How to use rviz and gmapping with magni robot?

I would like to use rviz and gmapping (or any similar application for mapping) with magni robot. I have an rplidar and I would like to make a map of my room and vizualize it. Is it necessary to install rviz and gmapping on my raspberry or there is another option to use rviz and gmapping? Please, advise!

Well you have requested something I put together exactly in a page on our ‘learn’ site.

See this page: Lidar-Based Localization | Learn Ubiquity Robots and ROS

We did this for the exact need you are thinking about doing.

Enjoy, Mark

1 Like

Hi,

Thank your for your help. I’ve started executing this tutorial. Everything is OK till the map creation. I’m using this script:

rosrun map_server map_saver -f mynewmap-ils

Unfortunately I’m receiving this note: “Waiting for the map” and it is waiting here without creating anything. Could you please help to resolve the problem?

Just about EVERY command I discuss must be run on the Magni robot itself, not your laptop. Only the rviz command is run on the laptop just to see the map being formed and the robot drive around. All the other scripts must be run on the robot itself for this demo as it is written.

You must open up ssh session(s) from your laptop to to get a terminal to a console on the robot.

Do not skip any of the verification steps. Those will help you see how to debug ROS and the lidar and so on and if those things are not seen to be working you should not go on because something is not right. So please do all the verifications as they happen from start to end.

Once you have started on the robot the magni_lidar_mapmaker.launch command line you must drive around a little bit like I discuss using teleop_twist_keyboard command or the joystick if you bought one of those. As you drive you need to see more and more of the map get ‘built’ as you monitor the progress on your laptop. Only the .rviz command is run on the laptop, everything else is all on the robot using ssh screens to the robot

Your rviz mut show the mapped area as ‘grey’ or perhaps you have not made a map yet.

Once you really do have a map as seen on rviz on your laptop only then back on an ssh windows BEFORE YOU STOP THE MAPPING run from a SEPARATE ssh window to the Magni the map saving tool.

1 Like

Hello,

Thank you for your answer. It’s working now according to your tutorial. I’ve created a map of my lab and I’ve saved it. I have some questions.

  1. After creating a map I’ve started this script:
roslaunch magni_lidar magni_lidar_maprunner.launch  

What is the difference between this script and this one:

roslaunch magni_lidar magni_lidar_mapmaker.launch
  1. I’ve started this script too:
roslaunch magni_nav move_basic.launch

I think that move_basic is used for obstacle avoidance. When I’m close to the wall the magni robot is stopping, right?

  1. After I’m starting this script:

rosrun rviz rviz -d lidar_mapmaker.rviz

It think that it is loading my map after making some corrections into the launch file (changing the name of the yaml file and the baud rate of my laser scanner). I see that the map is moving all the time regarding the red line (real time laser scanner data). Why does it happen? I thought that the map and the red line of the scanner have to be moved together.

  1. I’ve tried this script too:
roslaunch magni_lidar magni_lidar_maprunner_amcl.launch  

There is something wrong. You can see it on my pics that I’ve attached to this message. Could you please explain when and how I can use AMCL?

  1. After this tutorial I would like to put some points into the map and starting their execution with the magni robot. Is it possible to realize this task? I would like to make some corrections of the pose if there are some.

Thank you!

There are ways to avoid this but for your 1st experiences here is what I was trying to indicate in the video.

AMCL can be fooled in a room that looks very ‘regular’. Another thing to try is put a box or cover a corner of the area with a sheet of cardboard for your experiment. This set of boxes or cardboard must be tall enough so the lidar sees it. This helps because it is easier for AMCL to realize its rotation and location (pose) if the room cannot be confused easily. Suppose you put the robot in a complete circular room. That is the very worse. The robot has an infinite number of places it could think it is in. For a total square there are 4 or 8 places it may think are right and for a rectangle, maybe 4 or so. Thus make your room very unique by making one corner obviously not just a squared off wall.

When you first start to create the map start with a full reboot of Magni where you put a couple pieces of tape on the floor so you will remember where your zero point was when you first made the map.

Later when you are going to do the maprunner manually put Magni right back to where the wheels centers are marked with the tape pieces from before. Then reboot and since the robot is in the very same place as where you started the map you will not have to do a step called ‘setting the initial pose’. So I suggest keep this simple by starting the maprunner on magni after a reboot of Magni when it was sitting in same place s where it was for when you FIRST started the step to make the map in the first place.

Try this which is the simplest way to convince yourself things basically work.

Only after that you can try starting map runner from some other place but you must then try to judge where the robot is in the map and so a odd pulldown and setting location and rotation thing which I am not going to explain right now. You really need to see a video where somebody sets the pose using rviz so again, skip that for now by starting map make and runner from SAME spots after full robot reboot.

1 Like

Thank you for your answer! I tried to start the maprunner on magni after a reboot when it was sitting in the same place as where it was for wehen I first started the step to make the map. It’s working but the created map and the red line are moving again. If there is no matching between the red line of the scanner and the map, I don’t need to create a map, right? If I have the map it is not necessary to have a laser scanner or sonar sensors, right?

The sonar sensors are not involved in the map making in any way is one thing.

I am not sure I quite understand the rest of the question. Sorry. It is extremely late here, 3am. I will look back here again in my own ‘tomorrow’

As I see the sonar sensors are involved in move_basic application. As I understood if I have a map it is not necessary to have a laser scanner anymore, right?

When I start this script:

roslaunch magni_lidar magni_lidar_maprunner_amcl.launch  

There is the following warning:

It’s OK now but the map and the red line don’t fit!

Here is my robot. May be I have to correct the position of the laser but I’m not sure. Could you please help!

Several questions. Here are some answers:

  • You need the lidar while making the map and you need it later when you navigate. The lidar is how the robot sees the walls and objects at the height of the lidar. You cannot drive around later if the robot cannot ‘see’ those walls.

  • The room must be IDENTICAL for map making and for later driving around for best results. IF a new object shows up when you later drive it may or may not be able to figure out where it is in the room

  • It is required that the robot know right where the lidar is and how it is rotated for any of this to work right. Look where I put the lidar in the page I have already linked for you and you will see your lidar is in the wrong place in both X and Y by 5 or more cm.
    Lidar-Based Localization | Learn Ubiquity Robots and ROS

  • Your lidar is not the same lidar I used in my writting of the tutorial. I don’t know how to properly position your lidar and there could be things like it rotates in the opposite direction or things like it is upside down scan from how my RP-Lidar scan works. This is one of the most critical things and is rather complex to help you with frankly if I don’t have the very same lidar.

  • I also am not sure you are understanding or following my directions when I say you mark where the robot wheels are and fully reboot the robot at that ‘zero’ location. You then make the map and for a very simple room try just driving forward and backwards for map making without rotating just to keep things very simple. Later when you want to do the maprunner script place the robot right were it started for map making and fully rebot the robot there.

If when you run the maprunner and see your robot it should start right where the map origin was so the red lidar dots should align nicely with your map prior to any movement.

Next if that is true try driving forward. If your robot does NOT drive forward on the map that is an indication your lidar alignment is not right for your lidar.