This exercise is based on CMU 16663 - F1Tenth Course :: Lab 5.
Here, we are getting into localization, specifically, we are going to learn about and use particle filter.
Please watch UPenn's F1Tenth lecture on Localization using Particle Filters and review CMU's F1Tenth lecture slide on Particle Filters and Particle Filter Analysis.
Once you have a comprehensive understanding of localization with particle filters, run particle_filter on the car using the map you made with SLAM inside the simulator.
- Clone the
range_libcrepo:git clone https://github.com/f1tenth/range_libc.git
- Install with the following commands:
cd range_libc/pywrappersudo WITH_CUDA=ON python setup.py install
- Clone the
particle_filterpackagecd /home/{username}/{workspace}/srcgit clone https://github.com/f1tenth/particle_filter.git
- Install dependencies
rosdep install -r --from-paths src --ignore-src --rosdistro foxy -y
- Compile your workspace again and source it
cd /home/{username}/{workspace} && colcon build
source install/setup.bash - Launching
particle_filter- Launch
teleopin one window - Launch
particle_filterin another windowros2 launch particle_filter localize_launch.py
- Launch
- Visualization
- Launch rviz2
- Add
/mapby topic - In the settings for
/map, change durability policy under topic totransient local. - To show the current localization, add
/pf/viz/inferred_posetopic. - Optionally, you can add
/pf/viz/particlesto see the particles.
- Check the update frequency
Check the publishing frequency on
/pf/viz/inferred_pose. It should be at least 30 Hz. - Changing the map in use
- Put the map files (
.pngimage and.yamlfile) inparticle_filter/maps. - Change
particle_filter/config/localize.yamlto reflect the map you want to use.
- Put the map files (
- Use the "2D Pose Estimate" to set the initial position for the particle filter, as shown below in the figure:
