rosrust icon indicating copy to clipboard operation
rosrust copied to clipboard

Road map, especially for pointcloud2?

Open ghost opened this issue 3 years ago • 6 comments

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

ghost avatar Oct 24 '21 12:10 ghost

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).

pmirabel avatar Jan 30 '22 22:01 pmirabel

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 ;)

iliis avatar Sep 23 '22 11:09 iliis

@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.

noufelez avatar Mar 31 '23 08:03 noufelez

@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?

iliis avatar Mar 31 '23 08:03 iliis

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.

noufelez avatar Mar 31 '23 08:03 noufelez

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.

stelzo avatar May 01 '23 16:05 stelzo