How ani26052007/penguin-barn-training-pipeline works
1. What this repository is
- A distributed reinforcement-learning system for autonomous navigation of a Clearpath Jackal robot.
- The core architecture is an asynchronous actor–learner pipeline: many rollout workers collect trajectories in simulation, while a central trainer consumes those trajectories and updates the policy.
2. Top-level runtime boundary
- Python is the main application runtime for training, evaluation, and rollout orchestration.
- ROS/Gazebo is the simulation and robot-control boundary, packaged either inside Singularity or run natively for debugging.
- The repository is designed to run either on a single machine with multiple containers or on a cluster with a shared filesystem.
3. Training/control plane
- train.py is the central learner entrypoint.
- actor.py is the rollout worker entrypoint.
- The learner reads trajectories from a shared buffer directory, updates the model, and writes the latest policy back to that same shared location so actors can reload it.
- In cluster mode, this becomes an asynchronous pipeline where actors may lag behind the newest policy.
4. Rollout and simulation data flow
- Actors interact with gym-like environments from envs/, collect transitions, and persist episode data under local_buffer/.
- The central learner consumes these buffered rollouts, trains an RL model, and periodically publishes updated weights.
- logs/ captures per-actor and training logs, while train_ckpt_step264000.pt and local_buffer/policy_latest.pt show the system’s checkpointing pattern.
5. Environment abstraction layer
- envs/registration.py, wrappers.py, motion_control_envs.py, parameter_tuning_envs.py, jackal_gazebo_envs.py, gazebo_simulation.py, and move_base.py define the simulation-facing environment layer.
- This layer hides ROS/Gazebo specifics behind RL-friendly observations/actions, so the algorithms operate on a consistent interface even though the backend is a robot simulator.
- The environment layer is also where different task variants are exposed: static, dynamic wall, dynamic box, parameter tuning, and motion-control setups.
6. Algorithm layer
- rl_algos/ contains the learning methods: DDPG, TD3, SAC, safe TD3, model-based variants, and the Reinflow/trajectory transformer path.
- base_rl_algo.py, collector.py, net.py, and tester.py suggest a common interface for policy networks, replay/trajectory collection, and evaluation.
- The architecture experiments in configs/architecture_* map to different policy backbones: MLP, CNN, RNN/GRU, and Transformer with varying history lengths.
7. Model-based and safe-RL branches
- configs/model_based/ and rl_algos/model_based.py represent the branch where learned transition models are used for Dyna-style planning or MPC.
- configs/safe_rl/ and rl_algos/safe_td3.py represent a safety-aware branch, including Lagrangian and MPC-based variants.
- Architecturally, these are alternate training/evaluation pipelines built on top of the same environment and rollout infrastructure.
8. Experiment configuration system
- configs/ is the main experiment matrix: algorithm choice, architecture choice, history length, generalization scale, and safety/model-based settings.
- The YAML files are the primary switchboard for the system, determining which environment, policy class, rollout setup, and training regime are active.
- This makes the repository highly configuration-driven rather than code-branch-driven.
9. ROS/Gazebo integration package
- jackal_helper/ is a separate ROS package that provides launch files, world definitions, planner parameters, and a C++ collision publisher.
- launch/ files compose Gazebo, the Jackal robot, and move_base/planning components.
- configs/params/ contains navigation stack parameters such as costmaps and local planner settings, which materially affect the simulated robot behavior.
10. World generation and scenario assets
- jackal_helper/worlds/BARN/ contains many pre-generated .world scenes and corresponding .npy path files.
- scripts/generate_dynamic_BARN.py and generate_dynamic_BARN_regular_shape.py create dynamic benchmark variants.
- These assets form the scenario corpus for evaluating generalization and dynamic-obstacle robustness.
11. Deployment and containerization
- Singularityfile.def, singularity_run*.sh, and entrypoint.sh define the execution environment used to isolate ROS/Gazebo and the Python stack.
- The repo is explicitly built to support containerized rollout, which is why the README emphasizes Singularity images and shared buffers.
- executable/ contains convenience launch scripts for actor, learner, and tester roles.
12. Overall architectural shape
- At a high level, the system is: scenario assets and ROS navigation stack on one side; RL algorithm and policy training on the other; connected by a shared trajectory/policy buffer and asynchronous actor processes.
- The key architectural boundaries are: Python RL vs ROS simulation, central learner vs distributed actors, and configuration-driven experiment selection vs shared environment/runtime code.
Main entry points: configs Configs · jackal_helper Jackal helper · executable Role scripts · train.py Train
Components 19
Python runtime
Training, rollout, and evaluation processes in the main application runtime.
- Train · Central learner that consumes buffered rollouts and publishes updated policy weights.
train.py - Actor · Asynchronous worker that runs environments, collects trajectories, and writes episodes to the shared buffer.
actor.py - Algorithms · Core RL implementations and shared learning/evaluation interfaces, including DDPG, TD3, SAC, safe RL, and model-based variants.
rl_algos - Envs · Gym-like environment layer that hides ROS/Gazebo specifics behind a consistent RL interface.
envs - Local buffer · Shared rollout and policy exchange area used by actors and the learner.
local_buffer - Logs · Per-actor and training logs emitted during rollout and learning.
logs
ROS/Gazebo
Simulation, navigation stack, and robot-control boundary.
- Jackal helper · ROS package that composes Gazebo, Jackal, and navigation stack launch files plus C++ support code.
jackal_helper - Launch files · ROS launch composition for Gazebo, Jackal, and move_base/planning startup.
jackal_helper/launch - Nav params · Navigation stack parameters that materially shape simulated robot behavior.
jackal_helper/configs/params - BARN worlds · Pre-generated benchmark worlds and path files for navigation evaluation and robustness testing.
jackal_helper/worlds/BARN - World tools · Scripts that generate dynamic BARN variants and support benchmark scenario creation.
scripts
Experiment config
Configuration matrix and scenario assets that select tasks, architectures, and regimes.
- Configs · YAML switchboard for algorithm, architecture, history length, generalization scale, and safety/model-based settings.
configs - Arch configs · Architecture variants for MLP, CNN, RNN/GRU, and Transformer histories across task families.
configs/architecture_static - Dynamic configs · Task-specific configuration sets for dynamic wall and dynamic box benchmarks.
configs/architecture_dynamic_wall - Generalization · Scaling configs that vary the number of worlds used for training and evaluation.
configs/generalization - Model-based · Configuration branch for Dyna and MPC-style learning with learned dynamics.
configs/model_based - Safe RL · Safety-aware configuration branch for Lagrangian and MPC variants.
configs/safe_rl
Deployment
Containerization and role launch scripts for single-node or cluster execution.
- Container · Singularity and shell entrypoints that isolate ROS/Gazebo and Python execution.
Singularityfile.def - Role scripts · Convenience scripts for running actor, learner, tester, and cluster workflows.
executable
Connections 21
- Actor → Envs: creates · Actors instantiate task environments and collect trajectories there.
- Actor → Local buffer: writes rollouts · Episode data and trajectories are persisted to the shared buffer.
- Train → Local buffer: reads rollouts · The learner consumes buffered trajectories from shared storage.
- Train → Local buffer: publishes policy · Updated weights are written back for actors to reload.
- Train → Algorithms: trains with · Training logic is implemented by the algorithm layer.
- Algorithms → Envs: optimizes on · Algorithms operate through the common environment interface.
- Algorithms → Configs: selected by · Experiment YAMLs choose algorithm and architecture variants.
- Configs → Arch configs: includes · Architecture sweeps define policy backbones and history lengths.
- Configs → Dynamic configs: includes · Dynamic task families are configured separately from static ones.
- Configs → Generalization: includes · Generalization sweeps control world counts and scale.
- Configs → Model-based: includes · Model-based experiments use dedicated config sets.
- Configs → Safe RL: includes · Safe RL experiments use dedicated config sets.
- Envs → Jackal helper: bridges to · Environment implementations wrap the ROS/Gazebo simulation boundary.
- Jackal helper → Launch files: composes · Launch files assemble Gazebo, robot, and navigation components.
- Jackal helper → Nav params: tunes · Planner and costmap settings alter navigation behavior.
- Jackal helper → BARN worlds: runs in · Benchmark world assets define the simulation scenarios.
- World tools → BARN worlds: generates · Scenario generation scripts create dynamic BARN variants and assets.
- Container → Role scripts: packages · Containerization supports the role launch wrappers.
- Role scripts → Train: starts · Wrapper scripts launch the central learner role.
- Role scripts → Actor: starts · Wrapper scripts launch rollout workers.
- Role scripts → Logs: emits · Role executions write training and actor logs.