pflex_module_rs/
structs.rs1use crate::pflex::PFlexRobot;
2
3#[derive(Debug, Clone, PartialEq)]
5pub struct Waypoint {
6 pub id: i32,
7 pub x_mm: f64,
8 pub y_mm: f64,
9 pub z_mm: f64,
10 pub orientation_deg: f64,
11 pub rail_position_mm: Option<f64>,
12}
13
14impl Waypoint {
15 pub fn new(
16 id: i32,
17 x_mm: f64,
18 y_mm: f64,
19 z_mm: f64,
20 orientation_deg: f64,
21 rail_position_mm: Option<f64>,
22 ) -> Self {
23 Waypoint {
24 id,
25 x_mm,
26 y_mm,
27 z_mm,
28 orientation_deg,
29 rail_position_mm,
30 }
31 }
32
33 pub fn to_payload(&self) -> Vec<String> {
35 vec![
36 self.id.to_string(),
37 self.x_mm.to_string(),
38 self.y_mm.to_string(),
39 self.z_mm.to_string(),
40 self.orientation_deg.to_string(),
41 PFlexRobot::DEFAULT_EE_PITCH.to_string(),
42 PFlexRobot::DEFAULT_EE_ROLL.to_string(),
43 ]
44 }
45}
46
47#[derive(Debug, Clone, PartialEq)]
49pub struct MotionProfile {
50 pub id: i32,
51 pub max_speed_percent: f64, pub max_accel_percent: f64, pub max_decel_percent: f64, pub accel_ramp_seconds: f64, pub decel_ramp_seconds: f64, pub in_range: f64, pub straight_line: i32, }
59
60impl MotionProfile {
61 pub fn default(id: i32) -> Self {
62 MotionProfile {
63 id,
64 max_speed_percent: 50.0,
65 max_accel_percent: 50.0,
66 max_decel_percent: 50.0,
67 accel_ramp_seconds: 0.1,
68 decel_ramp_seconds: 0.1,
69 in_range: 10.0,
70 straight_line: 0,
71 }
72 }
73
74 pub fn to_payload(&self) -> Vec<String> {
76 vec![
77 self.id.to_string(),
78 self.max_speed_percent.to_string(),
79 "0".to_string(),
80 self.max_accel_percent.to_string(),
81 self.max_decel_percent.to_string(),
82 self.accel_ramp_seconds.to_string(),
83 self.decel_ramp_seconds.to_string(),
84 self.in_range.to_string(),
85 self.straight_line.to_string(),
86 ]
87 }
88}
89
90#[derive(Debug)]
92pub struct EndEffectorPosition {
93 pub yaw_mm: f64,
94 pub pitch_mm: f64,
95 pub roll_mm: f64,
96 pub x_mm: f64,
97 pub y_mm: f64,
98 pub z_mm: f64,
99}
100
101impl EndEffectorPosition {
102 pub fn to_payload(&self) -> Vec<String> {
104 vec![
105 self.x_mm.to_string(),
106 self.y_mm.to_string(),
107 self.z_mm.to_string(),
108 self.yaw_mm.to_string(),
109 self.pitch_mm.to_string(),
110 self.roll_mm.to_string(),
111 ]
112 }
113}