Bases: Action
Example action that generate its poses depending of the robot's pose
at the beginning of the action.
The robot will go from the current position to its opposite position in loop.
Source code in cogip/tools/planner/actions/back_and_forth.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 | class BackAndForthAction(Action):
"""
Example action that generate its poses depending of the robot's pose
at the beginning of the action.
The robot will go from the current position to its opposite position in loop.
"""
def __init__(self, planner: "Planner", actions: Actions):
super().__init__("BackAnForth action", planner, actions)
self.before_action_func = self.compute_poses
async def compute_poses(self) -> None:
x = self.planner.pose_current.x
y = self.game_context.table.y_min + self.game_context.table.y_max - self.planner.pose_current.y
angle = -self.planner.pose_current.O
pose1 = Pose(
x=x,
y=y,
O=angle,
max_speed_linear=66,
max_speed_angular=66,
)
pose2 = Pose(**self.planner.pose_current.model_dump())
pose1.after_pose_func = partial(self.append_pose, pose1)
pose2.after_pose_func = partial(self.append_pose, pose2)
self.poses.append(pose1)
self.poses.append(pose2)
async def append_pose(self, pose: Pose) -> None:
self.poses.append(pose)
def weight(self) -> float:
return 1000000.0
|