1 //! polynomial trajectory
5 /// cubic polynomial trajectory
8 /// coefficients of position
10 /// coefficients of velocity
12 /// coefficients of acceleration
26 fn a_polytraj3_pos(ctx: *const polytraj3, dt: float) -> float;
27 fn a_polytraj3_vel(ctx: *const polytraj3, dt: float) -> float;
28 fn a_polytraj3_acc(ctx: *const polytraj3, dt: float) -> float;
32 /// initialize for cubic polynomial trajectory
33 pub fn new(t0: float, t1: float, q0: float, q1: float, v0: float, v1: float) -> Self {
34 let mut ctx: Self = Self {
39 unsafe { a_polytraj3_gen(&mut ctx, t0, t1, q0, q1, v0, v1) };
43 /// generate for cubic polynomial trajectory
53 unsafe { a_polytraj3_gen(self, t0, t1, q0, q1, v0, v1) };
57 /// calculate for cubic polynomial trajectory position
58 pub fn pos(&mut self, dt: float) -> float {
59 unsafe { a_polytraj3_pos(self, dt) }
62 /// calculate for cubic polynomial trajectory velocity
63 pub fn vel(&mut self, dt: float) -> float {
64 unsafe { a_polytraj3_vel(self, dt) }
67 /// calculate for cubic polynomial trajectory acceleration
68 pub fn acc(&mut self, dt: float) -> float {
69 unsafe { a_polytraj3_acc(self, dt) }
78 let mut a = crate::polytraj::polytraj3::new(0.0, 1.0, 0.0, 1.0, 0.0, 1.0);
82 std::println!("[{}, {}, {}]", pos, vel, acc);
86 /// quintic polynomial trajectory
88 pub struct polytraj5 {
89 /// coefficients of position
91 /// coefficients of velocity
93 /// coefficients of acceleration
109 fn a_polytraj5_pos(ctx: *const polytraj5, dt: float) -> float;
110 fn a_polytraj5_vel(ctx: *const polytraj5, dt: float) -> float;
111 fn a_polytraj5_acc(ctx: *const polytraj5, dt: float) -> float;
115 /// initialize for quintic polynomial trajectory
116 #[allow(clippy::too_many_arguments)]
127 let mut ctx: Self = Self {
132 unsafe { a_polytraj5_gen(&mut ctx, t0, t1, q0, q1, v0, v1, a0, a1) };
136 /// generate for quintic polynomial trajectory
137 #[allow(clippy::too_many_arguments)]
149 unsafe { a_polytraj5_gen(self, t0, t1, q0, q1, v0, v1, a0, a1) };
153 /// calculate for quintic polynomial trajectory position
154 pub fn pos(&mut self, dt: float) -> float {
155 unsafe { a_polytraj5_pos(self, dt) }
158 /// calculate for quintic polynomial trajectory velocity
159 pub fn vel(&mut self, dt: float) -> float {
160 unsafe { a_polytraj5_vel(self, dt) }
163 /// calculate for quintic polynomial trajectory acceleration
164 pub fn acc(&mut self, dt: float) -> float {
165 unsafe { a_polytraj5_acc(self, dt) }
174 let mut a = crate::polytraj::polytraj5::new(0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0);
178 std::println!("[{}, {}, {}]", pos, vel, acc);
182 /// hepta polynomial trajectory
184 pub struct polytraj7 {
185 /// coefficients of position
187 /// coefficients of velocity
189 /// coefficients of acceleration
191 /// coefficients of jerk
209 fn a_polytraj7_pos(ctx: *const polytraj7, dt: float) -> float;
210 fn a_polytraj7_vel(ctx: *const polytraj7, dt: float) -> float;
211 fn a_polytraj7_acc(ctx: *const polytraj7, dt: float) -> float;
212 fn a_polytraj7_jer(ctx: *const polytraj7, dt: float) -> float;
216 /// initialize for hepta polynomial trajectory
217 #[allow(clippy::too_many_arguments)]
230 let mut ctx: Self = Self {
236 unsafe { a_polytraj7_gen(&mut ctx, t0, t1, q0, q1, v0, v1, a0, a1, j0, j1) };
240 /// generate for hepta polynomial trajectory
241 #[allow(clippy::too_many_arguments)]
255 unsafe { a_polytraj7_gen(self, t0, t1, q0, q1, v0, v1, a0, a1, j0, j1) };
259 /// calculate for hepta polynomial trajectory position
260 pub fn pos(&mut self, dt: float) -> float {
261 unsafe { a_polytraj7_pos(self, dt) }
264 /// calculate for hepta polynomial trajectory velocity
265 pub fn vel(&mut self, dt: float) -> float {
266 unsafe { a_polytraj7_vel(self, dt) }
269 /// calculate for hepta polynomial trajectory acceleration
270 pub fn acc(&mut self, dt: float) -> float {
271 unsafe { a_polytraj7_acc(self, dt) }
274 /// calculate for hepta polynomial trajectory jerk
275 pub fn jer(&mut self, dt: float) -> float {
276 unsafe { a_polytraj7_jer(self, dt) }
286 crate::polytraj::polytraj7::new(0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0);
291 std::println!("[{}, {}, {}, {}]", pos, vel, acc, jer);