Skip to content
charly525Public

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Robot Hexápodo ROS2 - Marcha Trípode

Plataforma: ROS2 Jazzy Jalisco | Ubuntu 24.04
Hardware: ESP32 38-pin + PCA9685 + US-016 + 12x SG90
Marcha: Trípode alternante (Grupo A: patas 1,3,5 | Grupo B: patas 2,4,6)

Hardware

Servos → Canales PCA9685

Pata Servo Canal Driver GPIO Driver
1 Proximal 0 (ch 1*) PCA9685
1 Distal 1 (ch 2*) PCA9685
2 Proximal 2 (ch 3*) PCA9685
2 Distal 3 (ch 4*) PCA9685
3 Proximal 4 (ch 5*) PCA9685
3 Distal 5 (ch 6*) PCA9685
4 Proximal 6 (ch 7*) PCA9685
4 Distal 7 (ch 8*) PCA9685
5 Proximal 8 (ch 9*) PCA9685
5 Distal 9 (ch 10*) PCA9685
6 Proximal 10 (ch 11*) PCA9685
6 Distal 11 (ch 12*) PCA9685

*El enunciado usa numeración 1-based; el firmware usa 0-based internamente.

Sensores y Comunicación

Componente Pin ESP32 Notas
PCA9685 SDA GPIO21 (D21) I2C Data
PCA9685 SCL GPIO22 (D22) I2C Clock
US-016 ECHO GPIO35 (P35) Solo entrada
US-016 TRIG GPIO33 Salida trigger

Marcha Trípode

FASE 0:                          FASE 1:
  Grupo A (1,3,5): VUELO           Grupo A (1,3,5): SOPORTE/EMPUJE
  Grupo B (2,4,6): SOPORTE/EMPUJE  Grupo B (2,4,6): VUELO

       ①   ③   ⑤                       ①   ③   ⑤
      ↑↑   ↑↑  ↑↑  (levantando)       ←←   ←←  ←←  (empujando)
      ←←   ←←  ←←  (avanzando)

       ②   ④   ⑥                       ②   ④   ⑥
      ←←   ←←  ←←  (empujando)        ↑↑   ↑↑  ↑↑  (levantando)
                                       ←←   ←←  ←←  (avanzando)

Ciclo completo: FASE 0 → FASE 1 → FASE 0 → ...

Parámetros ajustables:

  • step_height: cuánto sube cada pata (grados del servo distal)
  • step_forward: qué tan lejos avanza cada pata (grados del servo proximal)
  • push_back: qué tan atrás empuja la pata en soporte
  • gait_period: velocidad del ciclo (segundos)

Instalación y Configuración

Prerrequisitos

# Instalar ROS2 Jazzy Jalisco
sudo apt update && sudo apt install -y ros-jazzy-desktop

# Dependencias Python
pip3 install pyserial

# Permisos para puerto serial
sudo usermod -aG dialout $USER
# (Requiere cerrar sesión y volver a entrar)

Clonar

# Copiar el workspace a tu home
cp -r hexapod_ws ~/
cd ~/hexapod_ws

Compilar el workspace ROS2

source /opt/ros/jazzy/setup.bash
colcon build --symlink-install
source install/setup.bash

Comandos ROS2

Por línea de comandos

# Hacer caminar al robot
ros2 topic pub --once /hexapod/command std_msgs/msg/String '{data: walk}'

# Detener
ros2 topic pub --once /hexapod/command std_msgs/msg/String '{data: stop}'

# Rotar izquierda
ros2 topic pub --once /hexapod/command std_msgs/msg/String '{data: rotate_left}'

# Rotar derecha
ros2 topic pub --once /hexapod/command std_msgs/msg/String '{data: rotate_right}'

# Posición stand
ros2 topic pub --once /hexapod/command std_msgs/msg/String '{data: stand}'

# Volver a HOME
ros2 topic pub --once /hexapod/command std_msgs/msg/String '{data: home}'

# Caminar hacia atrás
ros2 topic pub --once /hexapod/command std_msgs/msg/String '{data: walk_back}'

# Ajustar velocidad (0.0 - 1.0)
ros2 topic pub --once /hexapod/speed std_msgs/msg/Float32 '{data: 0.7}'

Monitoreo

# Ver estado del robot
ros2 topic echo /hexapod/state

# Ver distancia del sensor US-016
ros2 topic echo /hexapod/distance

# Ver alertas de obstáculos
ros2 topic echo /hexapod/obstacle_alert

# Ver ángulos de servos enviados a la ESP32
ros2 topic echo /hexapod/servo_angles

# Estado de la ESP32
ros2 topic echo /hexapod/esp32_status

# Ver todos los topics activos
ros2 topic list

Cambiar parámetros en tiempo real

# Cambiar velocidad de marcha
ros2 param set /gait_controller gait_period 0.4

# Cambiar altura del paso
ros2 param set /gait_controller step_height 35.0

# Cambiar umbral de obstáculo
ros2 param set /obstacle_monitor warning_distance_cm 25.0

Estructura del Proyecto

hexapod_ws/
├── hexapod.code-workspace          # Workspace VS Code
└── src/hexapod_robot/
    ├── CMakeLists.txt              # Mensajes personalizados ROS2
    ├── package.xml
    ├── msg/
    │   ├── ServoCommand.msg
    │   ├── LegCommand.msg
    │   └── HexapodCommand.msg
    ├── config/
    │   └── hexapod_params.yaml     # Parámetros ajustables
    ├── launch/
    │   └── hexapod_launch.py       # Launch file principal
    ├── hexapod_controller/         # Paquete Python ROS2
    │   ├── package.xml
    │   ├── setup.py
    │   └── hexapod_controller/
    │       ├── gait_controller.py  # Marcha trípode
    │       ├── serial_bridge.py    # Comunicación ESP32
    │       ├── obstacle_monitor.py # Sensor US-016
    │       └── teleop_node.py      # Control por teclado
    └── hexapod_firmware/           # Firmware ESP32
        ├── hexapod_esp32.ino       # Código principal
        └── platformio.ini          # Configuración PlatformIO

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages