robotics_signals/sensors/range.rs
1use cdds_derive::*;
2use cyclonedds_rs::*;
3use serde_derive::{Deserialize, Serialize};
4
5use crate::standard::Header;
6
7/// Single range reading from an active ranger that emits energy and reports
8/// one range reading that is valid along an arc at the distance measured.
9/// This message is not appropriate for laser scanners. See the LaserScan
10/// message if you are working with a laser scanner.
11///
12/// This message also can represent a fixed-distance (binary) ranger. This
13/// sensor will have min_range===max_range===distance of detection.
14/// These sensors follow REP 117 and will output -Inf if the object is detected
15/// and +Inf if the object is outside of the detection range.
16
17#[repr(C)]
18#[derive(Serialize, Deserialize, Topic)]
19pub struct Range {
20 pub header: Header,
21
22 pub radiation_type: RadiationType,
23
24 /// the size of the arc that the distance reading is
25 /// valid for [rad]
26 /// the object causing the range reading may have
27 /// been anywhere within -field_of_view/2 and
28 /// field_of_view/2 at the measured range.
29 /// 0 angle corresponds to the x-axis of the sensor.
30 pub field_of_view: f32,
31
32 /// minimum range value [m]
33 pub min_range: f32,
34
35 /// maximum range value [m]
36 pub max_range: f32,
37 /// range data [m]
38 /// (Note: values < range_min or > range_max should be discarded)
39 /// Fixed distance rangers only output -Inf or +Inf.
40 /// -Inf represents a detection within fixed distance.
41 /// (Detection too close to the sensor to quantify)
42 /// +Inf represents no detection within the fixed distance. (Object out of range)
43 pub range: f32,
44}
45
46#[repr(C)]
47#[derive(Serialize, Deserialize)]
48pub enum RadiationType {
49 Ultrasound = 0,
50 Infrared = 1,
51}