Domain Layer - Planning Services
controller.domain.services.planning.motion_planning_domain_service
运动规划Domain服务
MotionPlanningDomainService
MotionPlanningDomainService()
运动规划Domain服务。
职责: 1. 管理多个方案(内存) 2. 维护当前激活的方案 3. 提供方案和节点的增删改查 4. 实施业务规则
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
_plans |
List[MotionPlan]
|
方案列表。 |
_current_index |
int
|
当前激活方案的索引。 |
初始化服务。
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
22 23 24 25 | |
initialize
initialize(plans: List[MotionPlan], current_index: int)
初始化数据(从Repository加载后调用)。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
plans
|
List[MotionPlan]
|
方案列表。 |
必需 |
current_index
|
int
|
当前方案索引。 |
必需 |
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
29 30 31 32 33 34 35 36 37 | |
get_all_plans
get_all_plans() -> List[MotionPlan]
获取所有方案(用于持久化)。
返回:
| 类型 | 描述 |
|---|---|
List[MotionPlan]
|
List[MotionPlan]: 方案列表的副本。 |
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
39 40 41 42 43 44 45 | |
create_plan
create_plan(name: str) -> int
创建方案,返回索引。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
name
|
str
|
方案名称。 |
必需 |
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
int |
int
|
新创建方案的索引。 |
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
49 50 51 52 53 54 55 56 57 58 59 60 61 | |
get_plan_names
get_plan_names() -> List[str]
获取所有方案名称(用于下拉框)。
返回:
| 类型 | 描述 |
|---|---|
List[str]
|
List[str]: 方案名称列表。 |
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
63 64 65 66 67 68 69 | |
get_current_index
get_current_index() -> int
获取当前方案索引。
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
int |
int
|
当前索引。 |
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
71 72 73 74 75 76 77 | |
set_current_index
set_current_index(index: int) -> bool
切换方案。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
int
|
目标索引。 |
必需 |
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
bool |
bool
|
是否切换成功。 |
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
79 80 81 82 83 84 85 86 87 88 89 90 91 | |
delete_plan
delete_plan(index: int) -> bool
删除方案。
业务规则:至少保留一个方案。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
int
|
方案索引。 |
必需 |
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
bool |
bool
|
True=删除成功, False=删除失败(违反业务规则或索引无效)。 |
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
can_delete_plan
can_delete_plan() -> bool
检查是否可以删除方案。
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
bool |
bool
|
True=可以删除, False=不能删除(只有一个方案)。 |
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
118 119 120 121 122 123 124 | |
rename_plan
rename_plan(index: int, new_name: str) -> bool
重命名方案。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
int
|
方案索引。 |
必需 |
new_name
|
str
|
新名称。 |
必需 |
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
bool |
bool
|
是否成功。 |
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
get_current_plan
get_current_plan() -> Optional[MotionPlan]
获取当前方案。
返回:
| 类型 | 描述 |
|---|---|
Optional[MotionPlan]
|
Optional[MotionPlan]: 当前方案对象,无方案时返回 None。 |
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
141 142 143 144 145 146 147 148 149 | |
get_plan_count
get_plan_count() -> int
获取方案数量。
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
int |
int
|
方案数量。 |
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
151 152 153 154 155 156 157 | |
add_point
add_point(point_data: dict)
添加节点到当前方案。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
point_data
|
dict
|
节点数据。 |
必需 |
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
161 162 163 164 165 166 167 168 169 | |
remove_point
remove_point(index: int)
删除节点。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
int
|
节点索引。 |
必需 |
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
171 172 173 174 175 176 177 178 179 | |
move_point_up
move_point_up(index: int) -> bool
上移节点。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
int
|
节点索引。 |
必需 |
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
bool |
bool
|
是否成功。 |
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
181 182 183 184 185 186 187 188 189 190 191 | |
move_point_down
move_point_down(index: int) -> bool
下移节点。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
int
|
节点索引。 |
必需 |
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
bool |
bool
|
是否成功。 |
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
193 194 195 196 197 198 199 200 201 202 203 | |
update_point
update_point(index: int, point_data: dict)
更新节点。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
int
|
节点索引。 |
必需 |
point_data
|
dict
|
新数据。 |
必需 |
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
205 206 207 208 209 210 211 212 213 214 | |
get_all_points
get_all_points() -> List[dict]
获取当前方案的所有节点。
返回:
| 类型 | 描述 |
|---|---|
List[dict]
|
List[dict]: 节点列表的副本。 |
源代码位于: src/controller/controller/domain/services/planning/motion_planning_domain_service.py
216 217 218 219 220 221 222 223 | |