ros2_interfaces_rolling/wiimote_msgs/msg/
state.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4pub struct State {
5    pub header: crate::std_msgs::msg::Header,
6    pub angular_velocity_zeroed: crate::geometry_msgs::msg::Vector3,
7    pub angular_velocity_raw: crate::geometry_msgs::msg::Vector3,
8    pub angular_velocity_covariance: [f64; 9],
9    pub linear_acceleration_zeroed: crate::geometry_msgs::msg::Vector3,
10    pub linear_acceleration_raw: crate::geometry_msgs::msg::Vector3,
11    pub linear_acceleration_covariance: [f64; 9],
12    pub nunchuk_acceleration_zeroed: crate::geometry_msgs::msg::Vector3,
13    pub nunchuk_acceleration_raw: crate::geometry_msgs::msg::Vector3,
14    pub nunchuk_joystick_zeroed: [f32; 2],
15    pub nunchuk_joystick_raw: [f32; 2],
16    pub buttons: [bool; 11],
17    pub nunchuk_buttons: [bool; 2],
18    pub leds: [bool; 4],
19    pub rumble: bool,
20    pub ir_tracking: Vec<crate::wiimote_msgs::msg::IrSourceInfo>,
21    pub raw_battery: f32,
22    pub percent_battery: f32,
23    pub zeroing_time: crate::builtin_interfaces::msg::Time,
24    pub errors: u64,
25}
26
27impl State {
28    pub const INVALID: i8 = -1;
29    pub const INVALID_FLOAT: f32 = -1.0;
30    pub const MSG_BTN_1: i8 = 0;
31    pub const MSG_BTN_2: i8 = 1;
32    pub const MSG_BTN_A: i8 = 2;
33    pub const MSG_BTN_B: i8 = 3;
34    pub const MSG_BTN_PLUS: i8 = 4;
35    pub const MSG_BTN_MINUS: i8 = 5;
36    pub const MSG_BTN_LEFT: i8 = 6;
37    pub const MSG_BTN_RIGHT: i8 = 7;
38    pub const MSG_BTN_UP: i8 = 8;
39    pub const MSG_BTN_DOWN: i8 = 9;
40    pub const MSG_BTN_HOME: i8 = 10;
41    pub const MSG_BTN_Z: i8 = 0;
42    pub const MSG_BTN_C: i8 = 1;
43    pub const MSG_CLASSIC_BTN_X: i8 = 0;
44    pub const MSG_CLASSIC_BTN_Y: i8 = 1;
45    pub const MSG_CLASSIC_BTN_A: i8 = 2;
46    pub const MSG_CLASSIC_BTN_B: i8 = 3;
47    pub const MSG_CLASSIC_BTN_PLUS: i8 = 4;
48    pub const MSG_CLASSIC_BTN_MINUS: i8 = 5;
49    pub const MSG_CLASSIC_BTN_LEFT: i8 = 6;
50    pub const MSG_CLASSIC_BTN_RIGHT: i8 = 7;
51    pub const MSG_CLASSIC_BTN_UP: i8 = 8;
52    pub const MSG_CLASSIC_BTN_DOWN: i8 = 9;
53    pub const MSG_CLASSIC_BTN_HOME: i8 = 10;
54    pub const MSG_CLASSIC_BTN_L: i8 = 11;
55    pub const MSG_CLASSIC_BTN_R: i8 = 12;
56    pub const MSG_CLASSIC_BTN_ZL: i8 = 13;
57    pub const MSG_CLASSIC_BTN_ZR: i8 = 14;
58}
59
60impl Default for State {
61    fn default() -> Self {
62        State {
63            header: crate::std_msgs::msg::Header::default(),
64            angular_velocity_zeroed: crate::geometry_msgs::msg::Vector3::default(),
65            angular_velocity_raw: crate::geometry_msgs::msg::Vector3::default(),
66            angular_velocity_covariance: [0.0; 9],
67            linear_acceleration_zeroed: crate::geometry_msgs::msg::Vector3::default(),
68            linear_acceleration_raw: crate::geometry_msgs::msg::Vector3::default(),
69            linear_acceleration_covariance: [0.0; 9],
70            nunchuk_acceleration_zeroed: crate::geometry_msgs::msg::Vector3::default(),
71            nunchuk_acceleration_raw: crate::geometry_msgs::msg::Vector3::default(),
72            nunchuk_joystick_zeroed: [0.0; 2],
73            nunchuk_joystick_raw: [0.0; 2],
74            buttons: [false; 11],
75            nunchuk_buttons: [false; 2],
76            leds: [false; 4],
77            rumble: false,
78            ir_tracking: Vec::new(),
79            raw_battery: 0.0,
80            percent_battery: 0.0,
81            zeroing_time: crate::builtin_interfaces::msg::Time::default(),
82            errors: 0,
83        }
84    }
85}
86
87impl ros2_client::Message for State {}