-
Notifications
You must be signed in to change notification settings - Fork 40
Module for autonomous docking #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
amessing-bdai
merged 78 commits into
rai-opensource:main
from
heuristicus:modular-docking
Jul 18, 2023
Merged
Changes from all commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
adfb0b1
refactored code into modules
jeremysee2 76f4899
refactored image service
jeremysee2 f026a3e
cleanup imports
jeremysee2 88ae203
add unit tests for some graph_nav_util functions
jeremysee2 be35078
pip install requirements
jeremysee2 86a604f
typing changes
jeremysee2 f4e9e43
absolute paths
jeremysee2 03c5997
clone to specific directory
jeremysee2 89213d8
check file structure for CI
jeremysee2 1ffab67
check files
jeremysee2 860c796
check files
jeremysee2 0097875
add test script
jeremysee2 5f04353
install spot wrapper
jeremysee2 7a9811b
install script
jeremysee2 15addcd
remove asyncimageservice
jeremysee2 3fa6430
use robot_params to share state variables
jeremysee2 55c68a1
Pytest replacement (#1)
jeremysee2 cf262e4
replace print() with self._logger.error()
jeremysee2 4928997
image publishing works well
jeremysee2 0c2bb45
moved SPOT_CLIENT_NAME
jeremysee2 6779aa5
static typing for claim()
jeremysee2 53fd6bf
Merge branch 'main' of https://github.com/jeremysee2/spot_wrapper int…
jeremysee2 4881d38
black formatting
jeremysee2 392da89
comments and passing error feedback
jeremysee2 22d1084
remove spot_config
jeremysee2 73d88be
use fstring for short code, move wrench from msg function to class body
heuristicus c473eef
Add changes from [SW-62] Elements for publishing the hand camera in s…
heuristicus 8963fb7
Wrapper for spot cam interaction (#4)
heuristicus 9b20fe1
fix bad indent after cherry-pick
heuristicus 2ea754a
fix formatting
heuristicus e913cba
fix short code conversion
heuristicus b5aa382
Always include exception message in response strings (#8)
heuristicus 1da2f3a
fix trajectory status unknown not being reset in trajectory command a…
heuristicus f481dfe
Add changes from [SW-127] Add function to get images by cameras (#11)
heuristicus 5d46cda
fix dataclass typing issue for older python versions (20.04), check l…
heuristicus b401006
remove old camera task mapping introduced in merge
heuristicus c9eb351
formatting
heuristicus 056fc25
Add changes from [WUD-126] Add manipulation client (#13)
heuristicus 65347c4
Add changes for added support for the rgb_cameras parameter in spot_r…
heuristicus 3e855a4
Add changes from [SW-141] Checking edge cases in upload_graph (#12)
heuristicus 03c9875
Updated bosdyn to 3.2.3 (#16)
davidwatkins-bdai 3ed105d
[OC-4] Build a Spot Dance Interface (#17)
vgupta-bdai 15ec99a
Merge branch 'main' into jeremysee-main
heuristicus 439965a
formatting
heuristicus 90d60ac
fix startup issues when choreography or arm is not present
heuristicus 7201b3a
small changes to choreo check and output when services are not available
heuristicus 9b7ecf5
better choreo ordering
heuristicus 0a67be9
message when choreo module is missing
heuristicus 5d53c58
cleanup unused spot_image and renamed graphnav private methods
jeremysee2 17dd90c
update graph_nav private methods
jeremysee2 bb7c5c1
merge upstream changes
jeremysee2 0ec8556
custom arm not found Exception
jeremysee2 651fed6
_get_lease private method in graphNav
jeremysee2 d64f65f
fix black
heuristicus 7843a48
import ordering and removal of unused imports
heuristicus e6df481
wait for arm commands to complete rather than sleeping, using block_u…
heuristicus ea44635
no longer use convenience dict to access robot params in wrapper class
heuristicus 7e9515c
missed some robot params usages in wrapper
heuristicus 8a9d27d
Merge branch 'main' into jeremysee-main
heuristicus 776e840
add block_until_manipulation_completes method
heuristicus ef2174d
improve arm module comments, manipulation request actually makes use …
heuristicus 94dcde5
Merge branch 'main' into jeremysee-main
heuristicus 8b1c477
restore wrapper to main branch state
heuristicus 5e33275
restore cam wrapper to main
heuristicus 664bfcc
restore graph nav util to main
heuristicus f88894a
Merge branch 'upstream-main' into modular-base-wrapper-restored
heuristicus 7131a2d
Merge branch 'main' into modular-base-wrapper-restored
heuristicus 1ffe26a
unnecessary change
heuristicus 101914a
Merge branch 'main' into modular-base-wrapper-restored
heuristicus a35373d
remove unrelated modules
heuristicus a143e8d
specific command clients passed to init, wrapper additions and deletions
heuristicus 0b9b062
Merge branch 'main' into modular-docking
heuristicus b19d02b
docking init receives and uses state object for is standing
heuristicus d9b07f2
Merge branch 'main' into modular-docking
heuristicus 9607905
use command data for dock id storage
heuristicus 82b6f41
move robot command and state classes into a helper file to avoid circ…
heuristicus ffed5a5
import robot state and command data from wrapper helpers, missing com…
heuristicus 00937d4
Merge branch 'main' into modular-docking
mpickett-bdai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import logging | ||
| import typing | ||
|
|
||
| from bosdyn.api.docking import docking_pb2 | ||
| from bosdyn.client import robot_command | ||
| from bosdyn.client.docking import DockingClient, blocking_dock_robot, blocking_undock | ||
| from bosdyn.client.robot import Robot | ||
|
|
||
| from spot_wrapper.wrapper_helpers import RobotState, RobotCommandData | ||
|
|
||
|
|
||
| class SpotDocking: | ||
| """ | ||
| Interactions with spot's autonomous docking station | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| robot: Robot, | ||
| logger: logging.Logger, | ||
| robot_state: RobotState, | ||
| command_data: RobotCommandData, | ||
| docking_client: DockingClient, | ||
| robot_command_client: robot_command.RobotCommandClient, | ||
| ) -> None: | ||
| self._robot = robot | ||
| self._logger = logger | ||
| self._command_data = command_data | ||
| self._docking_client: DockingClient = docking_client | ||
| self._robot_command_client = robot_command_client | ||
| self._robot_state = robot_state | ||
|
|
||
| def dock(self, dock_id: int) -> typing.Tuple[bool, str]: | ||
| """Dock the robot to the docking station with fiducial ID [dock_id].""" | ||
| try: | ||
| # Make sure we're powered on and standing | ||
| self._robot.power_on() | ||
| if not self._robot_state.is_standing: | ||
| robot_command.blocking_stand( | ||
| command_client=self._robot_command_client, timeout_sec=10 | ||
| ) | ||
| self._logger.info("Spot is standing") | ||
| else: | ||
| self._logger.info("Spot is already standing") | ||
| # Dock the robot | ||
| self._command_data.last_docking_command = dock_id | ||
| blocking_dock_robot(self._robot, dock_id) | ||
| self._command_data.last_docking_command = None | ||
| return True, "Success" | ||
| except Exception as e: | ||
| return False, f"Exception while trying to dock: {e}" | ||
|
|
||
| def undock(self, timeout: int = 20) -> typing.Tuple[bool, str]: | ||
| """Power motors on and undock the robot from the station.""" | ||
| try: | ||
| # Maker sure we're powered on | ||
| self._robot.power_on() | ||
| # Undock the robot | ||
| blocking_undock(self._robot, timeout) | ||
| return True, "Success" | ||
| except Exception as e: | ||
| return False, f"Exception while trying to undock: {e}" | ||
|
|
||
| def get_docking_state(self, **kwargs) -> docking_pb2.DockState: | ||
| """Get docking state of robot.""" | ||
| state = self._docking_client.get_docking_state(**kwargs) | ||
| return state |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| """Helper classes for the wrapper. This file is necessary to prevent circular imports caused by the modules also | ||
| using these classes""" | ||
| import typing | ||
| from dataclasses import dataclass | ||
|
|
||
|
|
||
| @dataclass() | ||
| class RobotState: | ||
| """ | ||
| Dataclass which stores information about the robot's state. The values in it may be changed by methods | ||
| """ | ||
|
|
||
| is_sitting: bool = True | ||
| is_standing: bool = False | ||
| is_moving: bool = False | ||
| at_goal: bool = False | ||
| near_goal: bool = False | ||
|
|
||
|
|
||
| @dataclass() | ||
| class RobotCommandData: | ||
| """ | ||
| Store data about the commands the wrapper sends to the SDK. Running a command returns an integer value | ||
| representing that command's ID. These values are used to monitor the progress of the command and modify attributes | ||
| of RobotState accordingly. The values should be reset to none when the command completes. | ||
| """ | ||
|
|
||
| last_stand_command: typing.Optional[int] = None | ||
| last_sit_command: typing.Optional[int] = None | ||
| last_docking_command: typing.Optional[int] = None | ||
| last_trajectory_command: typing.Optional[int] = None | ||
| # Was the last trajectory command requested to be precise | ||
| last_trajectory_command_precise: typing.Optional[bool] = None | ||
| last_velocity_command_time: typing.Optional[float] = None |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.