Skip to content

[FEATURE] Automation script template for launching different simulations #79

@yunlishao

Description

@yunlishao

Is your feature request related to a problem?
Currently, each test scenario requires users to navigate to specific directories and run individual batch files (e.g., cd tests/CoordMerge && runCoordMergeSUMO.bat). Users need a reusable template/framework that they can adapt for their own custom simulation scenarios, rather than creating batch files from scratch each time.

Describe the solution you'd like
Create an automation script template (Python-based) that users can easily customize for different simulation scenarios. The template should provide:

  • Reusable functions for common simulation tasks (launch TrafficLayer, start controllers, manage processes)
  • Example configurations showing how to adapt the template for different scenarios
  • Pre-flight validation (check executables exist, validate config.yaml, verify ports available)
  • Process lifecycle management (startup, monitoring, graceful shutdown)
  • Structured logging with timestamps
  • Clear documentation showing how to customize for user-specific needs

Example template structure:

# simulation_template.py - Users copy and modify this for their scenarios

class SimulationLauncher:
    def __init__(self, config_path):
        # Template handles: config loading, validation, process tracking
        
    def launch_traffic_layer(self):
        # Template method users can override
        
    def launch_controllers(self):
        # Template method users can customize
        
    def run(self):
        # Standard lifecycle: validate -> launch -> monitor -> cleanup

# Example customization in user's my_scenario.py:
# from simulation_template import SimulationLauncher
# class MyScenario(SimulationLauncher):
#     def launch_controllers(self):
#         # Custom controller launch logic

Describe alternatives you've considered

  • Batch file templates: Less flexible, harder to extend, Windows-only
  • Single monolithic script: Not customizable, forces users to edit shared code
  • Keep writing batch files: Works but lacks reusability and error handling

Environment (if feature is environment-specific)

  • Python version: >= 3.8 (consistent with existing realsimdev conda environment)
  • Platform: Windows (primary platform, but Python template provides better portability)

Additional context
The template should include:

  • Example scenarios showing common patterns (single vehicle, multi-vehicle, with/without Carla)
  • Utility functions for: parsing config.yaml, checking process health, capturing logs, cleanup
  • Best practices documentation for adapting template to new scenarios
  • Integration with existing tools (dispatchRealSim.py, compileCodes.bat)

This provides a middle ground between manual batch files and a full GUI - users get automation benefits while maintaining flexibility for custom scenarios. The template could also serve as the backend for the GUI feature (#78).

Deliverables:

  • simulation_template.py - Base template with reusable components
  • examples/ directory with 2-3 example scenario scripts
  • AUTOMATION_GUIDE.md - Documentation on customizing the template

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions