REMINDER: configure your environment before starting this tutorial.
This tutorial shows how to use Erle-Rover with a known map. This assumes that you have a map of robot environment. such as the one generated by the previous tutorial.
Make sure the minimal software has already been launched on the robot and you have configured your network correctly.
For this propuse we are going to use amcl, this is a probabilistic localization system for a robot moving in 2D. It implements the adaptive (or KLD-sampling) Monte Carlo localization approach, which uses a particle filter to track the pose of a robot against a known map.
Download the github repository and compile the code following these instructions:
mkdir -p ~/erle_ws/src cd ~/erle_ws/src git clone https://github.com/erlerobot/gazebo_cpp_examples cd .. catkin_make --pkg ros_erle_rover_navigation
Now, let's launch the simulation.
source ~/simulation/ros_catkin_ws/devel/setup.bash cd ~/simulation/ardupilot/APMrover2 ../Tools/autotest/sim_vehicle.sh -j 4 -f Gazebo # once MAVProxy has launched completely, load the parameters param load /[path_to_your_home_directory]/simulation/ardupilot/Tools/Frame_params/3DR_Rover.param # NOTE: replace [path_to_your_home_directory] with the actual path to your home directory. # Example: param load /home/john/simulation/ardupilot/Tools/Frame_params/3DR_Rover.param param set SYSID_MYGCS 1
In another terminal
source ~/simulation/ros_catkin_ws/devel/setup.bash roslaunch ardupilot_sitl_gazebo_plugin rover_maze.launch
This will spawn the Erle-Rover inside a maze.
Now run the nodes to get the autonomous navigation:
source ~/simulation/ros_catkin_ws/devel/setup.bash roslaunch ros_erle_rover_navigation navigation_sim.launch map_file:=map.yaml
When starting up, the Erle-Rover does not know where to go. To provide it its approximate goal on the map:
The navigation stack uses two costmaps to store information about obstacles in the world. One costmap is used for global planning, meaning creating long-term plans over the entire environment, and the other is used for local planning and obstacle avoidance.
You should use
costmap_2d package whenever you want to create a costmap for your robot to navigate through. This package has the ability to use distance sensor information in order to create a costmap with information about obstacles in the map.
The costmap update cycles at the rate specified by the
update_frequency parameter. Each update, the costmap will mark and clear objects.
Inflation is the process of propagating cost values from the occupied cells that decrease with distance.
The following part describes the costmap of the footprint. It will be centered on the
base_footprint frame and will extend to the footprint that you specify below in meters. The padding will specify if you want to create a little bit of a cushion between your footprint and the obstacles. The footprint should be calculated yourself and is very important. It will tell the planner of collisions. The inflation radius determines how much the obstacle is inflated. This is discussed in the inflation section above.
footprint: [[-0.4, -0.2], [-0.4, 0.2], [0.4, 0.2], [0.46, 0.0], [0.4, -0.2]] inflation_radius: 0.5
The next part is the most important as it will cause the costmap to fail if not specified correctly. We must tell the navigation stack which topic to listen to for the sensor information. We must also specify the type of the source so that it knows how to handle it:
observation_sources: scan scan: data_type: LaserScan topic: scan marking: true clearing: true min_obstacle_height: 0.0 max_obstacle_height: 0.4 observation_persistence: 0.0 expected_update_rate: 0.1 inf_is_valid: true
The blue and red cells represent obstacles inflated by the inscribed radius of the robot, and the red polygon represents the footprint of the robot.