1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//! Shared sensor message types
//!
//! This module contains common sensor message types used across drivers and nodes.
//! Previously these were duplicated in each driver, now they are centralized here.
use crate::messages::Message;
use serde::{Deserialize, Serialize};
// ============================================================================
// Camera Types
// ============================================================================
/// RGB image message
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RgbImage {
pub timestamp: u64,
pub frame_id: u64,
pub width: u32,
pub height: u32,
pub encoding: String,
pub data: Vec<u8>,
}
impl Message for RgbImage {}
/// Depth image message
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DepthImage {
pub timestamp: u64,
pub frame_id: u64,
pub width: u32,
pub height: u32,
pub data: Vec<f32>,
}
impl Message for DepthImage {}
/// Camera info message
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CameraInfo {
pub timestamp: u64,
pub width: u32,
pub height: u32,
pub fps: f32,
}
impl Message for CameraInfo {}
// ============================================================================
// LiDAR Types
// ============================================================================
/// Laser scan message (2D LiDAR)
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LaserScan {
pub timestamp: u64,
pub scan_id: u64,
pub angle_min: f32,
pub angle_max: f32,
pub angle_increment: f32,
pub range_min: f32,
pub range_max: f32,
pub ranges: Vec<f32>,
pub intensities: Vec<f32>,
}
impl Message for LaserScan {}
// ============================================================================
// Odometry Types
// ============================================================================
/// Odometry message
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Odometry {
pub timestamp: u64,
pub x: f32,
pub y: f32,
pub theta: f32,
pub linear_vel: f32,
pub angular_vel: f32,
}
impl Message for Odometry {}
// ============================================================================
// IMU Types
// ============================================================================
/// IMU data message
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ImuData {
/// IMU sensor identifier
#[serde(default = "default_imu_id")]
pub imu_id: String,
pub timestamp: u64,
// Orientation (Euler angles in radians)
pub roll: f32,
pub pitch: f32,
pub yaw: f32,
// Angular velocity (rad/s)
pub angular_velocity_x: f32,
pub angular_velocity_y: f32,
pub angular_velocity_z: f32,
// Linear acceleration (m/s²)
pub linear_acceleration_x: f32,
pub linear_acceleration_y: f32,
pub linear_acceleration_z: f32,
}
fn default_imu_id() -> String {
"imu-0".to_string()
}
impl Message for ImuData {}