Skip to content

Example traffic app#181

Draft
xiyuoh wants to merge 4 commits intomainfrom
xiyu/example_app
Draft

Example traffic app#181
xiyuoh wants to merge 4 commits intomainfrom
xiyu/example_app

Conversation

@xiyuoh
Copy link
Member

@xiyuoh xiyuoh commented Mar 13, 2026

New feature implementation

sample.mp4

Added a traffic app to our existing pool of Crossflow examples. The app allows users to interact with a simple traffic simulator via Crossflow diagrams. Users can modify their diagrams, make different node connections and observe how the vehicle behavior changes accordingly. This is meant to be a resource to help new Crossflow integrators to understand how they can make use of the library and diagram editor tool better.

The app is currently still very rudimentary and does not showcase all the operations Crossflow has to offer. Some operations like Spread and Collect are also relatively new and not available on the diagram editor yet. In the example JSONs I tried to include as many operations that make sense, and will be looking to add on further in the coming weeks.

Opening this draft PR first to make it available for testing and to gather some feedback.

GenAI Use

We follow OSRA's policy on GenAI tools

  • I used a GenAI tool in this PR.
  • I did not use GenAI

Used Gemini 3.0 to generate simple buttons to toggle traffic signal

Try it out!

From crossflow/examples/diagram/traffic_app/, run:

cargo run -- serve

You should (1) see a Bevy traffic simulator window, and (2) open the Diagram Editor on http://localhost:3000. You may choose to load any of the existing sample JSONs from traffic_app/diagrams/, or create your own diagram from scratch.

With a diagram ready on the editor,

  • Click on the Run Workflow button on the editor
  • Input a desired distance (e.g. 300) for the vehicle
  • Click Run

You should see the vehicle start to move forward on the road. Depending on which diagram/workflow you're using, it will react differently to its surrounding environment, e.g. respond to traffic signals, avoid pedestrians (tiny squares moving horizontally), or both! Feel free to use the user panel in the app to toggle some settings.

TODO

  • Documentation
  • Cleanup/add example JSONs
  • Add integration for "approach intersection" similar to handbook
  • Add SpeedLimit integration + create a node that processes Join operation for TrafficState
  • Improve lane change logic
  • Explore how else to incorporate other Crossflow operations
  • Address some TODOs sprinkled across the code
  • Move some toggle-able settings in the simulator into the ops catalog

Signed-off-by: Xiyu Oh <xiyu@openrobotics.org>
@xiyuoh
Copy link
Member Author

xiyuoh commented Mar 13, 2026

I also had to modify basic_executor a little to accommodate launching a Bevy app alongside the diagram editor - we were doing app.run() from a separate thread in serve() before, and Bevy isn't happy about that when rendering the app, it needs to be done on the main thread. I flipped it around and tried running the app on the main thread, while doing axum::serve() in a thread instead.

xiyuoh added 2 commits March 13, 2026 16:59
Signed-off-by: Xiyu Oh <xiyu@openrobotics.org>
Signed-off-by: Xiyu Oh <xiyu@openrobotics.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

1 participant