Open lucasw opened 5 months ago
Create simple test bag + mcap
rostopic pub /test marti_common_msgs/Float32Stamped "header:
seq: 3
stamp:
secs: 1
nsecs: 7
frame_id: 'test'
value: 1.0" -r 1
The test message is generated internally using the roslibrust message + serde_rosmsg to_vec()
test 28 - [18, 00, 00, 00, 03, 00, 00, 00, 01, 00, 00, 00, 07, 00, 00, 00, 04, 00, 00, 00, 74, 65, 73, 74, 00, 00, 80, 3f]
mcap 24 - [0a, 00, 00, 00, 01, 00, 00, 00, 07, 00, 00, 00, 04, 00, 00, 00, 74, 65, 73, 74, 00, 00, 80, 3f]
It has an extra 4 byte header over the mcap encoded message
-> https://github.com/lucasw/ros_one2z/issues/7#issuecomment-1826426812
https://github.com/adnanademovic/serde_rosmsg/blob/master/src/lib.rs#L13
It would be nice if serde_rosmsg had from_slice option to not require the header bytes (unless it actually uses them, but it has an array/vector length already)
use roslibrust_codegen_macro::find_and_generate_ros_messages;
find_and_generate_ros_messages!();
...
// https://github.com/adnanademovic/serde_rosmsg/blob/master/src/lib.rs#L9
let len_header = message.data.len() as u32;
let mut msg_with_header = Vec::from(len_header.to_le_bytes());
let mut message_data = Vec::from(message.data);
msg_with_header.append(&mut message_data);
match serde_rosmsg::from_slice::<nav_msgs::Odometry>(&msg_with_header) {
Ok(odom_msg) => {
println!("{:#?}", odom_msg);
...
I think I need rosrust for this- or roslibrust?