1e660fcdb610511744fc3d859d3a018b5b3d6c91
Add copy() to PosArray, DegArray and RadArray to allow easy shallow copies. Change RobotState imports in idle.py and walking.py to use explicit 'from RobotState.RobotState import RobotState' to avoid import issues. In main.py create a threading.Lock and pass it into the controller thread args to prepare for synchronized access in controller_loop.
JackBot — Hexapod Control & Simulation
Purpose
- Overview: JackBot is a Python project for controlling and simulating a six-legged (hexapod) robot. It computes foot trajectories, runs inverse kinematics against a URDF model, and sends joint commands to either a hardware controller (ESP32 / Arduino) or a PyBullet simulation.
Setup Dependencies and Virtual Enviroment
- Python packages: At minimum the project uses
numpy,pygame,ikpy,pybullet,pyserial, andmatplotlib. - Install (recommended inside a venv):
Linux / macOS (Bash):
python3 -m venv .venv
source .venv/bin/activate
pip install numpy pygame ikpy pybullet pyserial matplotlib
Windows (PowerShell):
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install numpy pygame ikpy pybullet pyserial matplotlib
If PowerShell blocks activation, run:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned
.\.venv\Scripts\Activate.ps1
Quick Start
- Simulation: enable the simulator in
config.pyby settingsim = True, then run:
python3 main.py
- Hardware: set
sim = Falseinconfig.pyand choosearduinoConnection = Trueor provide your ESP32 settings. Verifyport,baudrate,esp32_ip, andesp32_portinconfig.py.
Project structure (key files)
- Entry point: main.py — starts the controller and state loop.
- Controller: Controller.py — joystick input and
ControlIntentupdates. - Kinematics: kinematics.py — URDF-based forward/inverse kinematics using IKPy.
- Simulation: simulation.py — PyBullet visualization and joint control.
- Hardware comms: EspCommunication.py and ArduinoCommunication.py — send commands to ESP32 or Arduino.
- Runtime globals: GlobalVariables.py — central runtime objects and flags.
- Types: DataTypes.py —
PosArray,DegArray,RadArray,ControlIntent. - States: RobotState/idle.py and RobotState/walking.py — state machine implementations.
- Config: config.py — ports, flags (
sim,arduinoConnection), URDF path, timing values.
How it works
main.pycreates aControlIntentandRobotContext, starts the controller thread, and runs a state loop. TheWalkingStatecomputes per-leg foot paths (Bezier/linear), converts positions to joint angles withkinematics.ikpyInverse(), then sends commands to hardware or updates the simulator.
Configuration notes
- URDF: the robot description file is
JackBotUrdf.urdf; ensure the path inconfig.py(urdf_path) is correct. - Timing: step timing and tick rate are configured in
config.py(standard_duration,standard_tickpersec).
Suggested next steps
- Add a
requirements.txtorpyproject.tomlfor reproducible installs. - Document hardware wiring and expected serial/ESP packet formats if you plan to use hardware.
- Provide an example
config.pyfor common setups (sim vs hardware).
License & Contributing
- No license file included. Add
LICENSEif you want to publish or share. - Contributions: open an issue or PR with improvements; add tests for kinematics if possible.
Description
Languages
Python
100%