Skip to content

Conversation

@yunlishao
Copy link
Contributor

@yunlishao yunlishao commented Oct 17, 2025

Summary

Migrated TrafficLayer from the deprecated plain TraCI API to modern libtraci/libsumo libraries. Added automated build scripts for SUMO library management and improved runtime DLL discovery.

Related Issues / Tasks

Closes #55
Closes #56

Type of Change

  • New feature
  • Maintenance / Refactor

Affected Modules / Components

  • CommonLib/TrafficHelper.cpp - Updated to use libsumo/libtraci namespaces
  • CommonLib/ConfigHelper.cpp - Added SUMO config path resolution
  • TrafficLayer/mainTrafficLayer.cpp - Added DLL discovery and error handling
  • CommonLib/libsumo/ - Updated to SUMO 1.22.0
  • Build system - Added PowerShell build scripts for libsumo

Key Changes

  1. Library Migration

    • Removed deprecated TraCI implementation
    • Added compile-time switch between libsumo (in-process) and libtraci (TCP/IP)
    • Updated all SUMO API calls to use new library interfaces
  2. Build Infrastructure

    • Created build_libsumo.ps1 for automated SUMO library compilation
    • Added delay-load DLL configuration for flexible runtime linking
    • Implemented automatic DLL discovery from multiple search paths
  3. Configuration Improvements

    • Added SumoSetup section in YAML config for auto-launch settings
    • Resolve SUMO config file paths relative to YAML config directory
    • Added EnableAutoLaunch option for automated SUMO startup
  4. Developer Experience

    • Updated DEVELOPER_GUIDE.md with dependency management instructions
    • Reorganized SUMO DLLs to CommonLib/libsumo/bin/
    • Added Python test client for integration testing
    • Improved error messages and logging

Test Cases

  • Tested with tests/Python/SimpleEchoClient/ configuration
  • Verified SUMO 1.22.0 compatibility
  • Tested DLL discovery from multiple locations
  • Validated config file path resolution
  • External process launch (sumo-gui) verified working

Environment

  • Python version: 3.x (test client)
  • SUMO version: 1.22.0
  • Compiler: MSVC (Windows), GCC (Linux)

Checklist

  • Code compiles/runs as expected
  • Tests pass locally
  • Documentation is updated (DEVELOPER_GUIDE.md)
  • Relevant issues are linked
  • Version-specific changes are noted (SUMO 1.22.0)

Additional Notes

Known Limitations:

  • Direct SUMO startup via libsumo (in-process mode) is not yet functional and requires further investigation. Tracked in issue [FEATURE] Enable direct SUMO startup via libsumo #70.
  • Auto-launch currently works reliably with external process launch (non-ENABLE_LIBSUMO mode)

Breaking Changes:

  • Configuration files must now include SumoSetup section for auto-launch
  • Relative paths in config are now resolved relative to config file location, not working directory

Migration Path:
Existing users can continue using manual SUMO startup by setting EnableAutoLaunch: false in the configuration file.

- Replace TraCIAPI client with libtraci static API
- Update all traci method calls to use libtraci namespace
- Use libtraci::Simulation::init() for connection instead of traci.connect()
- Update Vehicle, Lane, Edge, TrafficLight, POI, and other domain APIs
- Remove commented-out TraCIAPI includes
- Remove traci/socket.cpp, traci/storage.cpp, traci/TraCIAPI.cpp
- Remove traci header files (socket.h, storage.h, TraCIAPI.h, TraCIConstants.h, TraCIDefs.h)
- Update include directories from traci to libsumo
- Update library directories from traci to libsumo
- Delete CommonLib/traci folder with old TraCIAPI implementation
- Remove traci include directory from VirCarlaEnv.vcxproj
- All projects now use libtraci/libsumo instead of plain TraCI
- Add dependencies.yaml to track external simulator versions
- Create update_libsumo.ps1 script to sync libsumo files, DLLs, and import libraries from SUMO releases
- Update all libsumo source files from SUMO v1.22.0
- Update TrafficLayer.vcxproj to use libtracicpp.lib import library
- Add fallback logic in post-build events to use release DLLs when debug DLLs are unavailable
Add section documenting dependencies.yaml and update_libsumo.ps1 script for managing external dependency versions
Add try-catch block around libtraci::Simulation::init() to provide
clearer diagnostics when connection fails. This helps identify
connection issues with the SUMO server (wrong IP, port, or server
not running).
…tion

- Move getConfig() before connectionSetup() to populate VehicleMessageField_set early
- Only retrieve speed limits if speedLimit or speedLimitNext is defined in VehicleMessageField
- Add comments explaining the optimization logic
- Preserves vehClassList retrieval as it's needed regardless of speed limit configuration
- Rename build_sumo_debug_dlls.ps1 to build_libsumo.ps1
- Update script to build both Release and Debug configurations
- Add header file copying from SUMO source (libsumo.h,1 libtraci.h)
- Remove 60+ unnecessary libsumo source files (.cpp, .h)
- Keep only essential files: DLLs, .lib files, and 2 required headers
- Update TrafficLayer.vcxproj include paths

This reduces CommonLib/libsumo from 69MB to 68MB and keeps only what's needed for compilation.
…e update script

- Keep SUMO and SUMOLibraries clones in tmp/ for faster future builds
- Only clean up CMake build artifacts, not source repositories
- Remove update_libsumo.ps1 (functionality now in build_libsumo.ps1)
- Update user messages to reflect new caching behavior
- Debug builds (Win32/x64): Link against libsumocppD.lib and libtracicppD.lib
- Release builds (Win32/x64): Link against libsumocpp.lib and libtracicpp.lib
- Add new libsumo header files to repository
Added new SumoSetup configuration fields:
- EnableAutoLaunch: Toggle automatic SUMO startup
- SumoConfigFile: Path to .sumocfg file
- NumClients: Support for multiple TraCI clients

Implementation includes two launch options:
- Option A (commented): Direct libsumo integration (headless)
- Option B (active): External sumo-gui process with cross-platform support

Updated batch script to automatically detect EnableAutoLaunch setting
and skip manual SUMO launch when enabled.

Platform support: Windows (start /B) and Linux (background &)
Changed log file operations from binary mode to text mode with explicit
UTF-8 encoding to prevent garbled output on Windows systems where default
encoding may vary.
- Remove debug print statements from TrafficHelper and mainTrafficLayer
- Add EnableExternalDynamics flag to config
- Add configurable verbose logging to SimpleEchoClient
- Reduce console output by printing basic info every 100 steps
Changes:
- build_libsumo.ps1: Copy xerces-c, zlib, proj DLLs to CommonLib/libsumo
- TrafficLayer.vcxproj: Post-build events copy runtime DLLs from CommonLib/libsumo
- TrafficHelper: Fix compile-time macro checks (#if -> #ifdef)
- TrafficHelper: Replace std::this_thread with platform-specific Sleep

This ensures all SUMO runtime dependencies are available when running TrafficLayer,
resolving "xerces-c_3_3D.dll was not found" errors without requiring PATH setup.
…tory

- build_libsumo.ps1: Clean up old CommonLib/libsumo before copying
- build_libsumo.ps1: Copy only .lib files to root, all DLLs to bin/
- Eliminates duplicate DLLs (libsumocpp, libtracicpp)
- Structure: bin/ contains all runtime DLLs, root contains .lib and .h files
- Update linker paths in vcxproj to point to CommonLib/libsumo/bin
- Remove post-build DLL copy events (no longer needed)
- Add runtime library path discovery in mainTrafficLayer
- Support RuntimeLibraryPath configuration override
- Update documentation with new path conventions
- Switch to libtraci by default (disable ENABLE_LIBSUMO)
- Configure delay-load for libtraci and libsumo DLLs in both Debug and Release
- Add build configuration display (DEBUG/RELEASE) to version banner
- Update test script to use Release build
- Add filesystem path resolution in ConfigHelper
- Convert relative SumoConfigFile paths to absolute paths based on config file location
- Add error message pause in TrafficHelper for debugging
- Improve exception handling output in mainTrafficLayer
- Replace outdated update_libsumo.ps1 documentation with build_libsumo.ps1
- Add detailed usage examples and requirements for build script
- Document SumoSetup configuration section with auto-launch options
- Add example configuration for SUMO auto-launch
@yunlishao yunlishao changed the title Migrate from TraCI to libtraci/libsumo #55/migrate to libtraci libsumo Oct 17, 2025
@yunlishao yunlishao changed the title #55/migrate to libtraci libsumo #55 #56/migrate to libtraci libsumo Oct 17, 2025
@yunlishao yunlishao requested a review from cjffly October 17, 2025 03:35
@yunlishao yunlishao merged commit e87f3b7 into main Oct 17, 2025
@yunlishao yunlishao deleted the feature/#55_use_libtraci_libsumo branch October 17, 2025 17:01
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.

[MAINTENANCE] Need an automated way to sync libsumo and their dlls [FEATURE] Remove plain Traci from TrafficLayer.exe

3 participants