Motion Planning ViewModel
controller.presentation.view_models.motion_planning_view_model
运动规划ViewModel
MotionPlanningViewModel
MotionPlanningViewModel(app_service: MotionPlanningApplicationService, dynamics_vm: DynamicsViewModel)
Bases: QObject
运动规划 ViewModel。
职责: 1. 转发 UI 命令到 Application Service 2. 转发 Application Service 信号到 UI 组件 3. 通过 DynamicsViewModel 获取示教记录(避免重复注入)
设计原则: - ViewModel 只依赖 Application Service,不直接访问 Domain 或 Infrastructure - 所有业务逻辑在 Application Service 中封装
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
plan_list_changed |
pyqtSignal
|
方案列表变更信号。 |
current_plan_changed |
pyqtSignal
|
当前方案变更信号,携带索引。 |
point_list_changed |
pyqtSignal
|
节点列表变更信号。 |
current_position_received |
pyqtSignal
|
当前位置数据信号,携带角度列表(弧度)。 |
trajectory_preview_signal |
pyqtSignal
|
轨迹预览信号,携带 (轨迹数据, 上下文)。 |
app_service |
MotionPlanningApplicationService
|
运动规划应用服务。 |
dynamics_vm |
DynamicsViewModel
|
动力学 ViewModel。 |
初始化运动规划 ViewModel。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
app_service
|
MotionPlanningApplicationService
|
运动规划应用服务。 |
必需 |
dynamics_vm
|
DynamicsViewModel
|
动力学 ViewModel。 |
必需 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
create_plan
create_plan(name: str)
创建方案。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
name
|
str
|
方案名称。 |
必需 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
63 64 65 66 67 68 69 | |
delete_plan
delete_plan(index: int) -> bool
删除方案。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
int
|
方案索引。 |
必需 |
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
bool |
bool
|
True=删除成功, False=删除失败(违反业务规则)。 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
71 72 73 74 75 76 77 78 79 80 | |
switch_plan
switch_plan(index: int)
切换方案。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
int
|
方案索引。 |
必需 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
82 83 84 85 86 87 88 | |
rename_plan
rename_plan(index: int, new_name: str)
重命名方案。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
int
|
方案索引。 |
必需 |
new_name
|
str
|
新名称。 |
必需 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
90 91 92 93 94 95 96 97 | |
get_plan_names
get_plan_names() -> List[str]
获取所有方案名称。
返回:
| 类型 | 描述 |
|---|---|
List[str]
|
List[str]: 方案名称列表。 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
99 100 101 102 103 104 105 | |
get_current_plan_index
get_current_plan_index() -> int
获取当前方案索引。
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
int |
int
|
当前索引。 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
107 108 109 110 111 112 113 | |
get_plan_count
get_plan_count() -> int
获取方案数量。
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
int |
int
|
方案数量。 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
115 116 117 118 119 120 121 | |
add_point
add_point(point_data: dict)
添加节点。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
point_data
|
dict
|
节点数据。 |
必需 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
125 126 127 128 129 130 131 | |
delete_point
delete_point(index: int)
删除节点。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
int
|
节点索引。 |
必需 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
133 134 135 136 137 138 139 | |
move_point_up
move_point_up(index: int)
上移节点。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
int
|
节点索引。 |
必需 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
141 142 143 144 145 146 147 | |
move_point_down
move_point_down(index: int)
下移节点。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
int
|
节点索引。 |
必需 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
149 150 151 152 153 154 155 | |
update_point
update_point(index: int, point_data: dict)
更新节点。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
int
|
节点索引。 |
必需 |
point_data
|
dict
|
节点数据。 |
必需 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
157 158 159 160 161 162 163 164 | |
get_all_points
get_all_points() -> List[dict]
获取当前方案的所有节点。
返回:
| 类型 | 描述 |
|---|---|
List[dict]
|
List[dict]: 节点列表。 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
166 167 168 169 170 171 172 | |
get_single_point
get_single_point(index: int) -> dict
获取单个节点数据。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
int
|
节点索引。 |
必需 |
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
dict |
dict
|
节点数据。 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
174 175 176 177 178 179 180 181 182 183 | |
get_teach_record_names
get_teach_record_names() -> List[str]
获取所有示教记录名称(委托给 DynamicsViewModel)。
返回:
| 类型 | 描述 |
|---|---|
List[str]
|
List[str]: 记录名称列表。 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
187 188 189 190 191 192 193 | |
get_teach_record
get_teach_record(name: str) -> List[List[float]]
获取指定示教记录的数据(委托给 DynamicsViewModel)。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
name
|
str
|
记录名称。 |
必需 |
返回:
| 类型 | 描述 |
|---|---|
List[List[float]]
|
List[List[float]]: 记录数据。 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
195 196 197 198 199 200 201 202 203 204 205 | |
execute_single_point
execute_single_point(index: int)
执行单个节点。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
int
|
节点索引。 |
必需 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
209 210 211 212 213 214 215 | |
execute_motion_plan
execute_motion_plan()
执行整个运动规划方案。
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
217 218 219 | |
request_current_position
request_current_position()
请求获取当前位置(仅用于UI显示)。
委托给 Application Service 处理。
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
223 224 225 226 227 228 | |
save_node_trajectory
save_node_trajectory(node_index: int) -> bool
保存单个节点的轨迹。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
node_index
|
int
|
节点索引。 |
必需 |
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
bool |
bool
|
True=准备成功, False=准备失败。 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
232 233 234 235 236 237 238 239 240 241 | |
save_plan_trajectory
save_plan_trajectory() -> bool
保存整个方案的轨迹。
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
bool |
bool
|
True=准备成功, False=准备失败。 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
243 244 245 246 247 248 249 | |
preview_node_trajectory
preview_node_trajectory(node_index: int) -> bool
预览单个节点的轨迹曲线。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
node_index
|
int
|
节点索引。 |
必需 |
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
bool |
bool
|
True=准备成功, False=准备失败。 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
253 254 255 256 257 258 259 260 261 262 | |
preview_plan_trajectory
preview_plan_trajectory() -> bool
预览整个方案的轨迹曲线。
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
bool |
bool
|
True=准备成功, False=准备失败。 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
264 265 266 267 268 269 270 | |
load_local_trajectory
load_local_trajectory(file_path: str) -> bool
从 plans 目录加载轨迹文件。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
file_path
|
str
|
轨迹文件的完整路径或文件名。 |
必需 |
返回:
| 名称 | 类型 | 描述 |
|---|---|---|
bool |
bool
|
True=加载成功, False=加载失败。 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
274 275 276 277 278 279 280 281 282 283 | |
get_local_trajectory_files
get_local_trajectory_files() -> List[str]
获取所有可用的本地轨迹文件。
返回:
| 类型 | 描述 |
|---|---|
List[str]
|
List[str]: 文件名列表(不带扩展名)。 |
源代码位于: src/controller/controller/presentation/view_models/motion_planning_view_model.py
285 286 287 288 289 290 291 | |