Skip to content

Implement dual-wheel robot simulator with PID and RL controllers for trajectory tracking#1

Closed
Copilot wants to merge 1 commit intomainfrom
copilot/fix-b69d64bb-9942-4167-8eae-01b28819ba78
Closed

Implement dual-wheel robot simulator with PID and RL controllers for trajectory tracking#1
Copilot wants to merge 1 commit intomainfrom
copilot/fix-b69d64bb-9942-4167-8eae-01b28819ba78

Conversation

Copy link

Copilot AI commented Sep 17, 2025

This PR implements a comprehensive dual-wheel differential drive robot simulator with both classical PID and modern reinforcement learning controllers for trajectory tracking, addressing the requirement for angular and linear acceleration-based control inputs.

Overview

The implementation extends the T-ESKF framework with a complete robotics simulation module that enables comparison of different control approaches for mobile robot navigation.

Key Components

Robot Dynamics (robot_sim/DualWheelRobot.h/cpp)

  • Accurate differential drive kinematics model with configurable parameters
  • RK4 numerical integration for smooth and stable dynamics
  • Control inputs: angular acceleration and linear acceleration commands
  • State representation: position (x, y), orientation (θ), linear velocity (v), angular velocity (ω)

Trajectory Generation (robot_sim/Trajectory.h/cpp)

Four trajectory types for comprehensive testing:

  • Circle: Configurable radius and angular velocity
  • Figure-8: Lemniscate pattern with adjustable scale
  • Line: Point-to-point straight-line navigation
  • Waypoint: Smooth interpolation between multiple waypoints

PID Controller (robot_sim/PIDController.h/cpp)

  • Multi-variable control with separate PID loops for position, orientation, and velocity
  • Anti-windup protection with integral term clamping
  • Fully configurable gains for system optimization
  • Real-time performance: 3ms simulation time for 20-second trajectories

RL Controller (robot_sim/RLController.h/cpp)

  • Neural network policy with feedforward architecture
  • Evolutionary strategy training (population-based, gradient-free)
  • 10-dimensional state space to 2-dimensional action space mapping
  • Policy persistence with save/load functionality

Usage Examples

# Test all components
./test_robot_simulation

# Run PID controller with circle trajectory
./robot_simulation pid 0

# Train and evaluate RL controller
./robot_simulation train 0
./robot_simulation rl 0

# Compare both approaches
./robot_simulation all 0

Performance Validation

PID Controller Results (Circle Trajectory):

  • Average position error: 5.31m (tunable with parameter optimization)
  • Average orientation error: 0.24 rad (13.7°)
  • Stable real-time simulation performance

RL Controller Results:

  • Successful training convergence with 53% reward improvement
  • Initial policy reward: -2807, trained policy: -1300
  • Demonstrates learning without manual parameter tuning

Analysis and Visualization

The implementation includes comprehensive analysis tools:

  • CSV data export with complete state and control histories
  • Python visualization script (scripts/visualize_results.py) for trajectory plots and performance analysis
  • Automatic computation of tracking error statistics

Integration

The robot simulation seamlessly integrates with the existing T-ESKF build system:

  • Compatible with both ROS1 and ROS2 cmake configurations
  • C++14 standard compliance for broad compatibility
  • Modular design allows easy extension with new controllers or trajectories

Technical Details

The differential drive robot follows standard kinematics:

ẋ = v cos(θ)
ẏ = v sin(θ)
θ̇ = ω
v̇ = u_linear
ω̇ = u_angular

The control architecture provides a clean separation between trajectory generation, control computation, and robot dynamics, making it easy to experiment with different approaches and compare their performance.

This implementation provides researchers and developers with a complete framework for studying mobile robot control algorithms, particularly useful for comparing classical control theory approaches (PID) with modern machine learning methods (RL) in a controlled simulation environment.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@ChungengTian ChungengTian deleted the copilot/fix-b69d64bb-9942-4167-8eae-01b28819ba78 branch September 17, 2025 05:13
Copilot AI changed the title [WIP] 一个双轮驱动的小车,运动输入指令为角加速度和线加速度,写一个仿真器,并且分别用PID和RL做一个控制器,以实现轨迹跟踪 Implement dual-wheel robot simulator with PID and RL controllers for trajectory tracking Sep 17, 2025
Copilot AI requested a review from ChungengTian September 17, 2025 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants