matlab-cosimulate-sumo-simulink

Build Simulink models that co-simulate with Eclipse SUMO traffic simulator via TraCI.

995|122|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-cosimulate-sumo-simulink
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: matlab-cosimulate-sumo-simulink
Source: https://github.com/matlab/matlab-agentic-toolkit/tree/main/skills-catalog/automotive/matlab-cosimulate-sumo-simulink
Command: npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-cosimulate-sumo-simulink

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Connecting Simulink to the Eclipse SUMO traffic simulator involves many failure-prone details: mismatched ports, solver misconfiguration, crashes from reading vehicles that do not exist yet, and silent route-file errors. This Skill encodes the correct block configuration, wiring patterns, and workarounds so co-simulation models work on the first build.

Core Features & Use Cases

  • Server/Client Setup: Configure SumoInterfaceLibrary Server and Client blocks with matching ports, fixed-step solvers, and real-time pacing.
  • Vehicle I/O Patterns: Read vehicle states (speed, position, angle) and write controls (speed, position, spawning) with Enabled Subsystem gating to avoid crashes on delayed-spawn vehicles.
  • Traffic Generation: Create random background traffic, define ego vehicles in route files, and dynamically spawn actors with distinct routes.
  • Use Case: An ADAS engineer needs to validate a controller against realistic traffic. The Skill generates a Simulink model that launches SUMO, spawns an ego vehicle at t=0, streams surrounding vehicle positions into the controller, and writes the ego's desired speed back to SUMO each step.

Quick Start

Ask your AI agent to build a Simulink model that co-simulates with Eclipse SUMO using a grid network, random traffic, and an ego vehicle whose speed is controlled from Simulink.

Frequently Asked Questions about matlab-cosimulate-sumo-simulink

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I connect Simulink to Eclipse SUMO for co-simulation?

Add a Server block pointing to your .sumocfg file and a Client block with a matching port (default 8813) from the SumoInterfaceLibrary. Use a fixed-step solver whose step size matches the SUMO step-length, then add Reader and Writer blocks to exchange vehicle data.

How do I control an ego vehicle in SUMO from Simulink?

Define the ego vehicle in a .rou.xml route file with depart="0" so it exists from simulation start, then use a Writer block with the Vehicle/Speed topic to set its desired speed each step. Avoid <stop> clauses in the ego route since SUMO stop directives override the Speed Writer.

Why does my SUMO-Simulink simulation crash when reading vehicle data?

Vehicle-topic Reader and Writer blocks crash if the target vehicle does not exist yet in SUMO. Gate them inside Enabled Subsystems triggered by Clock >= spawnTime, or define the vehicle in the route file with depart="0".

Why does SUMO fail to launch from Simulink on Windows?

The Server block concatenates SUMO_HOME with the binary path without a separator, so a SUMO_HOME lacking a trailing backslash causes launch failure. Run setenv('SUMO_HOME', [getenv('SUMO_HOME') filesep]) before simulating.

Can I spawn vehicles at exact positions in SUMO from Simulink?

The Actor block's SpawnMethod='Position' is broken in the support package. Use the spawn-then-teleport pattern: spawn with SpawnMethod='Lane', wait one step with a Unit Delay, then move the vehicle with a Writer(Vehicle/Position) block using int32 lane index and uint8 keep-route types.

When should I not use SUMO-Simulink co-simulation?

Avoid it for pure SUMO traffic studies without Simulink control logic, where SUMO's CLI or Python TraCI is simpler. It also does not replace vehicle dynamics modeling, which requires Vehicle Dynamics Blockset, or scenario design in Driving Scenario Designer.