A straightforward implementation of the Particle Filter algorithm for ROS 2, tailored for the TurtleBot4 platform. This package provides a foundational framework for localization in robotic systems using Python. This is part of a larger mobile robotic course that can be found here.
- Particle Filter Localization: Implements the particle filter algorithm to estimate the robot's pose based on sensor data.
- Map Utilities: Tools for handling and publishing maps within the ROS 2 ecosystem.
- Visualization: Integration with RViz for visualizing particles and robot pose.
- ROS 2: Ensure you have ROS 2 installed on your system. Follow the official ROS 2 installation guide if needed.
- TurtleBot4 Packages: Install the necessary TurtleBot4 packages:
sudo apt install ros-foxy-turtlebot4*
-
Clone the Repository:
cd ~/ros2_ws/src git clone https://github.com/aalghooneh/particlefilter-ros2.git
-
Install Dependencies 🛠️: Navigate to the workspace root and install any dependencies:
cd ~/ros2_ws rosdep install --from-paths src --ignore-src -r -y
-
Build the Package: Use
colcon
to build the workspace:colcon build --packages-select particlefilter-ros2
-
Source the Setup Script: After building, source the setup script to overlay the workspace on your environment:
source ~/ros2_ws/install/setup.bash
-
Start the ROS 2 Core:
ros2 run turtlebot4_bringup robot.launch.py
-
Run the Particle Filter Node: In a new terminal, execute:
ros2 run particlefilter-ros2 particle_filter
-
Visualize in RViz: Launch RViz to visualize the particles and robot pose:
rviz2 -d src/particlefilter-ros2/for_pf.rviz
If you have a pre-built map, you can publish it using the provided mapPublisher
script:
ros2 run particlefilter-ros2 mapPublisher.py --map_file path/to/your_map.yaml
Replace path/to/your_map.yaml
with the actual path to your map file.
The repository comprises several key scripts:
- particleFilter.py: Core implementation of the particle filter algorithm.
- particle.py: Defines the
Particle
class representing individual particles. - mapUtilities.py: Functions for loading and handling maps.
- mapPublisher.py: Node to publish the map to the ROS 2 network.
- utilities.py: Additional helper functions supporting the main algorithms.
Contributions are welcome! To contribute:
- Fork the Repository: Click on the "Fork" button at the top right of this page.
- Clone Your Fork:
git clone https://github.com/your-username/ros2-particlefilter-python.git
- Create a New Branch:
git checkout -b feature/your-feature-name
- Make Your Changes: Implement your feature or bug fix.
- Commit Your Changes:
git commit -m "Description of your changes"
- Push to Your Fork:
git push origin feature/your-feature-name
- Open a Pull Request: Navigate to the original repository and click on "New Pull Request".
This project is licensed under the MIT License. See the LICENSE file for details.
Note: This README provides a concise overview of the ParticleFilter-ROS2
package. For detailed information and advanced usage, refer to the source code and comments within the scripts.