#ros #nalgebra #robotics #message #convert #rosrust #geometry-msgs

ros-nalgebra

ROS message converter for rosrust and nalgebra

7 releases

0.1.0 Oct 25, 2022
0.0.6 Jan 24, 2022
0.0.5 Mar 5, 2021
0.0.4 Feb 1, 2021
0.0.1 Sep 15, 2020

#714 in Algorithms

Download history 24/week @ 2024-07-20 79/week @ 2024-07-27 42/week @ 2024-08-03 16/week @ 2024-08-10 11/week @ 2024-08-17 39/week @ 2024-08-24 77/week @ 2024-08-31 47/week @ 2024-09-07 16/week @ 2024-09-14 43/week @ 2024-09-21 61/week @ 2024-09-28 13/week @ 2024-10-05 19/week @ 2024-10-12 52/week @ 2024-10-19 13/week @ 2024-10-26 39/week @ 2024-11-02

123 downloads per month
Used in 4 crates (2 directly)

Apache-2.0

21KB
159 lines

ros-nalgebra

Build Status crates.io docs

Generate code to convert geometry_msgs into nalgebra structs, for rosrust.

Pre-requirements & dependencies

How to use

Easy usage: ros_nalgebra::rosmsg_include!()

Use ros_nalgebra::rosmsg_include instead of rosrust::rosmsg_include in your code.

use nalgebra as na;

mod msg {
    ros_nalgebra::rosmsg_include!(nav_msgs / Odometry);
}

fn main() {
    let mut odom_msg = msg::nav_msgs::Odometry::default();
    odom_msg.pose.pose.position.x = 1.0;
    odom_msg.pose.pose.position.y = -1.0;
    odom_msg.pose.pose.position.z = 2.0;
    odom_msg.pose.pose.orientation.x = 0.0;
    odom_msg.pose.pose.orientation.y = 0.0;
    odom_msg.pose.pose.orientation.z = 0.0;
    odom_msg.pose.pose.orientation.w = 1.0;

    // convert into nalgebra::Isometry<f64> by `from()`
    let pose = na::Isometry3::from(odom_msg.pose.pose);
    println!("{pose}");

    let mut pose2 = pose.clone();
    pose2.translation.vector.x = -5.0;

    // convert into ROS msg using `into()`
    let pose_msg: msg::geometry_msgs::Pose = pose2.into();
    println!("{pose_msg:?}");
}

Automatically defined messages by ros_nalgebra::rosmsg_include!()

Below messages are automatically included by ros_nalgebra::rosmsg_include!(). Do not include them in your code.

geometry_msgs/Point,
geometry_msgs/Pose,
geometry_msgs/Quaternion,
geometry_msgs/Transform,
geometry_msgs/Vector3,

Other usage: ros_nalgebra!() and ros_nalgebra_msg!()

If some messages are included already (for example in other crate), you can use ros_nalgebra_msg!(). The arguments are the rust namespace of the geometry_msgs (example:msg) and the message type (example: Pose for geometry_msgs/Pose, Point for geometry_msgs/Point).

Example

In some_other_crate,

mod msg {
    rosrust::rosmsg_include!(geometry_msgs/Point);
}

Then you can use ros_nalgebra::ros_nalgebra_msg!() in your crate.

// generate conversion code only for `geometry_msgs/Point` which is defined in `some_other_crate::msg`.
ros_nalgebra::ros_nalgebra_msg!(some_other_crate::msg, Point);

Supported conversions

See lib.rs.

TODO

Handle dependencies.

No runtime deps