Skip to content

Add traffic light adapter template#44

Open
jixiancgh wants to merge 7 commits into
open-rmf:mainfrom
chart-sg:add_traffic_light_adapter_template
Open

Add traffic light adapter template#44
jixiancgh wants to merge 7 commits into
open-rmf:mainfrom
chart-sg:add_traffic_light_adapter_template

Conversation

@jixiancgh

Copy link
Copy Markdown

New feature implementation

Implemented feature

This PR aims to add a traffic_light_adapter_template package for medium compliance robots. It fills a gap for fleets whose robots self-navigate (the robot's own fleet manager plans and drives the path) but still need RMF for traffic deconfliction with other RMF robots.

Implementation description

fleet_adapter.py registers each robot via Adapter.add_easy_traffic_light. The adapter then polls the robot each update cycle and reports its position and movement state to RMF. RMF responds with Resume, WaitAtNextCheckpoint, or PauseImmediately, which the adapter translates into pause / resume / pause_at_checkpoint robot commands.

The main difference is in traffic_light_command_handle.py:

  • wires up the three EasyTrafficLight callbacks (traffic_light_cb, pause_cb, resume_cb),
  • reports state via moving_from() / waiting_at() / waiting_after() each cycle in update_state_locked
  • calls the robot commands at _handle_moving, _handle_waiting_at and _handle_waiting_after logics

GenAI Use

We follow OSRA's policy on GenAI tools

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

Generated-by:

Signed-off-by: Loke Ji Xian <loke_ji_xian@cgh.com.sg>
@cardboardcode

Copy link
Copy Markdown
Collaborator

Hi @jixiancgh, thank you for PR. Will take a look and review, hopefully within these 2 weeks.

@mxgrey mxgrey moved this from Inbox to In Progress in PMC Board Jun 30, 2026
@cardboardcode

Copy link
Copy Markdown
Collaborator

Hi @jixiancgh, I have started evaluating traffic_light_adapter_template.

While that is happening, in an effort for better code quality standardization, please include the following files under directory, traffic_light_adapter_template/test and .github/workflows/:

Files To Include 📚

Under directory traffic_light_adapter_template/test

Under directory .github/workflows

Note

Replace fleet_adapter_template with traffic_light_adapter_template in the files above, once included.

Instructions 📘

  1. Run local Continuous Integration (CI) using the command below to verify that traffic_light_adapter_template is passing CI before pushing the code:

Note

There are no pytests included. This CI is purely for minimal linting, to keep things simple.

act -v -j test --reuse --pull=false
  1. Address any linting violations.

Note

If there are specific linting exceptions needed, please feel free to reach out.

@jixiancgh jixiancgh force-pushed the add_traffic_light_adapter_template branch from a23ae24 to 9d2abd9 Compare July 7, 2026 02:26
jixiancgh added 2 commits July 7, 2026 10:27
Signed-off-by: Loke Ji Xian <loke_ji_xian@cgh.com.sg>
Signed-off-by: Loke Ji Xian <loke_ji_xian@cgh.com.sg>
@jixiancgh

Copy link
Copy Markdown
Author

Hi @cardboardcode , I have fixed the formatting and added tests.

@cardboardcode

cardboardcode commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Hi @jixiancgh, verified from my side that the minimal linting CI is fully passing with the changes made. ✅

See steps below to reproduce:

Steps To Reproduce 📘

git clone git@github.com:chart-sg/fleet_adapter_template.git --branch add_traffic_light_adapter_template --single-branch --depth 1 && cd fleet_adapter_template
act -v -j test --reuse --pull=false

Verify

You should see the following to know the CI is fully passing:

 ======================== 3 passed, 2 warnings in 0.64s =========================
| --- stderr: traffic_light_adapter_template
| 
| =============================== warnings summary ===============================
| test/test_flake8.py::test_flake8
| test/test_flake8.py::test_flake8
|   Warning: SelectableGroups dict interface is deprecated. Use select.
| 
| -- Docs: https://docs.pytest.org/en/stable/warnings.html
| ---
| Finished <<< traffic_light_adapter_template [1.43s]
| 
| Summary: 1 package finished [1.81s]
|   1 package had stderr output: traffic_light_adapter_template
| Summary: 3 tests, 0 errors, 0 failures, 0 skipped
[build_and_test/Minimal Linting Build (humble)-1 ]   ✅  Success - Main Run colcon tests [2.410047773s]
[build_and_test/Minimal Linting Build (humble)-1 ] [DEBUG] skipping post step for 'Checkout repository': no action model available
[build_and_test/Minimal Linting Build (humble)-1 ] ⭐ Run Complete job
[build_and_test/Minimal Linting Build (humble)-1 ] Cleaning up container for job Minimal Linting Build (humble)
[build_and_test/Minimal Linting Build (humble)-1 ] [DEBUG] Loading revision from git directory
[build_and_test/Minimal Linting Build (humble)-1 ] [DEBUG] Found revision: 3921986d9231cfd5a558cadceebb54c5e2faacaf
[build_and_test/Minimal Linting Build (humble)-1 ] [DEBUG] HEAD points to '3921986d9231cfd5a558cadceebb54c5e2faacaf'
[build_and_test/Minimal Linting Build (humble)-1 ] [DEBUG] using github ref: refs/heads/add_traffic_light_adapter_template
[build_and_test/Minimal Linting Build (humble)-1 ] [DEBUG] Found revision: 3921986d9231cfd5a558cadceebb54c5e2faacaf
[build_and_test/Minimal Linting Build (humble)-1 ]   ✅  Success - Complete job
[build_and_test/Minimal Linting Build (humble)-1 ] 🏁  Job succeeded

Managed to evaluate traffic_light_adapter_template further.

So far the implementation looks good and working as expected in its participation of traffic deconfliction with the fleet_adapter_template-based robots. ✅

See below for working proof:

SPEDUP_simple_traffic_light
  1. robot1 is moving up and down between waypoint 0_c and 0_b.
  2. robot0 dispatched to move to the right (0_b) and return to the left (0_a).
  3. robot1 as traffic_light_adapter participates by pausing robot1 at waypoint 0_c until robot0 completes patrol task.
  4. robot1 resumes moving up and down after robot0 has returned to 0_a.

Warning

Based on the inherent API design of EasyTrafficLight, fleet markers are not visualised for easy_traffic_light_adapter-based robots, as seen in the .gif animation above.

Reference(s) 📚

Follow-up Actions ⬇️

@jixiancgh Will suggest a few more minor changes before merging in.

Comment thread .github/workflows/build_minimal.yml Outdated
Comment thread traffic_light_adapter_template/traffic_light_adapter_template/RobotClientAPI.py Outdated
Comment thread traffic_light_adapter_template/package.xml Outdated
Signed-off-by: Loke Ji Xian <loke_ji_xian@cgh.com.sg>
Signed-off-by: Loke Ji Xian <loke_ji_xian@cgh.com.sg>
Signed-off-by: Loke Ji Xian <loke_ji_xian@cgh.com.sg>
Signed-off-by: Loke Ji Xian <loke_ji_xian@cgh.com.sg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants