Skip to content

Commit

Permalink
Add TODO, broken attempt at optional parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
ggoretkin-bdai committed Dec 4, 2023
1 parent 4823531 commit 716d3da
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
11 changes: 9 additions & 2 deletions spot_driver/launch/spot_driver.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ def launch_setup(context: LaunchContext, ld: LaunchDescription) -> None:

if not mock_enable:
# Get parameters from Spot.

# TODO this deviates from the `get_from_env_and_fall_back_to_param` logic in `spot_ros2.py`,
# which would pull in values in `config_file`
username = os.getenv("BOSDYN_CLIENT_USERNAME", "username")
password = os.getenv("BOSDYN_CLIENT_PASSWORD", "password")
hostname = os.getenv("SPOT_IP", "hostname")
Expand Down Expand Up @@ -160,12 +161,18 @@ def launch_setup(context: LaunchContext, ld: LaunchDescription) -> None:
spot_driver_params = {
"spot_name": spot_name,
"mock_enable": mock_enable,
"mock_has_arm": mock_has_arm,
"publish_depth_registered": False,
"publish_depth": False,
"publish_rgb": False,
}

if mock_enable:
mock_spot_driver_params = {
"mock_has_arm": mock_has_arm
}
# Merge the two dicts
spot_driver_params = {**spot_driver_params, **mock_spot_driver_params}

spot_driver_node = launch_ros.actions.Node(
package="spot_driver",
executable="spot_ros2",
Expand Down
12 changes: 8 additions & 4 deletions spot_driver/spot_driver/spot_ros2.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,10 @@ def __init__(self, parameter_list: Optional[typing.List[Parameter]] = None, **kw
self.declare_parameter("initialize_spot_cam", False)

self.declare_parameter("spot_name", "")
self.declare_parameter("mock_enable", False)
self.declare_parameter("mock_has_arm", True)
if self.get_parameter("mock_enable").value:
# This is resuling in:
# [spot_ros2-1] rclpy.exceptions.ParameterNotDeclaredException: ('Invalid access to undeclared parameter(s)', 'mock_enable')
self.declare_parameter("mock_has_arm")

# used for setting when not using launch file
if parameter_list is not None:
Expand Down Expand Up @@ -294,8 +296,10 @@ def __init__(self, parameter_list: Optional[typing.List[Parameter]] = None, **kw
self.name: Optional[str] = self.get_parameter("spot_name").value
if not self.name:
self.name = None
self.mock: Optional[bool] = self.get_parameter("mock_enable").value
self.mock_has_arm: Optional[bool] = self.get_parameter("mock_has_arm").value
self.mock: bool = self.get_parameter("mock_enable").value
self.mock_has_arm: Optional[bool] = None
if self.mock:
self.mock_has_arm = self.get_parameter("mock_has_arm").value

self.motion_deadzone: Parameter = self.get_parameter("deadzone")
self.estop_timeout: Parameter = self.get_parameter("estop_timeout")
Expand Down

0 comments on commit 716d3da

Please sign in to comment.