跳转至

Domain Layer - Entities

controller.domain.entities.motion_plan

运动规划方案实体

MotionPlan dataclass

MotionPlan(name: str, points: List[dict] = list())

运动规划方案实体。

属性:

名称 类型 描述
name str

方案名称。

points List[dict]

节点列表。

add_point

add_point(point_data: dict)

添加节点。

参数:

名称 类型 描述 默认
point_data dict

节点数据。

必需
源代码位于: src/controller/controller/domain/entities/motion_plan.py
20
21
22
23
24
25
26
def add_point(self, point_data: dict):
    """添加节点。

    Args:
        point_data (dict): 节点数据。
    """
    self.points.append(point_data)

remove_point

remove_point(index: int)

删除节点。

参数:

名称 类型 描述 默认
index int

节点索引。

必需
源代码位于: src/controller/controller/domain/entities/motion_plan.py
28
29
30
31
32
33
34
35
def remove_point(self, index: int):
    """删除节点。

    Args:
        index (int): 节点索引。
    """
    if 0 <= index < len(self.points):
        self.points.pop(index)

move_point_up

move_point_up(index: int) -> bool

上移节点。

参数:

名称 类型 描述 默认
index int

节点索引。

必需

返回:

名称 类型 描述
bool bool

是否成功移动。

源代码位于: src/controller/controller/domain/entities/motion_plan.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def move_point_up(self, index: int) -> bool:
    """上移节点。

    Args:
        index (int): 节点索引。

    Returns:
        bool: 是否成功移动。
    """
    if index > 0:
        self.points[index], self.points[index-1] = \
            self.points[index-1], self.points[index]
        return True
    return False

move_point_down

move_point_down(index: int) -> bool

下移节点。

参数:

名称 类型 描述 默认
index int

节点索引。

必需

返回:

名称 类型 描述
bool bool

是否成功移动。

源代码位于: src/controller/controller/domain/entities/motion_plan.py
52
53
54
55
56
57
58
59
60
61
62
63
64
65
def move_point_down(self, index: int) -> bool:
    """下移节点。

    Args:
        index (int): 节点索引。

    Returns:
        bool: 是否成功移动。
    """
    if index < len(self.points) - 1:
        self.points[index], self.points[index+1] = \
            self.points[index+1], self.points[index]
        return True
    return False

update_point

update_point(index: int, point_data: dict)

更新节点。

参数:

名称 类型 描述 默认
index int

节点索引。

必需
point_data dict

新的节点数据。

必需
源代码位于: src/controller/controller/domain/entities/motion_plan.py
67
68
69
70
71
72
73
74
75
def update_point(self, index: int, point_data: dict):
    """更新节点。

    Args:
        index (int): 节点索引。
        point_data (dict): 新的节点数据。
    """
    if 0 <= index < len(self.points):
        self.points[index] = point_data