Skip to content

feat(nav): execute arrival actions when robot reaches a POI#111

Closed
xiaolefang-dm wants to merge 2 commits intomainfrom
xiaole/feat/poi-arrival-actions
Closed

feat(nav): execute arrival actions when robot reaches a POI#111
xiaolefang-dm wants to merge 2 commits intomainfrom
xiaole/feat/poi-arrival-actions

Conversation

@xiaolefang-dm
Copy link
Copy Markdown
Contributor

@xiaolefang-dm xiaolefang-dm commented Apr 26, 2026

What

Adds an optional actions field to POI definitions. When the robot arrives at a POI, it executes the action sequence
before advancing to the next waypoint. POIs without actions are completely unaffected.

Why

Navigation to a POI is just half the story — the robot often needs to do something meaningful when it gets there (face
a direction, take a photo, wait). Without this, every use case requires custom code. This gives a clean, declarative
way to attach behaviors to POIs without touching the nav stack.

How it works

pois.json → map_node.pois_data → arrive at POI → action_executor → advance

  1. map_node detects POI arrival (existing proximity threshold, unchanged)
  2. If the POI has actions, spawns a daemon thread running execute_poi_actions()
  3. While actions run, try_publish_nav_path holds — robot stays put
  4. After all actions complete, poi_index advances as normal

New file: tinynav/core/action_executor.py

Self-contained, no new dependencies.

Adding a new action type = one async def + one line in ACTION_REGISTRY. No changes to map_node or POI schema needed.

Example pois.json

{
     "1": {
         "id": 1,
         "name": "reception",
         "position": [3.2, 1.5, 0.0],                                                                                      
         "actions": [
           {"type": "lookat", "params": {"target": [5.0, 2.0, 0.0]}},                                                      
           {"type": "photo",  "params": {}},                                                                               
           {"type": "wait",   "params": {"seconds": 3}}
         ]                                                                                                                 
     }                                                       
 }

Backward compatibility

Fully backward compatible. Existing pois.json without actions work as before — no migration needed.

Adds an optional `actions` field to POI definitions. When the robot
arrives at a POI, map_node runs the action sequence before advancing
to the next waypoint. POIs without actions behave exactly as before.

Supported action types (tinynav/core/action_executor.py):
- lookat: rotate to face a map-frame coordinate
- wait: pause for N seconds
- photo: save latest keyframe image to disk
- custom: publish arbitrary command to /service/command

New action types can be registered in ACTION_REGISTRY without touching
map_node or the POI schema.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

cloc github.com/AlDanial/cloc v 2.04 T=0.17 s (252.5 files/s, 37183.8 lines/s)
Language files blank comment code
Python 13 613 301 3362
Markdown 4 155 6 426
C++ 4 60 38 409
Bourne Shell 15 41 9 272
Dockerfile 1 31 30 196
JSON 2 8 0 58
TOML 1 4 0 57
make 1 18 15 55
CMake 1 4 0 17
-------- -------- -------- -------- --------
SUM: 42 934 399 4852

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

cloc github.com/AlDanial/cloc v 2.04 T=0.17 s (247.0 files/s, 36361.9 lines/s)
Language files blank comment code
Python 13 613 301 3361
Markdown 4 155 6 426
C++ 4 60 38 409
Bourne Shell 15 41 9 272
Dockerfile 1 31 30 196
JSON 2 8 0 58
TOML 1 4 0 57
make 1 18 15 55
CMake 1 4 0 17
-------- -------- -------- -------- --------
SUM: 42 934 399 4851

@xiaolefang-dm xiaolefang-dm requested review from dvorak0 and junlinp and removed request for junlinp April 26, 2026 11:32
@dvorak0 dvorak0 closed this Apr 28, 2026
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.

2 participants