Skip to content

Commit b16ddc3

Browse files
Merge branch 'main' into modular-graphnav
2 parents 9b0eedf + c85fe4a commit b16ddc3

4 files changed

Lines changed: 760 additions & 48 deletions

File tree

spot_wrapper/spot_arm.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from bosdyn.client.time_sync import TimeSyncEndpoint
2222
from bosdyn.util import seconds_to_duration
2323

24-
from spot_wrapper.wrapper_helpers import RobotState
24+
from spot_wrapper.wrapper_helpers import RobotState, ClaimAndPowerDecorator
2525

2626

2727
class SpotArm:
@@ -34,13 +34,19 @@ def __init__(
3434
manipulation_api_client: ManipulationApiClient,
3535
robot_state_client: RobotStateClient,
3636
max_command_duration: float,
37+
claim_and_power_decorator: ClaimAndPowerDecorator,
3738
) -> None:
3839
"""
3940
Constructor for SpotArm class.
4041
Args:
4142
robot: Robot object
4243
logger: Logger object
44+
robot_state: Object containing the robot's state as controlled by the wrapper
45+
robot_command_client: Command client to use to send commands to the robot
46+
manipulation_api_client: Command client to send manipulation commands to the robot
47+
robot_state_client: Client to retrieve state of the robot
4348
max_command_duration: Maximum duration for commands when using the manipulation command method
49+
claim_and_power_decorator: Object to use to decorate the functions on this object
4450
"""
4551
self._robot = robot
4652
self._logger = logger
@@ -49,6 +55,23 @@ def __init__(
4955
self._robot_command_client = robot_command_client
5056
self._manipulation_api_client = manipulation_api_client
5157
self._robot_state_client = robot_state_client
58+
self._claim_and_power_decorator = claim_and_power_decorator
59+
self._claim_and_power_decorator.decorate_functions(
60+
self,
61+
decorated_funcs=[
62+
self.ensure_arm_power_and_stand,
63+
self.arm_stow,
64+
self.arm_unstow,
65+
self.arm_carry,
66+
self.arm_joint_move,
67+
self.force_trajectory,
68+
self.gripper_open,
69+
self.gripper_close,
70+
self.gripper_angle_open,
71+
self.hand_pose,
72+
self.grasp_3d,
73+
],
74+
)
5275

5376
def _manipulation_request(
5477
self,

spot_wrapper/spot_docking.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
from bosdyn.client.docking import DockingClient, blocking_dock_robot, blocking_undock
77
from bosdyn.client.robot import Robot
88

9-
from spot_wrapper.wrapper_helpers import RobotState, RobotCommandData
9+
from spot_wrapper.wrapper_helpers import (
10+
RobotState,
11+
RobotCommandData,
12+
ClaimAndPowerDecorator,
13+
)
1014

1115

1216
class SpotDocking:
@@ -22,13 +26,20 @@ def __init__(
2226
command_data: RobotCommandData,
2327
docking_client: DockingClient,
2428
robot_command_client: robot_command.RobotCommandClient,
29+
claim_and_power_decorator: ClaimAndPowerDecorator,
2530
) -> None:
2631
self._robot = robot
2732
self._logger = logger
2833
self._command_data = command_data
2934
self._docking_client: DockingClient = docking_client
3035
self._robot_command_client = robot_command_client
3136
self._robot_state = robot_state
37+
self._claim_and_power_decorator = claim_and_power_decorator
38+
# Decorate the functions so that they take the lease. Dock function needs to power on because it might have
39+
# to move the robot, the undock
40+
self._claim_and_power_decorator.decorate_functions(
41+
self, decorated_funcs=[self.dock, self.undock]
42+
)
3243

3344
def dock(self, dock_id: int) -> typing.Tuple[bool, str]:
3445
"""Dock the robot to the docking station with fiducial ID [dock_id]."""

0 commit comments

Comments
 (0)