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

Should support ros2 launch #214

Closed
EricCousineau-TRI opened this issue Jan 20, 2023 · 8 comments
Closed

Should support ros2 launch #214

EricCousineau-TRI opened this issue Jan 20, 2023 · 8 comments

Comments

@EricCousineau-TRI
Copy link
Collaborator

Most likely would happen in ~August, pending an external solution and/or upped priority

\cc @adeeb10abbas

@EricCousineau-TRI
Copy link
Collaborator Author

Should also look at alternative Bazel + ros2 approaches, and how they do it:
https://github.com/RobotLocomotion/drake-ros/tree/4c46abbfc5566c9b4cd1c3dffb77ec6549aa3a21/bazel_ros2_rules/ros2#alternatives

@sloretz
Copy link
Collaborator

sloretz commented Feb 22, 2023

How should Launch be supported? Is this looking for a bazel rule that invokes a launch file, kind of like a *_binary() rule?

# launch with `bazel run //:robot_launch`
ros2_launch_binary(
   name = "robot_launch",
   launch_file = ":robot_launch.xml",
)

@EricCousineau-TRI
Copy link
Collaborator Author

Yup!

Though I wouldn't say this is a priority for Anzu usage yet, though.

@adityapande-1995
Copy link
Collaborator

adityapande-1995 commented Jul 27, 2023

For starters, I feel the CLI should also be supported, as that is the easiest way to use ros2 launch.
For e.g. :

bazel run @ros2//:ros2 launch some_launch_file.py

I get an error saying :

    for entry_point in distribution(dist_name).entry_points
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 957, in distribution
    return Distribution.from_name(distribution_name)
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 548, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for ros2cli

The underlying ros2 archive extract which contains the run.bash hack actually does work. If you run the above command with --sandbox_debug and cd into the cached archive, run :

./run.bash ros2 launch some_launch_file.py

this works perfectly fine.

We're missing data dependencies or environment variables in _ros2_shim.py. Investigating.

Edit :
When using the ./run.bash way, I see the environment contains ros2cli/lib/python3.10/dist-packages, which is missing in the python import paths inside ~/.cache/bazel/_bazel_adityapande/a8af586f0c82b9e6daa7657c8a88944b/execroot/drake_ros/bazel-out/k8-fastbuild/bin/external/ros2

@EricCousineau-TRI
Copy link
Collaborator Author

EricCousineau-TRI commented Jul 27, 2023

FWIW, we ran into this (the ros2cli error) in Anzu.

I'm a bit murky on exact details, but I now think the No package metadata was found for ros2cli error will go away if you refetch the repository (e.g. bazel clean --expunge --async, or change anything in the repository definition to trigger re-fetching).

@adityapande-1995
Copy link
Collaborator

adityapande-1995 commented Aug 14, 2023

In other news, running bazel run @ros2//:ros2 from inside ros2_examples_bazel_installed actually works without complaining about a ros2cli dependency. If we do add a rule to run launch tests, it should run consistently from inside drake_ros as well, ideally.

Figuring out the path to the launch file is stil tricky using the CLI way, as the cwd for the bazel rule turns out to be in bazel-out/k8-opt/bin/external/ros2/ros2.runfiles/ros2_example_bazel_installed/ which may not be clear to users.

@EricCousineau-TRI
Copy link
Collaborator Author

Resolved by #298

FYI @tervay-bdai @adeeb10abbas @ali-bdai

@EricCousineau-TRI
Copy link
Collaborator Author

Follow-on work documented in #344

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

No branches or pull requests

3 participants