ROS2 Jazzy + Gazebo Harmonic simulation environment for a 6-legged hexapod robot. Features realistic physics, collision detection, and hardware integration capabilities.
- 18-DOF Hexapod Robot - 6 legs with 3 joints each
- Multiple Gait Patterns - Wave, bipod, tripod, ripple gaits for different terrains
- Contact Sensor Integration - Foot contact detection for adaptive walking
- IMU Stabilization - Body orientation control based on inertial feedback
- Dual Mode Operation - Seamless switching between simulation and real hardware
- Mobile App Control - Wireless control via WebSocket interface
- MoveIt Integration - Advanced motion planning and trajectory control
- Real-time Physics - Gazebo simulation with accurate collision detection
- ROS2 Native - Full ros2_control integration with joint trajectory controllers
- ESP32 Hardware Interface - Direct serial communication with servo controllers
- Ubuntu 24.04 (recommended, but other Ubuntu 24 releases should also work).
- ROS2 Jazzy Jalisco
Link to installation tutorial - Gazebo Harmonic
Link to installation tutorial - MoveIt
Link to installation tutorial
# Clone repository
git clone https://github.com/Siedmiu/Hexapod-ROS2-System.git
cd Hexapod/sim_and_real/ros2_ws_hex
# Build packages
colcon build
# Source workspace
source install/setup.bashIf the packages build correctly, you should be able to run all necessary launch files and programs.
ros2 launch hex_gz gazebo.launch.pyThis should open the Gazebo simulator with a world containing the robot model and an inclined plane.
To run controllers on the real robot, you need to check which port the ESP32 microcontroller is connected to. You can view all active ports with:
ls /dev/tty{USB,ACM}*The ESP32 should appear on one of these ports.
Launching hardware controllers:
# If ESP32 is on USB0
ros2 launch hex_gz robot.launch.py port_name:=/dev/ttyUSB0
# If ESP32 is on ACM0
ros2 launch hex_gz robot.launch.py port_name:=/dev/ttyACM0After launching the controllers (either in simulation or on hardware), you can activate the robot by running one of the movement algorithms. General syntax looks like this:
ros2 run hex_gz [name_of_algorithm]List of available executables:
# Basic movement algorithms
ros2 run hex_gz wave_gate_square.py
ros2 run hex_gz bi_gate.py
ros2 run hex_gz tri_gate.py
ros2 run hex_gz ripple_gate.py
ros2 run hex_gz rotation.py
# Algorithms using contact sensors
ros2 run hex_gz wave_gate_contact_sensors.py
ros2 run hex_gz bi_gate_contact_sensors.py
ros2 run hex_gz tri_gate_contact_sensor.py
# Other executables
ros2 run hex_gz hi.py
ros2 run hex_gz dance.py
ros2 run hex_gz dance1.py
ros2 run hex_gz move_body_based_on_imu.pyYou can control the robot via a mobile application, but first you need to configure it properly.
- Connect the ROS system to the same Wi-Fi network as the mobile device.
- Check the IP address of the ROS system using:
ifconfig
- Insert this address into the application.
- Launch either the Gazebo simulation or the hardware controllers as described earlier.
- In another terminal, run:
ros2 run hex_gz ws_run.py
The MoveIt GUI allows you to control individual joints, move individual robot legs to specific positions, or configure custom trajectory points.
First, launch the hardware controllers or Gazebo simulation:
ros2 launch hexapod_moveit_config demo.launch.pyViewing the robot model in the ROS2 visualization tool, Rviz:
ros2 launch hex_gz rviz.launch.pyViewing the collision model specifically:
ros2 launch hex_gz collision_view.launch.pyThis project uses the ROS2 framework and follows the standard ROS package structure. The initial setup and configuration patterns were inspired by ROBOTIS open_manipulator, although the implementation has been completely redesigned for hexapod robotics, with original kinematics, hardware interfaces, and control algorithms.
