Once your robot is started you can enable SLAM mapping as follows:
ros2 launch turtlebot3_cartographer cartographer.launch.py
Use teleop to drive your robot around the room to create a map.
Once you are satisfied with your map, you can save it user the
map_saver_cli
node:
ros2 run nav2_map_server map_saver_cli -f ~/engeo1203
You’ll need to edit the resulting engeo1203.yaml
file to change
the occupied_thresh
and free_thresh
values to .6 and .18
respectively.
Upload a copy of your finished map to Canvas. Make sure to upload both the .yaml and the .pgm file. Only upload one copy per group.
Clone the following repository into your workspace. This is the starter code for PA2:
https://github.com/JMU-ROBOTICS-VIVA/particle_filter
Build and source this package.
Once this package is installed, you should be able to test the starter code by executing:
ros2 launch particle_filter amcl.launch.py use_sim_time:=false map:=$HOME/engeo1203.yaml
You should be able to set the initial pose, but the particle filter won’t update, since that code isn’t written yet.
You can test the standard Nav2 particle filter implementation as follows:
ros2 launch particle_filter nav2_amcl.launch.py use_sim_time:=false map:=$HOME/engeo1203.yaml
Once this is running, you should be able to set your initial pose and then the robot should be localized correctly as you drive it using teleop.
Try modifying some of the settings in
particle_filter/config/default_tb.yaml
to see how they impact
the behavior of the particle filter. The parameters are
documented here:
https://navigation.ros.org/configuration/packages/configuring-amcl.html
You’ll need to rebuild the package to test your changes.
You can launch the full navigation stack, including localization and path planning, as follows. Make sure to shut down any localization nodes you may already have running.
ros2 launch turtlebot3_navigation2 navigation2.launch.py map:=$HOME/engeo1203.yaml use_sim_time:=false
At this point you should be able to control your robot by selecting navigation goals.