Closed zhuhaow closed 4 months ago
So, Bazel package name != ros_package_name and they are unrelated. But, ros_package_name == Bazel target name. In your case, you defined 3 separate targets (please share why) example_msg, example_srv and example_action. Those will define 3 separate packages in ROS terms. Therefore, you need to the following changes:
diff --git a/example/Example.action b/example/Example.action
index c0b78f8..be916b6 100644
--- a/example/Example.action
+++ b/example/Example.action
@@ -1,5 +1,5 @@
-Example message1
+example_msg/Example message1
---
-Example message2
+example_msg/Example message2
---
-Example message3
+example_msg/Example message3
diff --git a/example/Example.srv b/example/Example.srv
index d0bba73..ab7d8a2 100644
--- a/example/Example.srv
+++ b/example/Example.srv
@@ -1,3 +1,3 @@
-Example ping
+example_msg/Example ping
---
-Example pong
+example_msg/Example pong
With those changes, you can build the other cc-targets. Sounds good?
That makes total sense! Thanks so much
I created a minimal repro at https://github.com/zhuhaow/ros2-bazel-message-error-demo/
When running
bazel build --keep_going //...
, we will get errorThe problem seems like the message header should be
example_msg/msg/detail/example__struct.hpp
but somehow it is generated as the target depends on it{TARGET_NAME}/msg/detail/example__struct.hpp
.