Skip to content
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

[N/A] Add a mock launch argument #199

Merged
merged 8 commits into from
Dec 8, 2023

Conversation

ggoretkin-bdai
Copy link
Collaborator

@ggoretkin-bdai ggoretkin-bdai commented Nov 22, 2023

This PR uses node / launch arguments to specify whether the driver should operate in "mock" mode, instead of using the sentinel name Mock_spot. With an explicit parameter, we can have multiple mocks, with different names, and also affect whether there is an arm.

For example, with this modification you can do

cd spot_driver
colcon build --symlink # (`symlink` [does not apply to launch files](https://github.com/colcon/colcon-core/issues/407))
source install/setup.bash
ros2 launch spot_driver spot_driver.launch.py spot_name:=AnyNameHere mock_enable:=True mock_has_arm:=True

and then, for example (spot_utilities, specifically in bdai repo)

# source so that `spot_driver` can be found
cd spot_utilities # /workspaces/bdai/ws/src/spot_utilities
colcon build
source install/setup.bash
ros2 run spot_utilities spot_teleop.py AnyNameHere

@ggoretkin-bdai
Copy link
Collaborator Author

ggoretkin-bdai commented Nov 22, 2023

@ggoretkin-bdai ggoretkin-bdai force-pushed the 11-21-_N/A_Add_a_mock_launch_argument branch from 68d28d9 to 2202fef Compare November 22, 2023 00:32
@@ -2343,7 +2349,7 @@ def populate_camera_static_transforms(self, image_data: image_pb2.Image) -> None
# We exclude the odometry frames from static transforms since they are not static. We can ignore the body
# frame because it is a child of odom or vision depending on the preferred_odom_frame, and will be published
# by the non-static transform publishing that is done by the state callback
frame_prefix = MOCK_HOSTNAME + "/"
frame_prefix = ""
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ashay-bdai ashay-bdai force-pushed the 11-21-_N/A_Add_a_mock_launch_argument branch from 217290e to 0432abf Compare November 29, 2023 17:43
@ggoretkin-bdai ggoretkin-bdai force-pushed the 11-21-_N/A_Add_a_mock_launch_argument branch 4 times, most recently from 716d3da to 80fd72b Compare December 5, 2023 17:00
@ggoretkin-bdai ggoretkin-bdai force-pushed the 11-21-_N/A_Add_a_mock_launch_argument branch from 9725e97 to 166eb4e Compare December 5, 2023 19:57
@ggoretkin-bdai ggoretkin-bdai marked this pull request as ready for review December 5, 2023 21:52
Copy link
Collaborator

@bhung-bdai bhung-bdai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with a non-urgent question/comment

spot_driver/spot_driver/spot_ros2.py Show resolved Hide resolved
Copy link
Collaborator

@ksharma-bdai ksharma-bdai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - one hesitation on warning vs error

Comment on lines 417 to 421
if self.frame_prefix != self.spot_wrapper.frame_prefix:
self.get_logger().warn(
f"WARNING: disagreement between `self.frame_prefix` ({self.frame_prefix}) and"
f" `self.spot_wrapper.frame_prefix` ({self.spot_wrapper.frame_prefix})"
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this safe to just keep a as a warning rather than a failure? since some of the replacement code depends on this being true, i wonder if we should fail here even if this is a "should never happen" kind of scenario

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1. Honestly not sure if it matters or not, but it would be good if someone knew

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. The safe options are

  1. make this an error
  2. restore some of the logic at https://github.com/bdaiinstitute/spot_ros2/pull/199/files#diff-11ccb5e01196250d5a8ef23315e44c8111eeb856fcc11e14b36789f915ba207aL2347 and handle the mocked case specially

I think 1 is better.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the error makes sense, a hard failure will get reported so we can figure out when/why this actually occurs.

@ggoretkin-bdai
Copy link
Collaborator Author

I made disagreement about frame_prefix an error. Thanks!

@bhung-bdai bhung-bdai merged commit e51722d into main Dec 8, 2023
5 checks passed
@bhung-bdai bhung-bdai deleted the 11-21-_N/A_Add_a_mock_launch_argument branch December 8, 2023 18:43
marlow-fawn pushed a commit to marlow-fawn/spot_ros2 that referenced this pull request Aug 19, 2024
This PR uses node / launch arguments to specify whether the driver should operate in "mock" mode, instead of using the sentinel name `Mock_spot`. With an explicit parameter, we can have multiple mocks, with different names, and also affect whether there is an arm.


For example, with this modification you can do

```
cd spot_driver
colcon build --symlink # (`symlink` [does not apply to launch files](colcon/colcon-core#407))
source install/setup.bash
ros2 launch spot_driver spot_driver.launch.py spot_name:=AnyNameHere mock_enable:=True mock_has_arm:=True
```

and then, for example (`spot_utilities`, specifically in `bdai` repo)

```
# source so that `spot_driver` can be found
cd spot_utilities # /workspaces/bdai/ws/src/spot_utilities
colcon build
source install/setup.bash
ros2 run spot_utilities spot_teleop.py AnyNameHere
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants