Skip to content

Commit b7ac5a2

Browse files
committed
Support RobotState() and RobotCommandData() class and move _last_navigate_to_command to RobotCommandData() class
1 parent e858756 commit b7ac5a2

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

spot_wrapper/wrapper.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,10 @@ def _start_query(self) -> None:
473473
self._logger.error("Error when getting robot command feedback: %s", e)
474474
self._spot_wrapper.last_trajectory_command = None
475475

476-
if self._spot_wrapper._last_navigate_to_command is not None:
476+
if self._spot_wrapper.last_navigate_to_command is not None:
477477
is_moving = True
478478

479-
self._spot_wrapper._is_moving = is_moving
479+
self._spot_wrapper.is_moving = is_moving
480480

481481
# We must check if any command currently has a non-None value for its id. If we don't do this, this stand
482482
# command can cause other commands to be interrupted before they get to start
@@ -593,6 +593,7 @@ class RobotCommandData:
593593
# Was the last trajectory command requested to be precise
594594
last_trajectory_command_precise: typing.Optional[bool] = None
595595
last_velocity_command_time: typing.Optional[float] = None
596+
last_navigate_to_command: typing.Optional[int] = None
596597

597598

598599
class SpotWrapper:
@@ -658,7 +659,6 @@ def __init__(
658659
self._state = RobotState()
659660
self._trajectory_status_unknown = False
660661
self._command_data = RobotCommandData()
661-
self._last_navigate_to_command = None
662662
self._state_navigate_to_valid = None
663663

664664
self._front_image_requests = []
@@ -1186,6 +1186,14 @@ def last_velocity_command_time(self) -> typing.Optional[float]:
11861186
def last_velocity_command_time(self, command_time: float) -> None:
11871187
self._command_data.last_velocity_command_time = command_time
11881188

1189+
@property
1190+
def last_navigate_to_command(self) -> typing.Optional[int]:
1191+
return self._command_data.last_navigate_to_command
1192+
1193+
@last_navigate_to_command.setter
1194+
def last_navigate_to_command(self, command_id: int) -> None:
1195+
self._command_data.last_navigate_to_command = command_id
1196+
11891197
def is_estopped(self, timeout: typing.Optional[float] = None) -> bool:
11901198
return self._robot.is_estopped(timeout=timeout)
11911199

@@ -2607,15 +2615,15 @@ def _start_navigate_to(
26072615
leases=[sublease.lease_proto],
26082616
command_id=nav_to_cmd_id,
26092617
)
2610-
self._last_navigate_to_command = nav_to_cmd_id
2618+
self.last_navigate_to_command = nav_to_cmd_id
26112619
except ResponseError as e:
26122620
self._logger.error("Error while navitation: %s", e)
26132621
break
26142622

26152623
if self._check_success(nav_to_cmd_id):
26162624
break
26172625

2618-
self._last_navigate_to_command = None
2626+
self.last_navigate_to_command = None
26192627
self._lease = self._lease_wallet.advance()
26202628
self._lease_keepalive = LeaseKeepAlive(self._lease_client)
26212629

0 commit comments

Comments
 (0)