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

Road map, especially for pointcloud2? #163

Open
ghost opened this issue Oct 24, 2021 · 6 comments
Open

Road map, especially for pointcloud2? #163

ghost opened this issue Oct 24, 2021 · 6 comments

Comments

@ghost
Copy link

ghost commented Oct 24, 2021

Hi,

Very excited by this project, especially for a simple ROS client I'd like to use it for in development/debugging scenarios only to interface with existing C++ ROS services. But is there a list of supported ros modules and msgs?

For instance:

  • before diving too deep it would be good to know if I could use rosrust to be able to run rosbridge, as I would be using Rust to create a rest server running rosbridge_suite to convert json messages it receives into ROS msgs to send onward to my C++ ROS services that expect various geometry_msgs as well as more basic std_msgs including arrays.
  • I see in the readme pointcloud2 msg is not yet available, and I would definitely need that in the next year or so. Are there workarounds for subscribing or publishing pointcloud2 msg type or is it soon to be available? For instance, if array messages are supported in some cases I could write an adapter in my C++ ROS services that just accept f32 arrays instead of pointcloud2 (at a performance penalty, but okay for development since PCL can read raw text data too)
  • Is support for ROS2 on the horizon? Or would that break some backs to get implemented anytime soon? Just found it: https://github.com/ros2-rust/ros2_rust
@pmirabel
Copy link

Hi, late but maybe expected answer :

  • regarding the fact that rosrust is able to run rosbridge : I maybe misunderstood your question, but if you want to know if rosrust is able to interact with rosbridge, then answer is yes.
  • regarding the workaround needed to work with pointcloud2 msg, I think that your workarround works (despites performances concerns indeed).

@iliis
Copy link

iliis commented Sep 23, 2022

For other's stumbling over this: It seems to be that only the infrastructure to work conveniently with point clouds is missing, but you can absolutely create a PointCloud2 message manually:

let cloud_publisher = rosrust::publish("/cloud", 100).unwrap();
let mut cloud = rosrust_msg::sensor_msgs::PointCloud2::default();

cloud.header.seq = 0;
cloud.header.frame_id = "map".to_string();
cloud.header.stamp = rosrust::now();

cloud.height = 1;
cloud.width = 10;

cloud.fields = vec![
    rosrust_msg::sensor_msgs::PointField {
        name: 'x'.to_string(),
        offset: 0,
        datatype: rosrust_msg::sensor_msgs::PointField::FLOAT32,
        count: 1
    },
    rosrust_msg::sensor_msgs::PointField {
        name: 'y'.to_string(),
        offset: 4,
        datatype: rosrust_msg::sensor_msgs::PointField::FLOAT32,
        count: 1
    },
    rosrust_msg::sensor_msgs::PointField {
        name: 'z'.to_string(),
        offset: 8,
        datatype: rosrust_msg::sensor_msgs::PointField::FLOAT32,
        count: 1
    },
];

cloud.is_bigendian = false; // seems to be ignored by rviz, so probably has to be host order
cloud.point_step = 3*4; // size of a point in bytes
cloud.row_step = cloud.point_step * cloud.width; // length of a row in bytes (not really used as our cloud here is 1D)
cloud.is_dense = true; // no invalid points
cloud.data = Vec::with_capacity((cloud.width * cloud.point_step) as usize);

// generate some points
for i in 0..10 {
    let x: f32 = 1_f32;
    let y: f32 = i as f32;
    let z: f32 = i as f32/10.0;

    // ideally, we would use to_le_bytes() or to_be_bytes() here, but the is_bigendian flag doesn't seem to be supported by rviz
    cloud.data.extend_from_slice(&x.to_ne_bytes());
    cloud.data.extend_from_slice(&y.to_ne_bytes());
    cloud.data.extend_from_slice(&z.to_ne_bytes());
}

cloud_publisher.send(cloud).unwrap();

This works, at least with rviz. No guarantees that this is the most performant code ;)

@noufelez
Copy link

noufelez commented Mar 31, 2023

@iliis Hey I'm new to rosrust. I just read your message and I'd like to implement pointcloud2 and maybe upstream it if I get something working.

When you say that it works with rviz you mean that you are able to send a pointcloud message that gets serialized into bytes and sent over the wire to later be retrieved by another node that will deserialize it into a struct (rust, cpp or py) ?

If this is the case then I don't see what's missing.

@iliis
Copy link

iliis commented Mar 31, 2023

@noufelez Yes, exactly, although I haven't tested it extensively.
What I think is missing is a convenient API, for example to directly publish a rust array without needing all this boilerplate. But I'm not involved in this project, so maybe @adnanademovic could chime in?

@noufelez
Copy link

Thanks for your quick response!

I see. I'll try to get something working in the near future. I'll update this thread when I do so to notify people that may need it.

@stelzo
Copy link

stelzo commented May 1, 2023

You could also use https://crates.io/crates/ros_pointcloud2.

Full disclosure: it is my first crate, I just started Rust and rosrust is my first real application for it. I did not see this issue before, else I probably could have waited for @noufelez but I needed it really soon for a lot of point cloud work.

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

4 participants