Skip to content

pose

AdaptedPose #

Bases: Pose

Like a Pose, but its values are automatically adapted to selected camp during initialization. So to define static positions in actions, we can use this class to set pose related to the default camp, and if the camp changes, the pose will be adapted on reset.

Source code in cogip/tools/planner/pose.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
class AdaptedPose(Pose):
    """
    Like a Pose, but its values are automatically adapted to selected camp
    during initialization.
    So to define static positions in actions, we can use this class to set pose related
    to the default camp, and if the camp changes, the pose will be adapted on reset.
    """

    _camp: ClassVar[Camp] = Camp()

    @field_validator("y")
    @classmethod
    def adapt_y(cls, v, **kwargs):
        """
        Validator to adapt Y depending on the camp at initialization.
        """
        return Camp().adapt_y(v)

    @field_validator("O")
    @classmethod
    def adapt_O(cls, v, **kwargs):
        """
        Validator to adapt the angle depending on the camp at initialization.
        """
        return Camp().adapt_angle(v)

adapt_O(v, **kwargs) classmethod #

Validator to adapt the angle depending on the camp at initialization.

Source code in cogip/tools/planner/pose.py
71
72
73
74
75
76
77
@field_validator("O")
@classmethod
def adapt_O(cls, v, **kwargs):
    """
    Validator to adapt the angle depending on the camp at initialization.
    """
    return Camp().adapt_angle(v)

adapt_y(v, **kwargs) classmethod #

Validator to adapt Y depending on the camp at initialization.

Source code in cogip/tools/planner/pose.py
63
64
65
66
67
68
69
@field_validator("y")
@classmethod
def adapt_y(cls, v, **kwargs):
    """
    Validator to adapt Y depending on the camp at initialization.
    """
    return Camp().adapt_y(v)

Pose #

Bases: PathPose

Pose class used in actions. A function can be executed before moving and an other once it is reached.

Source code in cogip/tools/planner/pose.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class Pose(PathPose):
    """
    Pose class used in actions.
    A function can be executed before moving and an other once it is reached.
    """

    before_pose_func: Callable[[socketio.ClientNamespace], Awaitable[None]] | None = None
    intermediate_pose_func: Callable[[socketio.ClientNamespace], Awaitable[None]] | None = None
    after_pose_func: Callable[[socketio.ClientNamespace], Awaitable[None]] | None = None

    @final
    async def act_before_pose(self):
        """
        Function executed before the robot starts moving.
        """
        if self.before_pose_func:
            await self.before_pose_func()

    @final
    async def act_intermediate_pose(self):
        """
        Function executed once an intermediate pose is reached.
        """
        if self.intermediate_pose_func:
            await self.intermediate_pose_func()

    @final
    async def act_after_pose(self):
        """
        Function executed once the pose is reached.
        """
        if self.after_pose_func:
            await self.after_pose_func()

    @property
    def path_pose(self) -> PathPose:
        """
        Convert the pose into its parent class.
        """
        return PathPose(**self.model_dump())

path_pose: PathPose property #

Convert the pose into its parent class.

act_after_pose() async #

Function executed once the pose is reached.

Source code in cogip/tools/planner/pose.py
37
38
39
40
41
42
43
@final
async def act_after_pose(self):
    """
    Function executed once the pose is reached.
    """
    if self.after_pose_func:
        await self.after_pose_func()

act_before_pose() async #

Function executed before the robot starts moving.

Source code in cogip/tools/planner/pose.py
21
22
23
24
25
26
27
@final
async def act_before_pose(self):
    """
    Function executed before the robot starts moving.
    """
    if self.before_pose_func:
        await self.before_pose_func()

act_intermediate_pose() async #

Function executed once an intermediate pose is reached.

Source code in cogip/tools/planner/pose.py
29
30
31
32
33
34
35
@final
async def act_intermediate_pose(self):
    """
    Function executed once an intermediate pose is reached.
    """
    if self.intermediate_pose_func:
        await self.intermediate_pose_func()