dora-rs / dora

DORA (Dataflow-Oriented Robotic Application) is middleware designed to streamline and simplify the creation of AI-based robotic applications. It offers low latency, composable, and distributed dataflow capabilities. Applications are modeled as directed graphs, also referred to as pipelines.
https://dora-rs.ai
Apache License 2.0
1.35k stars 68 forks source link

self-defined messages not able to included in header file #481

Closed bobd988 closed 2 months ago

bobd988 commented 2 months ago

For self-defined ROS2 msg , after adding to AMENT_PREFIX_PATH , and then run cargo build the msg was not inlcuded in the bindings header file.

The expected behavior is to having the message to be included in bindings header file if ROS2 msg folder was added AMENT_PREFIX_PATH . By the way the msg folder by default has no idl file. Is idl file needed in order to make this work?

I was running this command after adding msg to AMENT_PREFIX_PATH

export RMW_IMPLEMENTATION=rmw_fastrtps_cpp cargo run --example cxx-ros2-dataflow --features ros2-examples

phil-opp commented 2 months ago

Our current message generator looks at the files in share/ament_index/resource_index/rosidl_interfaces to find all available messages. Then it looks up the listed messages in share/<namespace>/msg/<name>.msg. I think we could skip the lookup in rosidl_interfaces and look for the message files directly.

I'm not familiar with self-defined ROS2 messages. Could you give some details on the directory structure so that I can update the message generator to work for your case?

haixuanTao commented 2 months ago

It seems that we also need to modify: `share/ament_index/resource_index/rosidl_interfaces"; See: https://github.com/dora-rs/dora/blob/20afeb7ab0a9ecd1647b74fe87db5cfb3a57d3d3/libraries/extensions/ros2-bridge/msg-gen/src/parser/package.rs#L12

The parsing use this index to search for packages:

fn get_ros_msgs_each_package<P: AsRef<Path>>(root_dir: P) -> Result<Vec<Package>> {
    let dir = root_dir.as_ref().join(ROSIDL_INTERFACES);
bobd988 commented 2 months ago

Ubuntu 22.04 OS switch to fix-ament-prefix-path branch and

cargo run --example cxx-ros2-dataflow --features ros2-examples

I got compile error

Compiling dora-node-api v0.3.3 (/home/demo/Public/github_dora/dora/apis/rust/node) error: failed to run custom build command for dora-ros2-bridge v0.1.0 (/home/demo/Public/github_dora/dora/libraries/extensions/ros2-bridge)

Caused by: process didn't exit successfully: /home/demo/Public/github_dora/dora/target/debug/build/dora-ros2-bridge-3496c43697944aee/build-script-build (exit status: 101) --- stdout cargo:rerun-if-env-changed=AMENT_PREFIX_PATH cargo:rerun-if-changed=/opt/ros/humble cargo:rerun-if-changed= cargo:rerun-if-changed=/home/demo/msgs cargo:rerun-if-changed=/home/demo/msgs/autoware_msgs/autoware_common_msgs/msg/

--- stderr GlobError { path: "/boot/efi", error: Os { code: 13, kind: PermissionDenied, message: "Permission denied" } } GlobError { path: "/etc/cups/ssl", error: Os { code: 13, kind: PermissionDenied, message: "Permission denied" } } GlobError { path: "/etc/polkit-1/localauthority", error: Os { code: 13, kind: PermissionDenied, message: "Permission denied" } } GlobError { path: "/etc/ssl/private", error: Os { code: 13, kind: PermissionDenied, message: "Permission denied" } } thread 'main' panicked at /home/demo/Public/github_dora/dora/libraries/extensions/ros2-bridge/msg-gen/src/lib.rs:23:40: called Result::unwrap() on an Err value: No such file or directory (os error 2) note: run with RUST_BACKTRACE=1 environment variable to display a backtrace warning: build failed, waiting for other jobs to finish... Error: failed to compile dora-node-api-cxx

Location: examples/c++-ros2-dataflow/run.rs:74:9

haixuanTao commented 2 months ago

Indeed! Thanks for trying. Just pushed a fix on the branch.