This project features an ESP32-based joystick data receiver integrated with a ROS 2 joy_serial_bridge package. The system enables control of a 4-wheeled drive robot equipped with a flywheel shooting mechanism, an adjustable angle motor, and a servo. The joystick axes and button inputs are processed and mapped to control the robot's motors and mechanisms.
- Joystick Input Parsing: Receives joystick data in the format
"axes;buttons"via ROS and parses it. - 4-Wheeled Drive Control: Maps joystick axes to control forward, backward, left, and right movement.
- Flywheel Shooting Mechanism: Activates flywheel motors via specific joystick buttons.
- Servo Control: Adjusts servo position using joystick buttons.
- Angle Adjustment: Uses a dedicated motor to change the flywheel's shooting angle based on joystick input.
- Dynamic Feedback: Debugging information is printed to the serial monitor, including axis values, button states, and robot actions.
- ESP32 Microcontroller
- 4 DC Motors for Driving
- 2 Motors for Flywheel Shooting Mechanism
- 1 Motor for Angle Adjustment
- 1 Servo for fine control
- Joystick Controller
- joy_serial_bridge: Bridges joystick input
/joyfrom ROS to serial data sent to the ESP32.
-
ROS 2 (Humble or jazzy or later)
-
Python dependencies for ROS packages:
sudo apt install python3-serial
-
Hardware Setup:
- Connect the ESP32 to a computer via USB.
- Wire the motors, servo, and flywheel mechanism according to your robot's design.
-
Create a ROS workspace:
mkdir -p ~/joy_serial_ws/src cd ~/joy_serial_ws/src ros2 pkg create --build-type ament_python joy_serial_bridge
-
Add
joy_serial_bridgecode to the newly created package and build:cd ~/joy_serial_ws colcon build --packages-select joy_serial_bridge source install/setup.bash
-
Verify package visibility:
ros2 pkg list | grep joy_serial_bridge
- Open the Arduino IDE and load the
joy_serial_receiver.inofile provided in this repository. - Configure the serial monitor baud rate to
115200. - Upload the code to the ESP32.
- Start the joystick node:
ros2 run joy joy_node --ros-args -p deadzone:=0.0
- Echo the joystick data:
ros2 topic echo /joy - Start the
joy_serial_bridge:ros2 run joy_serial_bridge joy_to_serial --ros-args -p dev:=/dev/ttyUSB0 -p baud:=115200
- Driving: Use the left joystick to control forward, backward, left, and right movement.
- Flywheel Shooting: Activate the flywheel motors using the assigned button.
- Angle Adjustment: Adjust the shooting angle using the corresponding joystick axis.
- Servo Control: Fine-tune shooting angle using the servo control buttons.
Monitor joystick inputs and robot actions via the Arduino Serial Monitor or an alternative terminal:
sudo apt install minicomminicom -D /dev/ttyUSB0 -b 115200You should see parsed joystick data and corresponding robot actions.
- Adjust the axis/button mappings in the ESP32 code (
joy_serial_receiver.ino) to suit your robot's control requirements. - Ensure your motors and servo are configured correctly for the ESP32 pins.