Skip to content

Gazebo simulation model for PiRacer control and experimentation

License

Notifications You must be signed in to change notification settings

lalywr2000/PiRacer-Gazebo-Simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PiRacer Simulation with ROS2 and Gazebo


This repository provides tools and examples for controlling and experimenting with PiRacer model vehicle in Gazebo. The Gazebo model, designed to match the hardware specifications of PiRacer, can be controlled via ROS2 topic communication. The included teleoperation example is a simple demonstration using the WASD keys on the keyboard, allowing simultaneous control of both the real PiRacer and the PiRacer in Gazebo.

The idea is to utilize this repository as a template for digital twin research. By equipping PiRacer with sensors such as odometer, IMU, LiDAR, etc., and implementing closed-loop feedback control, it would be possible to more accurately replicate the behavior of the real-world PiRacer in Gazebo.

Throttle Steering
Throttle Steering

ROS2 Packages

./
 ├── simulation_ws/src/
 │   └── sim        # Description and launch file for PiRacer model
 │
 └── teleoperation_ws/src/
     └── teleop     # Remote control example including a controller and a receiver

Requirements

Before using this package, ensure the following prerequisites are installed:

Device Software/Framework Functionality
Local Gazebo 11 Simulation environment
Local ROS2 Foxy Robotics middleware
Local pygame Keyboard input for control
Raspberry Pi ROS2 Foxy Robotics middleware
Raspberry Pi piracer Physical PiRacer control

This package has been developed and tested on both local machine and Raspberry Pi 4, using Ubuntu 20.04.

Usage

Gazebo Simulator and Teleoperation Controller are for local environment. While this controller can simultaneously control physical PiRacer, if the purpose is solely simulation, the setup on Raspberry Pi can be disregarded, and only the local environment is utilized.

0. Package Configuration

Change the gazebo_model_path in the package.xml located in simulation_ws/src/sim to suit your local environment.

1. Launch Gazebo Simulator

# Local
cd simulation_ws
colcon build

source install/local_setup.bash
ros2 launch sim sim.launch.py

You should see the PiRacer model inside the Gazebo simulation window.

2. Run Teleoperation Receiver

# Raspberry Pi
cd teleoperation_ws
colcon build

source install/local_setup.bash
ros2 run teleop receiver

3. Run Teleoperation Controller

# Local
cd teleoperation_ws

source install/local_setup.bash
ros2 run teleop controller

When you run the controller, a small pygame window like the following will appear.

Click on this window and press the WASD keys on the keyboard. Observe the movement of both Gazebo PiRacer and physical PiRacer.

Note

The communication between controller node and receiver node is machine-to-machine. Make sure that local machine and Raspberry Pi are connected to the same WLAN. If connection is not successful, disable the firewall using the following command.

# Local & Raspberry Pi
sudo ufw disable

Explore

Design various experiments and developments using the Gazebo PiRacer. This package provides an example with the PiRacer camera. Check the view of the PiRacer's camera using RViz2. For instance, you can use this image data to implement autonomous driving in the simulation.

References