Motion Plan Repository
controller.infrastructure.persistence.motion_plan_repository
运动方案持久化仓库
MotionPlanRepository
MotionPlanRepository(file_path: str = './motion_planning_plans.json')
运动方案持久化仓库。
职责: 1. 保存/加载方案到JSON文件 2. 管理文件系统操作
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
file_path |
Path
|
方案文件路径。 |
初始化仓库。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
file_path
|
str
|
文件路径. Defaults to "./motion_planning_plans.json". |
'./motion_planning_plans.json'
|
源代码位于: src/controller/controller/infrastructure/persistence/motion_plan_repository.py
20 21 22 23 24 25 26 | |
save
save(plans_data: List[Dict], current_index: int)
保存方案数据到文件。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
plans_data
|
List[Dict]
|
方案数据列表。 |
必需 |
current_index
|
int
|
当前选中方案索引。 |
必需 |
源代码位于: src/controller/controller/infrastructure/persistence/motion_plan_repository.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
load
load() -> tuple[List[Dict], int]
从文件加载方案数据。
返回:
| 类型 | 描述 |
|---|---|
tuple[List[Dict], int]
|
tuple[List[Dict], int]: (plans_data, current_index)。 如果文件不存在或加载失败,返回默认方案。 |
源代码位于: src/controller/controller/infrastructure/persistence/motion_plan_repository.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |