Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
ROS PointCloud2
A Rust implementation for fast, safe and customizable conversions to and from the sensor_msgs/PointCloud2 ROS message.
Providing a fast and memory efficient way for message conversion while allowing user defined types without the cost of iterations.
Currently only supports rosrust_msg with ROS1.
use ConvertXYZ;
use PointXYZ;
use FallibleIterator;
use PointCloud2;
// Your points (here using the predefined type PointXYZ).
let cloud_points = vec!;
let cloud_copy = cloud_points.clone; // Only for checking equality later.
// Vector -> Convert -> Message
let msg: PointCloud2 = try_from.unwrap.try_into.unwrap;
// Message -> Convert -> Vector
let convert: ConvertXYZ = try_from.unwrap;
let new_cloud_points = convert.map.
.unwrap; // Handle point conversion or byte errors here.
assert_eq!;
Instead of converting the entire cloud into a Vector, you get an Iterator that converts each point from the message on the fly.
An example for using this crate is this filter node. It is also a good starting point for
implementing ROS1 nodes in Rust inside a catkin environment.
Features
- Full support for
sensor_msgs/PointCloud2messages - Custom types with
FromandIntotraits - Predefined types for common conversions (compared to PCL)
- PointXYZ
- PointXYZI
- PointXYZL
- PointXYZRGB
- PointXYZRGBA
- PointXYZRGBL
- PointXYZNormal
- PointXYZINormal
- PointXYZRGBNormal
- 2D and 3D support
Usage
Add this to your Cargo.toml:
[]
= "0.1.0"
When building, the rosrust_msg crate needs to have the ROS environment sourced or use ROSRUST_MSG_PATH=/opt/ros/$ROS_DISTRO/share cargo build.
Custom Types
You can freely convert to your own types without reiterating the entire cloud.
You just need to implement the Into and From traits.
use size_of;
use ;
use PointCloud2;
const DIM : usize = 3;
const METADIM : usize = 4;
// Converting your custom point to the crate's internal representation
// The mappings for index of meta idx to field names. Example: 0 -> "r", 1 -> "g", 2 -> "b", 3 -> "a"
// Converting crate's internal representation to your custom point
type MyConverter = size_of! }, DIM, METADIM, CustomPoint>;
// Your custom cloud (Vector)
let custom_cloud = vec!;
// Cloud -> ROS message
let custom_msg: PointCloud2 = try_from.unwrap.try_into.unwrap;
// ROS message -> Cloud
let to_custom_type = try_from.unwrap;
Future Work
- ROS2 support(!)
- Removing rosrust dependency
- Benchmark vs PCL
- Proper error passing to the iterator result (currently merged into
PointConversionError) - remove allocations
- introduce no-panic for maximum stability
- Add more predefined types