实现行为树执行器、任务协调和技能接口

This commit is contained in:
2026-09-20 12:18:52 +08:00
commit 492676344a
143 changed files with 13010 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
import sys
import tempfile
import unittest
from pathlib import Path
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'coordinator'))
from robot_bt_coordinator.service import Coordinator
from robot_bt_coordinator.backends import ManualBackend
from robot_bt_coordinator.replay import replay_events
class ReplayTest(unittest.TestCase):
def test_real_canceled_task_replays_without_transport(self):
with tempfile.TemporaryDirectory() as tmp:
c=Coordinator(str(Path(tmp)/'db'),ManualBackend(),{'robot_01'})
try:
tid=c.submit(dict(client_request_id='replay',robot_id='robot_01',instruction='取水'))['task_id']
c.control(tid,'cancel');events=c.events(tid)
out=replay_events(events)
self.assertEqual(out['status'],'CANCELED');self.assertFalse(out['connects_to_robot'])
finally:c.close()
def test_missing_status_event_detected(self):
with self.assertRaises(ValueError):replay_events([dict(event_id=10,kind='state',status_version=3,status='EXECUTING')])
def test_success_without_commit_is_not_replayed_as_success(self):
with self.assertRaises(ValueError):replay_events([dict(event_id=1,kind='state',status_version=1,status='SUCCEEDED')])