How yitinghh-bit/turtlebot3_drlnav works
Project type and purpose
• Type: A ROS2-based robotics framework combining Gazebo simulation, LiDAR/odometry data feeds, and a deep-reinforcement-learning (DRL) agent implemented in PyTorch.
• Purpose: Train, evaluate, and deploy DRL navigation agents (DQN, DDPG, TD3) for TurtleBot3 (or any LiDAR-equipped robot) in both simulated and real environments.
File structure
• Top-level packages in src/:
– turtlebot3_drl: core DRL framework
– turtlebot3_msgs: custom ROS2 messages, services, actions for DRL steps, goals, etc.
– turtlebot3_simulations: simulation support (Gazebo worlds, robot models, obstacle plugins, fake nodes).
• util/: post-processing scripts (cleaning models, plotting reward graphs, spawn/stop scripts).
• Dockerfile + spawn_goal.sh at root: containerized environment and goal-spawning helper.
• Within turtlebot3_drl: submodules common/, drl_agent/, drl_environment/, drl_gazebo/.
README for additional insights
• System_architecture.png: outlines high-level ROS2 nodes and data flows.
• Launch/training instructions: shows four parallel terminals/nodes—Gazebo launch, gazebo_goals, environment, train_agent/test_agent.
• Real-robot vs simulation: almost identical flow, but environment node switches between Gazebo and real sensors.
a. Main components
– ROS2 DDS Network (DDS as the message bus)
– Gazebo Simulator
– spawn_goal node (gazebo_goals)
– DRL Environment Node
• drl_environment (simulated)
• real_environment (real robot)
– DRL Agent Node
• train_agent/test_agent (DQN/DDPG/TD3)
• real_agent for deployment
– turtlebot3_msgs (custom message definitions)
– turtlebot3_simulations (models, worlds, plugins)
– File System for model storage & logs (model/…)
– Optional GUIs: RViz2, pyqtgraph visualizer
– Utilities (reward_graph.py, clean scripts)
– Docker Container / Host OS / GPU runtime
b. Relationships and interactions
– Gazebo publishes /scan (LaserScan) and /odom (Odometry) → picked up by drl_environment.
– drl_environment node transforms raw messages into observation vectors + computes reward via reward.py → publishes Observation & Reward to DRL agent (via topics or direct API).
– DRL agent subscribes to observations, computes next action (cmd_vel messages), and publishes Twist → drl_environment or Gazebo (real robot listens on same topic).
– Agent periodically writes model checkpoints, hyperparameter files, test/train logs to disk.
– Real deployment: real_environment listens to real /scan and /odom, publishes observations; real_agent reads from disk and publishes velocity commands.
c. Architectural patterns / design principles
– Modular ROS2 nodes communicating via publish/subscribe and services/actions.
– Separation of concerns: perception (environment node), decision-making (agent), simulation (Gazebo), data definitions (msgs).
– Plugin-based simulation: custom obstacle plugins implemented as Gazebo model plugins.
– Configurability: settings.py drives hyperparameters, environment settings, real/sim switches.
d. Key technologies / frameworks
– ROS2 (Foxy): rclpy for Python nodes, colcon build system
– Gazebo 11: world definitions, custom obstacle plugins (C++)
– PyTorch: DQN, DDPG, TD3 implementations
– Docker + NVIDIA Container Toolkit for GPU acceleration
– Python utilities: matplotlib, pandas, pyqtgraph for visualization
Elements
– Clear labels: name each node (e.g., “drl_environment (gazebo)”), each topic (/scan, /odom, /cmd_vel), services/actions (Goal.srv).
• Blue rectangles for simulation nodes
• Green rectangles for DRL framework nodes
• Grey cloud for ROS2 DDS fabric
Final advice
– Be thorough: capture every ROS2 node, every custom message/service, and the filesystem interactions.
– Don’t over-optimize: it’s better to show many small components clearly than to lump everything into a monolith.
– Use layering: group by package (turtlebot3_drl, turtlebot3_simulations, turtlebot3_msgs) or by runtime (sim vs real).
– Keep it updated: as new DRL algorithms or environments are added, insert new nodes or topics.