Readme seperated into Sub-Readme's
This commit is contained in:
+105
@@ -0,0 +1,105 @@
|
||||
# JackBot Machine Learning
|
||||
|
||||
This folder contains the Gymnasium/PyBullet environment and the scripts for
|
||||
behavioral-cloning pretraining, PPO training, and policy evaluation. For the
|
||||
robot's manual-control application, simulator setup, and project overview, see the
|
||||
[main README](../README.md).
|
||||
|
||||
## Setup
|
||||
|
||||
Install the project's Python dependencies from the repository root, following the
|
||||
[main setup instructions](../README.md#installation--setup):
|
||||
|
||||
```bash
|
||||
python -m pip install -r requirements.txt
|
||||
```
|
||||
|
||||
Run the commands below from the repository root. The environment loads the robot
|
||||
model and runs a PyBullet simulation; `--gui` opens the PyBullet window where that
|
||||
option is available.
|
||||
|
||||
## Workflows
|
||||
|
||||
### Behavioral-cloning pretraining
|
||||
|
||||
`pretrain_bc.py` collects observation/action examples from the kinematics controller
|
||||
and trains an initial PPO policy to imitate those actions:
|
||||
|
||||
```bash
|
||||
python ml/pretrain_bc.py --num-samples 100000 --epochs 15 \
|
||||
--save-path ml/checkpoints/jackbot_kinematics_base.zip
|
||||
```
|
||||
|
||||
Use `--gui` to visualize data collection. Defaults are 100,000 samples, 15 epochs,
|
||||
and the checkpoint path shown above.
|
||||
|
||||
### PPO training
|
||||
|
||||
`run_train.py` trains a PPO policy in parallel environments and saves checkpoints:
|
||||
|
||||
```bash
|
||||
python ml/run_train.py --total-timesteps 1500000
|
||||
```
|
||||
|
||||
Useful options include `--num-workers`, `--save-freq`, `--log-dir`, `--save-dir`,
|
||||
`--pretrained-model`, and `--gui`. By default, the script uses 16 workers, saves
|
||||
checkpoints under `ml/checkpoints/`, and writes TensorBoard logs under `ml/logs/`.
|
||||
To continue from a pretraining or previous checkpoint, pass its `.zip` path with
|
||||
`--pretrained-model`.
|
||||
|
||||
### Policy evaluation
|
||||
|
||||
`run_eval.py` runs deterministic episodes for fixed movement commands and reports
|
||||
mean reward, steps survived, and maximum distance for each phase:
|
||||
|
||||
```bash
|
||||
python ml/run_eval.py \
|
||||
--model ml/checkpoints/jackbot_kinematics_base.zip \
|
||||
--episodes-per-phase 5
|
||||
```
|
||||
|
||||
The model path is required. Other options include `--max-steps-per-episode`,
|
||||
`--gui`, and `--save-metrics path/to/report.json`.
|
||||
|
||||
### Kinematics benchmark
|
||||
|
||||
`run_eval_training.py` benchmarks the kinematics controller against fixed commands
|
||||
and prints reward-component averages and movement metrics. It currently has no
|
||||
command-line options and enables the PyBullet GUI:
|
||||
|
||||
```bash
|
||||
python ml/run_eval_training.py
|
||||
```
|
||||
|
||||
## Environment and training concepts
|
||||
|
||||
[`env.py`](env.py) defines `JackBotEnv`. Each observation contains 18 joint angles
|
||||
and a three-value movement command `[vx, vy, omega]`; the policy outputs 18
|
||||
normalized joint actions. The environment can use direct policy actions or the
|
||||
kinematics controller, and provides reward and robot metrics to the training and
|
||||
evaluation scripts.
|
||||
|
||||
The reward is shaped to encourage survival, body height and stability, following
|
||||
the requested linear and angular motion, smooth actions, and a stable stance when
|
||||
the command is zero. It also discourages unintended movement while standing and
|
||||
remaining still when movement is requested. Negative reward contributions are
|
||||
not the same as episode termination: an episode ends on a failure condition (such
|
||||
as excessive tilt or a collapsed body) or when the configured step limit is
|
||||
reached.
|
||||
|
||||
The curriculum in `env.py` progresses through these command stages:
|
||||
|
||||
1. `STAND_ONLY`
|
||||
2. `FORWARD`
|
||||
3. `TURN_AND_DIRECTION`
|
||||
4. `OMNI_DIRECTION`
|
||||
5. `FULL_COMMAND`
|
||||
|
||||
`callbacks.py` contains reward logging and curriculum callbacks. `MetricsOverlay.py`
|
||||
displays simulation metrics when the GUI is in use.
|
||||
|
||||
## Outputs
|
||||
|
||||
Training checkpoints are written to `ml/checkpoints/` and TensorBoard logs and
|
||||
evaluation results to `ml/logs/` by default. These directories can also contain
|
||||
large generated artifacts; keep or remove them according to your experiment needs.
|
||||
Reference in New Issue
Block a user