rclrs 0.7.0

A ROS 2 client library for developing robotics applications in Rust
Documentation
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
pub mod rmw {
    #[cfg(feature = "serde")]
    use serde::{Deserialize, Serialize};

    #[link(name = "action_msgs__rosidl_typesupport_c")]
    unsafe extern "C" {
        fn rosidl_typesupport_c__get_message_type_support_handle__action_msgs__msg__GoalInfo(
        ) -> *const std::ffi::c_void;
    }

    #[link(name = "action_msgs__rosidl_generator_c")]
    unsafe extern "C" {
        fn action_msgs__msg__GoalInfo__init(msg: *mut GoalInfo) -> bool;
        fn action_msgs__msg__GoalInfo__Sequence__init(
            seq: *mut rosidl_runtime_rs::Sequence<GoalInfo>,
            size: usize,
        ) -> bool;
        fn action_msgs__msg__GoalInfo__Sequence__fini(
            seq: *mut rosidl_runtime_rs::Sequence<GoalInfo>,
        );
        fn action_msgs__msg__GoalInfo__Sequence__copy(
            in_seq: &rosidl_runtime_rs::Sequence<GoalInfo>,
            out_seq: *mut rosidl_runtime_rs::Sequence<GoalInfo>,
        ) -> bool;
    }

    // Corresponds to action_msgs__msg__GoalInfo
    #[repr(C)]
    #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
    #[derive(Clone, Debug, PartialEq, PartialOrd)]
    pub struct GoalInfo {
        pub goal_id: crate::vendor::unique_identifier_msgs::msg::rmw::UUID,
        pub stamp: crate::vendor::builtin_interfaces::msg::rmw::Time,
    }

    impl Default for GoalInfo {
        fn default() -> Self {
            unsafe {
                let mut msg = std::mem::zeroed();
                if !action_msgs__msg__GoalInfo__init(&mut msg as *mut _) {
                    panic!("Call to action_msgs__msg__GoalInfo__init() failed");
                }
                msg
            }
        }
    }

    impl rosidl_runtime_rs::SequenceAlloc for GoalInfo {
        fn sequence_init(seq: &mut rosidl_runtime_rs::Sequence<Self>, size: usize) -> bool {
            // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized.
            unsafe { action_msgs__msg__GoalInfo__Sequence__init(seq as *mut _, size) }
        }
        fn sequence_fini(seq: &mut rosidl_runtime_rs::Sequence<Self>) {
            // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized.
            unsafe { action_msgs__msg__GoalInfo__Sequence__fini(seq as *mut _) }
        }
        fn sequence_copy(
            in_seq: &rosidl_runtime_rs::Sequence<Self>,
            out_seq: &mut rosidl_runtime_rs::Sequence<Self>,
        ) -> bool {
            // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized.
            unsafe { action_msgs__msg__GoalInfo__Sequence__copy(in_seq, out_seq as *mut _) }
        }
    }

    impl rosidl_runtime_rs::Message for GoalInfo {
        type RmwMsg = Self;
        fn into_rmw_message(
            msg_cow: std::borrow::Cow<'_, Self>,
        ) -> std::borrow::Cow<'_, Self::RmwMsg> {
            msg_cow
        }
        fn from_rmw_message(msg: Self::RmwMsg) -> Self {
            msg
        }
    }

    impl rosidl_runtime_rs::RmwMessage for GoalInfo
    where
        Self: Sized,
    {
        const TYPE_NAME: &'static str = "action_msgs/msg/GoalInfo";
        fn get_type_support() -> *const std::ffi::c_void {
            // SAFETY: No preconditions for this function.
            unsafe {
                rosidl_typesupport_c__get_message_type_support_handle__action_msgs__msg__GoalInfo()
            }
        }
    }

    #[link(name = "action_msgs__rosidl_typesupport_c")]
    unsafe extern "C" {
        fn rosidl_typesupport_c__get_message_type_support_handle__action_msgs__msg__GoalStatus(
        ) -> *const std::ffi::c_void;
    }

    #[link(name = "action_msgs__rosidl_generator_c")]
    unsafe extern "C" {
        fn action_msgs__msg__GoalStatus__init(msg: *mut GoalStatus) -> bool;
        fn action_msgs__msg__GoalStatus__Sequence__init(
            seq: *mut rosidl_runtime_rs::Sequence<GoalStatus>,
            size: usize,
        ) -> bool;
        fn action_msgs__msg__GoalStatus__Sequence__fini(
            seq: *mut rosidl_runtime_rs::Sequence<GoalStatus>,
        );
        fn action_msgs__msg__GoalStatus__Sequence__copy(
            in_seq: &rosidl_runtime_rs::Sequence<GoalStatus>,
            out_seq: *mut rosidl_runtime_rs::Sequence<GoalStatus>,
        ) -> bool;
    }

    // Corresponds to action_msgs__msg__GoalStatus
    #[repr(C)]
    #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
    #[derive(Clone, Debug, PartialEq, PartialOrd)]
    pub struct GoalStatus {
        pub goal_info: crate::vendor::action_msgs::msg::rmw::GoalInfo,
        pub status: i8,
    }

    impl GoalStatus {
        /// Indicates status has not been properly set.
        pub const STATUS_UNKNOWN: i8 = 0;
        /// The goal has been accepted and is awaiting execution.
        pub const STATUS_ACCEPTED: i8 = 1;
        /// The goal is currently being executed by the action server.
        pub const STATUS_EXECUTING: i8 = 2;
        /// The client has requested that the goal be canceled and the action server has
        /// accepted the cancel request.
        pub const STATUS_CANCELING: i8 = 3;
        /// The goal was achieved successfully by the action server.
        pub const STATUS_SUCCEEDED: i8 = 4;
        /// The goal was canceled after an external request from an action client.
        pub const STATUS_CANCELED: i8 = 5;
        /// The goal was terminated by the action server without an external request.
        pub const STATUS_ABORTED: i8 = 6;
    }

    impl Default for GoalStatus {
        fn default() -> Self {
            unsafe {
                let mut msg = std::mem::zeroed();
                if !action_msgs__msg__GoalStatus__init(&mut msg as *mut _) {
                    panic!("Call to action_msgs__msg__GoalStatus__init() failed");
                }
                msg
            }
        }
    }

    impl rosidl_runtime_rs::SequenceAlloc for GoalStatus {
        fn sequence_init(seq: &mut rosidl_runtime_rs::Sequence<Self>, size: usize) -> bool {
            // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized.
            unsafe { action_msgs__msg__GoalStatus__Sequence__init(seq as *mut _, size) }
        }
        fn sequence_fini(seq: &mut rosidl_runtime_rs::Sequence<Self>) {
            // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized.
            unsafe { action_msgs__msg__GoalStatus__Sequence__fini(seq as *mut _) }
        }
        fn sequence_copy(
            in_seq: &rosidl_runtime_rs::Sequence<Self>,
            out_seq: &mut rosidl_runtime_rs::Sequence<Self>,
        ) -> bool {
            // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized.
            unsafe { action_msgs__msg__GoalStatus__Sequence__copy(in_seq, out_seq as *mut _) }
        }
    }

    impl rosidl_runtime_rs::Message for GoalStatus {
        type RmwMsg = Self;
        fn into_rmw_message(
            msg_cow: std::borrow::Cow<'_, Self>,
        ) -> std::borrow::Cow<'_, Self::RmwMsg> {
            msg_cow
        }
        fn from_rmw_message(msg: Self::RmwMsg) -> Self {
            msg
        }
    }

    impl rosidl_runtime_rs::RmwMessage for GoalStatus
    where
        Self: Sized,
    {
        const TYPE_NAME: &'static str = "action_msgs/msg/GoalStatus";
        fn get_type_support() -> *const std::ffi::c_void {
            // SAFETY: No preconditions for this function.
            unsafe {
                rosidl_typesupport_c__get_message_type_support_handle__action_msgs__msg__GoalStatus(
                )
            }
        }
    }

    #[link(name = "action_msgs__rosidl_typesupport_c")]
    unsafe extern "C" {
        fn rosidl_typesupport_c__get_message_type_support_handle__action_msgs__msg__GoalStatusArray(
        ) -> *const std::ffi::c_void;
    }

    #[link(name = "action_msgs__rosidl_generator_c")]
    unsafe extern "C" {
        fn action_msgs__msg__GoalStatusArray__init(msg: *mut GoalStatusArray) -> bool;
        fn action_msgs__msg__GoalStatusArray__Sequence__init(
            seq: *mut rosidl_runtime_rs::Sequence<GoalStatusArray>,
            size: usize,
        ) -> bool;
        fn action_msgs__msg__GoalStatusArray__Sequence__fini(
            seq: *mut rosidl_runtime_rs::Sequence<GoalStatusArray>,
        );
        fn action_msgs__msg__GoalStatusArray__Sequence__copy(
            in_seq: &rosidl_runtime_rs::Sequence<GoalStatusArray>,
            out_seq: *mut rosidl_runtime_rs::Sequence<GoalStatusArray>,
        ) -> bool;
    }

    // Corresponds to action_msgs__msg__GoalStatusArray
    #[repr(C)]
    #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
    #[derive(Clone, Debug, PartialEq, PartialOrd)]
    pub struct GoalStatusArray {
        pub status_list:
            rosidl_runtime_rs::Sequence<crate::vendor::action_msgs::msg::rmw::GoalStatus>,
    }

    impl Default for GoalStatusArray {
        fn default() -> Self {
            unsafe {
                let mut msg = std::mem::zeroed();
                if !action_msgs__msg__GoalStatusArray__init(&mut msg as *mut _) {
                    panic!("Call to action_msgs__msg__GoalStatusArray__init() failed");
                }
                msg
            }
        }
    }

    impl rosidl_runtime_rs::SequenceAlloc for GoalStatusArray {
        fn sequence_init(seq: &mut rosidl_runtime_rs::Sequence<Self>, size: usize) -> bool {
            // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized.
            unsafe { action_msgs__msg__GoalStatusArray__Sequence__init(seq as *mut _, size) }
        }
        fn sequence_fini(seq: &mut rosidl_runtime_rs::Sequence<Self>) {
            // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized.
            unsafe { action_msgs__msg__GoalStatusArray__Sequence__fini(seq as *mut _) }
        }
        fn sequence_copy(
            in_seq: &rosidl_runtime_rs::Sequence<Self>,
            out_seq: &mut rosidl_runtime_rs::Sequence<Self>,
        ) -> bool {
            // SAFETY: This is safe since the pointer is guaranteed to be valid/initialized.
            unsafe { action_msgs__msg__GoalStatusArray__Sequence__copy(in_seq, out_seq as *mut _) }
        }
    }

    impl rosidl_runtime_rs::Message for GoalStatusArray {
        type RmwMsg = Self;
        fn into_rmw_message(
            msg_cow: std::borrow::Cow<'_, Self>,
        ) -> std::borrow::Cow<'_, Self::RmwMsg> {
            msg_cow
        }
        fn from_rmw_message(msg: Self::RmwMsg) -> Self {
            msg
        }
    }

    impl rosidl_runtime_rs::RmwMessage for GoalStatusArray
    where
        Self: Sized,
    {
        const TYPE_NAME: &'static str = "action_msgs/msg/GoalStatusArray";
        fn get_type_support() -> *const std::ffi::c_void {
            // SAFETY: No preconditions for this function.
            unsafe {
                rosidl_typesupport_c__get_message_type_support_handle__action_msgs__msg__GoalStatusArray()
            }
        }
    }
} // mod rmw

#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub struct GoalInfo {
    pub goal_id: crate::vendor::unique_identifier_msgs::msg::UUID,
    pub stamp: crate::vendor::builtin_interfaces::msg::Time,
}

impl Default for GoalInfo {
    fn default() -> Self {
        <Self as rosidl_runtime_rs::Message>::from_rmw_message(
            crate::vendor::action_msgs::msg::rmw::GoalInfo::default(),
        )
    }
}

impl rosidl_runtime_rs::Message for GoalInfo {
    type RmwMsg = crate::vendor::action_msgs::msg::rmw::GoalInfo;

    fn into_rmw_message(msg_cow: std::borrow::Cow<'_, Self>) -> std::borrow::Cow<'_, Self::RmwMsg> {
        match msg_cow {
            std::borrow::Cow::Owned(msg) => std::borrow::Cow::Owned(Self::RmwMsg {
                goal_id: crate::vendor::unique_identifier_msgs::msg::UUID::into_rmw_message(
                    std::borrow::Cow::Owned(msg.goal_id),
                )
                .into_owned(),
                stamp: crate::vendor::builtin_interfaces::msg::Time::into_rmw_message(
                    std::borrow::Cow::Owned(msg.stamp),
                )
                .into_owned(),
            }),
            std::borrow::Cow::Borrowed(msg) => std::borrow::Cow::Owned(Self::RmwMsg {
                goal_id: crate::vendor::unique_identifier_msgs::msg::UUID::into_rmw_message(
                    std::borrow::Cow::Borrowed(&msg.goal_id),
                )
                .into_owned(),
                stamp: crate::vendor::builtin_interfaces::msg::Time::into_rmw_message(
                    std::borrow::Cow::Borrowed(&msg.stamp),
                )
                .into_owned(),
            }),
        }
    }

    fn from_rmw_message(msg: Self::RmwMsg) -> Self {
        Self {
            goal_id: crate::vendor::unique_identifier_msgs::msg::UUID::from_rmw_message(
                msg.goal_id,
            ),
            stamp: crate::vendor::builtin_interfaces::msg::Time::from_rmw_message(msg.stamp),
        }
    }
}

#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub struct GoalStatus {
    pub goal_info: crate::vendor::action_msgs::msg::GoalInfo,
    pub status: i8,
}

impl GoalStatus {
    /// Indicates status has not been properly set.
    pub const STATUS_UNKNOWN: i8 = 0;
    /// The goal has been accepted and is awaiting execution.
    pub const STATUS_ACCEPTED: i8 = 1;
    /// The goal is currently being executed by the action server.
    pub const STATUS_EXECUTING: i8 = 2;
    /// The client has requested that the goal be canceled and the action server has
    /// accepted the cancel request.
    pub const STATUS_CANCELING: i8 = 3;
    /// The goal was achieved successfully by the action server.
    pub const STATUS_SUCCEEDED: i8 = 4;
    /// The goal was canceled after an external request from an action client.
    pub const STATUS_CANCELED: i8 = 5;
    /// The goal was terminated by the action server without an external request.
    pub const STATUS_ABORTED: i8 = 6;
}

impl Default for GoalStatus {
    fn default() -> Self {
        <Self as rosidl_runtime_rs::Message>::from_rmw_message(
            crate::vendor::action_msgs::msg::rmw::GoalStatus::default(),
        )
    }
}

impl rosidl_runtime_rs::Message for GoalStatus {
    type RmwMsg = crate::vendor::action_msgs::msg::rmw::GoalStatus;

    fn into_rmw_message(msg_cow: std::borrow::Cow<'_, Self>) -> std::borrow::Cow<'_, Self::RmwMsg> {
        match msg_cow {
            std::borrow::Cow::Owned(msg) => std::borrow::Cow::Owned(Self::RmwMsg {
                goal_info: crate::vendor::action_msgs::msg::GoalInfo::into_rmw_message(
                    std::borrow::Cow::Owned(msg.goal_info),
                )
                .into_owned(),
                status: msg.status,
            }),
            std::borrow::Cow::Borrowed(msg) => std::borrow::Cow::Owned(Self::RmwMsg {
                goal_info: crate::vendor::action_msgs::msg::GoalInfo::into_rmw_message(
                    std::borrow::Cow::Borrowed(&msg.goal_info),
                )
                .into_owned(),
                status: msg.status,
            }),
        }
    }

    fn from_rmw_message(msg: Self::RmwMsg) -> Self {
        Self {
            goal_info: crate::vendor::action_msgs::msg::GoalInfo::from_rmw_message(msg.goal_info),
            status: msg.status,
        }
    }
}

#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub struct GoalStatusArray {
    pub status_list: Vec<crate::vendor::action_msgs::msg::GoalStatus>,
}

impl Default for GoalStatusArray {
    fn default() -> Self {
        <Self as rosidl_runtime_rs::Message>::from_rmw_message(
            crate::vendor::action_msgs::msg::rmw::GoalStatusArray::default(),
        )
    }
}

impl rosidl_runtime_rs::Message for GoalStatusArray {
    type RmwMsg = crate::vendor::action_msgs::msg::rmw::GoalStatusArray;

    fn into_rmw_message(msg_cow: std::borrow::Cow<'_, Self>) -> std::borrow::Cow<'_, Self::RmwMsg> {
        match msg_cow {
            std::borrow::Cow::Owned(msg) => std::borrow::Cow::Owned(Self::RmwMsg {
                status_list: msg
                    .status_list
                    .into_iter()
                    .map(|elem| {
                        crate::vendor::action_msgs::msg::GoalStatus::into_rmw_message(
                            std::borrow::Cow::Owned(elem),
                        )
                        .into_owned()
                    })
                    .collect(),
            }),
            std::borrow::Cow::Borrowed(msg) => std::borrow::Cow::Owned(Self::RmwMsg {
                status_list: msg
                    .status_list
                    .iter()
                    .map(|elem| {
                        crate::vendor::action_msgs::msg::GoalStatus::into_rmw_message(
                            std::borrow::Cow::Borrowed(elem),
                        )
                        .into_owned()
                    })
                    .collect(),
            }),
        }
    }

    fn from_rmw_message(msg: Self::RmwMsg) -> Self {
        Self {
            status_list: msg
                .status_list
                .into_iter()
                .map(crate::vendor::action_msgs::msg::GoalStatus::from_rmw_message)
                .collect(),
        }
    }
}