Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

AWS DeepRacer Advanced Reward Function

An optimised reward function for AWS DeepRacer that implements multiple racing strategies including racing line optimisation, dynamic speed adjustment, and safety controls. This implementation helps create more consistent and competitive autonomous racing models.

🚗 Features

  • Racing Line Optimisation: Rewards the agent for following an optimal racing path
  • Dynamic Speed Control: Automatically adjusts target speed based on track curvature
  • Safety Management: Implements lateral acceleration limits and track boundary awareness
  • Predictive Steering: Looks ahead multiple waypoints to anticipate turns
  • Lap Time Optimisation: Rewards efficient lap completion
  • Comprehensive Error Handling: Robust validation of input parameters

🎮 Adjustable Parameters

Speed Settings

MAX_SPEED = 4.0        # (m/s) Maximum speed on straight sections
TURN_SPEED = 2.0       # (m/s) Target speed during turns

Steering Settings

MAX_STEERING_ANGLE = 30.0  # (degrees) Maximum steering angle
MAX_LATERAL_ACC = 3.0      # (m/s^2) Maximum lateral acceleration

Safety Settings

SAFETY_FACTOR = 0.8    # (0.0 to 1.0) Higher values = stay closer to center
CAR_LENGTH = 2.5       # (meters) Length of the car model

Track Navigation

FUTURE_STEP = 5        # Number of waypoints to look ahead
TURN_THRESHOLD = 0.1   # Minimum curvature to identify as turn

Lap Optimisation

EXPECTED_STEPS = 300   # Baseline number of steps for optimal lap

🛠 Installation

  1. Log in to your AWS DeepRacer console
  2. Navigate to the "Model" section
  3. Create a new model or select an existing one
  4. In the reward function section, copy and paste the contents of reward_function.py
  5. Adjust the parameters according to your track and racing style

📊 Reward Function Components

The final reward is calculated by combining multiple factors:

  1. Distance Reward: Based on the car's proximity to the optimal racing line
  2. Lateral Acceleration Reward: Encourages smooth steering and stable cornering
  3. Speed Reward: Rewards maintaining appropriate speed for track conditions
  4. Safety Reward: Ensures the car stays within safe track boundaries
  5. Lap Time Reward: Bonus for completing laps efficiently

🔧 Tuning Guide

For Faster Lap Times

  • Increase MAX_SPEED
  • Decrease SAFETY_FACTOR
  • Increase TURN_SPEED
  • Adjust TURN_THRESHOLD

For More Stable Racing

  • Decrease MAX_LATERAL_ACC
  • Increase SAFETY_FACTOR
  • Decrease TURN_SPEED
  • Increase FUTURE_STEP

For Different Track Types

Technical Tracks

  • Lower speeds
  • Higher SAFETY_FACTOR
  • Increase FUTURE_STEP

High-Speed Tracks

  • Increase MAX_SPEED
  • Lower SAFETY_FACTOR
  • Decrease FUTURE_STEP

📈 Performance Tips

  1. Start with conservative values and gradually increase them
  2. Test thoroughly after each parameter adjustment
  3. Monitor the completion rate alongside lap times
  4. Consider track width when setting safety parameters
  5. Adjust EXPECTED_STEPS based on your track length

🤝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Note: This reward function is provided as-is and may require adjustments based on your specific track and racing conditions.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages