To run this example:
cargo run --example read_bag
To regenerate sample bags, run:
./examples/read_bag/scripts/generate_fixtures.sh
Make sure you have the std_msgs
(git submodule in the root of the project) checked out:
git submodule update --init
Code-generation is done through the build.rs
and added to the project via the include!
statement in main.rs.
The generation recursively scans every .msg
file in the supplied std_msgs
and dummy_msgs directories and create Rust structs for them, which will be used by the serde_rosmsg
crate for deserialization.
It looks something like:
/// This file is autogenerated. Do not edit by hand!
pub mod msgs {
pub mod dummy_msgs {
#[derive(Clone, Debug, serde::Deserialize, PartialEq)]
pub struct Dummy {
pub r#data: Vec<u8>,
}
impl Dummy {
pub const r#PI: f32 = 3.1415927;
pub const r#N_PI: f32 = -3.1415927;
pub const r#HELLO: &'static str = &"WORLD";
}
impl frost::msgs::Msg for Dummy {}
}
pub mod std_msgs {
#[derive(Clone, Debug, serde::Deserialize, PartialEq)]
pub struct Bool {
pub r#data: bool,
}
impl Bool {}
impl frost::msgs::Msg for Bool {}
#[derive(Clone, Debug, serde::Deserialize, PartialEq)]
pub struct Byte {
pub r#data: u8,
}
impl Byte {}
impl frost::msgs::Msg for Byte {}
//... more
}
}