This ROS2 package provides an enhanced Ackermann steering controller with a smooth bicycle kinematic model, designed for accurate robot simulation and navigation in ROS2 Jazzy. It handles numerous edge cases.
- Smooth Bicycle Kinematics: Implements
δ = atan(L*ω/v)for accurate, Nav2-compatible steering. The controller logic is designed to prevent jerks and ensure smooth motion. - Robust Edge Case Handling:
- Turning in Place: Manages commands with only an
angular.zcomponent (andlinear.xis zero), allowing the robot to remain stationary. - Velocity Deadzone: Velocities below
0.001are treated as zero to prevent minor drift from joystick noise. - Handles various other scenarios to ensure stable and predictable behavior.
- Turning in Place: Manages commands with only an
- Persistent Steering: Maintains the current steering angle even when the robot is stopped, allowing for precise maneuvering.
- Command Timeout with Auto-Reset: If no commands are received for 2 seconds, the steering angle gradually and smoothly returns to the center position.
- Teleoperation Options:
- PS4 DualShock 4 Controller (Recommended): Uses
joyandteleop_twist_joyfor responsive control. - Standard Keyboard: Uses the standard
teleop_twist_keyboardfor basic control.
- PS4 DualShock 4 Controller (Recommended): Uses
Below is a demonstration of the Ackermann controller in action within a Gazebo simulation, controlled using a PS4 controller.
Ackermann.Drive.Bot.operated.using.a.PS4.controller.webm
- ROS2 Jazzy Jalisco
ros-jazzy-teleop-twist-joyros-jazzy-joy
To install dependencies:
sudo apt-get update
sudo apt-get install ros-jazzy-teleop-twist-joy ros-jazzy-joy- Navigate to your ROS2 workspace's
srcdirectory:cd ~/prototype_autonomous_bot_cir_ws/src
- (If not already present) Clone the repository:
# git clone <your-repo-url> - Build the package using
colcon:cd ~/prototype_autonomous_bot_cir_ws colcon build --packages-select custom_ackermann_controller
- Source the workspace:
source install/setup.bash
To run the full simulation, open three separate terminals.
Terminal 1: Launch Robot Simulation
source ~/prototype_autonomous_bot_cir_ws/install/setup.bash
ros2 launch bot_description gazebo.launch.pyTerminal 2: Run the Ackermann Controller
source ~/prototype_autonomous_bot_cir_ws/install/setup.bash
ros2 run custom_ackermann_controller ackermann_twist_controllerTerminal 3: Choose a Teleoperation Method
Ensure your PS4 controller is connected via Bluetooth or USB. You may need to set permissions for the joystick device:
sudo chmod 666 /dev/input/js0Launch the joystick teleop node:
source ~/prototype_autonomous_bot_cir_ws/install/setup.bash
ros2 launch custom_ackermann_controller joystick_teleop.launch.pyPS4 Controller Mappings:
| Control | PS4 Input | Function |
|---|---|---|
| Movement | Left Stick Up/Down | Forward/Backward (linear.x) |
| Steering | Left Stick Left/Right | Turn Left/Right (angular.z) |
| Enable | L1 Button | Must hold to activate movement |
| Turbo | R1 Button | Hold for faster movement |
This uses the standard ROS2 keyboard teleop but does not support simultaneous forward and turning commands.
source ~/prototype_autonomous_bot_cir_ws/install/setup.bash
ros2 run teleop_twist_keyboard teleop_twist_keyboardThe core node that subscribes to /cmd_vel (Twist messages) and converts them into Ackermann steering and velocity commands. It publishes Float64MultiArray messages to the `/forward_position_contro[...]
A diagnostic script to test the PS4 controller. It subscribes to the /joy topic and displays crucial real-time information, including the raw data received from the controller and the corresponding [...]
Launches the joy_node for joystick communication and the teleop_twist_joy node with pre-configured parameters for a PS4 DualShock 4 controller.