Mapping for Mobile Robots and UGV - MATLAB
Video Player is loading.
Current Time 0:00
Duration 10:01
Loaded: 1.65%
Stream Type LIVE
Remaining Time 10:01
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 10:01

    Mapping for Mobile Robots and UGV

    From the series: Modeling, Simulation, and Control

    Discover how to create occupancy grids from different sources after collecting environment information using various robot sensors. You’ll also learn how to use ROS-enabled systems with MATLAB® and Simulink® to generate and simulate maps that you can use for developing autonomous navigation algorithms such as path planning and control.

    Autonomous systems such as mobile robots and unmanned ground vehicles require digital representations of their environments to navigate effectively. Occupancy grid objects provide versatile representations that interact with existing motion planning, control, and localization algorithms. After watching this video, you'll be able to use MATLAB to map robot environments from either individual numerical arrays, images, or lidar scans with the SLAM Map Builder app.

    Published: 7 Oct 2021

    Welcome to the MATLAB and Simulink Robotics Arena. In this video, we will be covering mapping for mobile robots and unmanned ground vehicles. By the end of this video, you should be able to better understand how to use mapping for robotics and autonomous systems applications, different uses for pre-built maps, the different map representations, and how to create maps from either arrays, images, or lidar scans.

    Robot mapping means capturing environment information such as features, obstacles, and objects so that your robot can correctly interact with all of these portions of your environment. Maps are generally represented using grids, where the grid positions or locations can be set as either free or occupied space. In turn this grid information is implemented in software using objects that will contain or encapsulate the different arrays and parameters. The object will contain information such as the grid itself, the map limits, the information of the origin, and also the resolution of the map itself so that it can be correlated to the physical world.

    In this case, we can see the parameters contained within a MATLAB mapping object called the binary occupancy map. And here you can see that you have access to your x and y local limits, x and y world limits, and a whole other array of information. Having a map defined as an occupancy grid will give you access to important utilities.

    These utilities will help with your robotics workflows, especially in navigation workflows by letting you access the information in the map like getting the occupancy, or inflating the occupied spaces in the map to prevent the robot from running into obstacles or even moving certain portions of your map to account for different coordinate transformation that your algorithm might require. Maps can come in several different types. Occupancy grids in particular can come in binary form, which will only specify when there are spaces free or occupied.

    They can also be probabilistic occupancy grids, which will give you a more granular set of information, ranging from let's say zero to one that will give you the probability of a certain section or portion of the grid of being occupied or not. And then finally, they can be split up by dimensions. Occupancy maps can represent spaces in either two dimensions or three dimensions depending on the application that you're going to be using these maps.

    With the brief introduction on mapping for robotics and autonomous systems application, we will now move over to a hands-on software demo to show you how to create maps. If you'd like to follow along or are interested in the files we will be using here, you can find the link to the files in the description below. This example live script will show you how to create maps from arrays. In this case, we are creating a map to correspond to an environment that is 10 meters by 10 meters, and we are trying to create it with the resolution of five cells per meter.

    For that we use the binary occupancy map method, and then specify the dimension and resolution of our map. You can see on the right in the live script that we now have a map that's of binary occupancy map type with the following properties, some of which are the grid size, which corresponds to our dimensions times the resolution, and then the different local and world limits that we have set forth. Then we will create an array that we can use for setting the occupied space within the map.

    In this case, we're creating a variable called walls that is of 50 by 50, which corresponds to the grid size of our map and then setting the occupied space on the relevant locations, in this case for the walls and some divisions by using the value of one. Then we update the map that we've created, called my map, by using the method set setOccupancy and passing the variable we create.

    And this is what our binary occupancy grid will look like once we've assigned the occupied space using the array. We can see in the visual that the walls are now corresponding to occupied space and we have three divisions in the middle of the map. Now one of the utilities that occupancy grids will provide you is the ability to inflate your occupancy map.

    Inflating your map means that you can have a safety factor for your robot radius so that it won't run into the occupied space. In this case, we can set an inflate radius of 0.3. And then use the inflate method to update my map. You can see that we will now have much thicker walls which will then translate into a bigger safety factor when using any motion or path planning algorithms.

    If you're interested in individually checking whether a portion of that map is occupied, you can always use the method checkOccupancy, pass on your map and then the location that you would like to check. And in this case, we can see that if we want to check whether the location corresponding to positive 5 meters and 5 meters is occupied, then we get the answer as true.

    You can also create 3D occupancy maps. In this case, I'm creating a placeholder array to store the map information and then I am extruding the current map that I already have in two dimensions by adding a z-coordinate to all of the elements. Finally, I will set the occupancy using the setOccupancy method by passing my coordinates array and my occupancy area.

    And you can see here how we now have a three-dimensional version that has been extruded on a z dimension. 3D occupancy maps are also very popular for UAV applications. So if you're interested in mapping for UAV navigation, we recommend that you take a look at the documentation for the MATLAB UAV Toolbox.

    However, creating these maps by specifically defining each of the individual grid locations using arrays can be very time consuming. A much more efficient way of creating maps is by processing images of your current environment. And then using those to set the occupied space in your maps. One way to do this is by thresholding an image by its color. In this example, we have a top view image of our Turtlebot map that contains all the relevant walls that we would like to prevent our robots from running into. So we would load that image into MATLAB and then threshold it by color.

    You will see that we now have a black and white version of the map that contains only the information from the walls. In this case, we will resize it to a resolution of 520 by 520 pixels since we're trying to create a binary occupancy map with length and width of 5.2 meters and a resolution of 100 cells per meter. After we set the occupancy in our object, we can see the finalized version of binary occupancy rate.

    A more accurate way to create maps of your robot impairments would be to use laser scanners to capture information from the different surfaces. In this case, we're using a simulated robot that is ros-enabled. And we are using the rosbag functionality in order to record the laser scans at each point in time and the odometry of the robot.

    For the purposes of our demo, we're using a Simulink model that controls a robot so that we can drive it around the different paths within the environment and capture data from all the relevant surfaces or walls in this case. Once we have a rosbag containing the odometry data and the lidar scan data for the exploratory run we just perform with our robot, we can then go to the MATLAB app menu and select the SLAM Map Builder app. In the SLAM Map Builder application you can import your rosbag back file.

    And select a downsampling scale for your scan so that the algorithm can run more efficiently and take less time. In this case, we will downsample to 50% of our scans. And apply those changes. Then we will adjust our SLAM settings. In this case, we will change our optimization interval to 10 loop closures. If you want more information regarding the SLAM settings you can check the documentation links in the example.

    And finally, we can click the Build button on the app. The application will start processing all the different scans and building one map from all of them. In this case, you can see how the application is surfing through the scans using the progress bar and you can see how the map gets more information added to it, which each new scan that is correlated into the algorithm.

    In this case, we'll fast forward towards the end of the map building process to show you the end result. But you can adjust your SLAM settings in order to make this process go faster or slower depending on the accuracy you need and the data that you have. Finally you can export your occupancy map directly from this SLAM Map Builder app and you will end up with the map file containing the occupancy map that you can use for other workflows.

    Now that you have this detailed representation of your robot environment, you can use it for either motion planning, or path planning, prototyping and simulation of your robot or autonomous system, or other algorithms, such as Monte Carlo localization. In this video, we covered the different uses for pre-built maps for robotics and autonomous systems, the different map representations and how to create these maps from either arrays, images, or lidar scans that can come from your ros-enabled robots.

    If you have any questions, feel free to reach out to us at roboticsarena@mathworks.com or feel free to check out any more of our videos and resources available on our website. Thanks for watching.

    Up Next:

    View full series (20 Videos)

    View more related videos