merge conflict and readme update
old code was uploaded in the initial upload changed everything with working programm and updated the readme
This commit is contained in:
@@ -1,67 +1,103 @@
|
||||
|
||||
# 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.
|
||||
JackBot is a Python project for controlling and simulating a six-legged hexapod robot.
|
||||
It uses IKPy for inverse kinematics, PyBullet for optional simulation, and can send joint commands to ESP32 or Arduino hardware.
|
||||
|
||||
**Setup Dependencies and Virtual Enviroment**
|
||||
- **Python packages**: At minimum the project uses `numpy`, `pygame`, `ikpy`, `pybullet`, `pyserial`, and `matplotlib`.
|
||||
- **Install** (recommended inside a venv):
|
||||
## Requirements
|
||||
|
||||
Linux / macOS (Bash):
|
||||
- Python 3.12 recommended on Windows
|
||||
- Python 3.11 / 3.12 is safest for `pygame` compatibility
|
||||
- Required Python packages:
|
||||
- `numpy`
|
||||
- `pygame`
|
||||
- `ikpy`
|
||||
- `pybullet`
|
||||
- `pyserial`
|
||||
- `matplotlib`
|
||||
|
||||
## Setup
|
||||
|
||||
### Linux / macOS (Bash)
|
||||
|
||||
```bash
|
||||
python3 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
python -m pip install --upgrade pip setuptools wheel
|
||||
pip install numpy pygame ikpy pybullet pyserial matplotlib
|
||||
```
|
||||
|
||||
Windows (PowerShell):
|
||||
### Windows (PowerShell)
|
||||
|
||||
```powershell
|
||||
python -m venv .venv
|
||||
.\.venv\Scripts\Activate.ps1
|
||||
python -m pip install --upgrade pip setuptools wheel
|
||||
pip install numpy pygame ikpy pybullet pyserial matplotlib
|
||||
```
|
||||
|
||||
If PowerShell blocks activation, run:
|
||||
If PowerShell blocks activation:
|
||||
|
||||
```powershell
|
||||
Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned
|
||||
.\.venv\Scripts\Activate.ps1
|
||||
```
|
||||
|
||||
**Quick Start**
|
||||
- **Simulation**: enable the simulator in `config.py` by setting `sim = True`, then run:
|
||||
## Run
|
||||
|
||||
From the repository root:
|
||||
|
||||
```powershell
|
||||
python main.py
|
||||
```
|
||||
|
||||
or on Linux/macOS:
|
||||
|
||||
```bash
|
||||
python3 main.py
|
||||
```
|
||||
- **Hardware**: set `sim = False` in `config.py` and choose `arduinoConnection = True` or provide your ESP32 settings. Verify `port`, `baudrate`, `esp32_ip`, and `esp32_port` in `config.py`.
|
||||
|
||||
**Project structure (key files)**
|
||||
- **Entry point**: [main.py](main.py) — starts the controller and state loop.
|
||||
- **Controller**: [Controller.py](Controller.py) — joystick input and `ControlIntent` updates.
|
||||
- **Kinematics**: [kinematics.py](kinematics.py) — URDF-based forward/inverse kinematics using IKPy.
|
||||
- **Simulation**: [simulation.py](simulation.py) — PyBullet visualization and joint control.
|
||||
- **Hardware comms**: [EspCommunication.py](EspCommunication.py) and [ArduinoCommunication.py](ArduinoCommunication.py) — send commands to ESP32 or Arduino.
|
||||
- **Runtime globals**: [GlobalVariables.py](GlobalVariables.py) — central runtime objects and flags.
|
||||
- **Types**: [DataTypes.py](DataTypes.py) — `PosArray`, `DegArray`, `RadArray`, `ControlIntent`.
|
||||
- **States**: [RobotState/idle.py](RobotState/idle.py) and [RobotState/walking.py](RobotState/walking.py) — state machine implementations.
|
||||
- **Config**: [config.py](config.py) — ports, flags (`sim`, `arduinoConnection`), URDF path, timing values.
|
||||
## Configuration
|
||||
|
||||
**How it works**
|
||||
- `main.py` creates a `ControlIntent` and `RobotContext`, starts the controller thread, and runs a state loop. The `WalkingState` computes per-leg foot paths (Bezier/linear), converts positions to joint angles with `kinematics.ikpyInverse()`, then sends commands to hardware or updates the simulator.
|
||||
Edit `config.py` before running:
|
||||
|
||||
**Configuration notes**
|
||||
- **URDF**: the robot description file is `JackBotUrdf.urdf`; ensure the path in `config.py` (`urdf_path`) is correct.
|
||||
- **Timing**: step timing and tick rate are configured in `config.py` (`standard_duration`, `standard_tickpersec`).
|
||||
- `sim = True` to enable PyBullet simulation
|
||||
- `sim = False` to use hardware control
|
||||
- `arduinoConnection = True` to use Arduino
|
||||
- `arduinoConnection = False` to use ESP32
|
||||
- `port` and `baudrate` for Arduino
|
||||
- `esp32_ip` and `esp32_port` for ESP32
|
||||
- `urdf_path = "JackBotUrdf.urdf"`
|
||||
|
||||
**Suggested next steps**
|
||||
- Add a `requirements.txt` or `pyproject.toml` for reproducible installs.
|
||||
- Document hardware wiring and expected serial/ESP packet formats if you plan to use hardware.
|
||||
- Provide an example `config.py` for common setups (sim vs hardware).
|
||||
## Project structure
|
||||
|
||||
**License & Contributing**
|
||||
- No license file included. Add `LICENSE` if you want to publish or share.
|
||||
- Contributions: open an issue or PR with improvements; add tests for kinematics if possible.
|
||||
- `main.py` — main application entry point
|
||||
- `Controller.py` — Pygame-based controller and input display
|
||||
- `kinematics.py` — IKPy forward/inverse kinematics
|
||||
- `simulation.py` — PyBullet simulation wrapper
|
||||
- `GlobalVariables.py` — shared runtime state and comms
|
||||
- `DataTypes.py` — typed arrays and control intent
|
||||
- `RobotState/idle.py` — idle robot state
|
||||
- `RobotState/walking.py` — walking robot state
|
||||
- `EspCommunication.py` — ESP32 communication
|
||||
- `ArduinoCommunication.py` — Arduino communication
|
||||
- `JackBotUrdf.urdf` — robot model file
|
||||
|
||||
## Notes
|
||||
|
||||
- `GlobalVariables.py` initializes either `Simulation()` or the selected hardware comm class.
|
||||
- `DataTypes.py` declares `PosArray`, `DegArray`, `RadArray`, `RobotCommand`, and `ControlIntent`.
|
||||
- `Controller.py` updates `gv.vector_dirmov` and `gv.robot_state` from joystick input.
|
||||
- `kinematics.py` loads leg chains from `JackBotUrdf.urdf` and computes IK.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- If `pygame` installation fails on Windows, use Python 3.12 and upgrade `pip setuptools wheel` first.
|
||||
- If `python` is not found on Windows, install Python and enable "Add Python to PATH".
|
||||
- If the program crashes on startup, verify `JackBotUrdf.urdf` path and `config.py` settings.
|
||||
|
||||
## Suggested improvements
|
||||
|
||||
- Add a `requirements.txt` or `pyproject.toml`.
|
||||
- Add a `LICENSE` file before sharing the project.
|
||||
- Document hardware wiring and packet formats for ESP32/Arduino.
|
||||
Reference in New Issue
Block a user