3 @brief cubic polynomial trajectory
4 @details Trajectory Planning for Automatic Machines and Robots
7 #ifndef LIBA_TRAJPOLY3_H
8 #define LIBA_TRAJPOLY3_H
14 @addtogroup A_TRAJPOLY3 cubic polynomial trajectory
18 typedef struct a_trajpoly3 a_trajpoly3
;
20 #if !defined A_TRAJPOLY3
22 #endif /* A_TRAJPOLY3 */
23 #if defined(__cplusplus)
25 #endif /* __cplusplus */
28 @brief generate for cubic polynomial trajectory
30 \left\{\begin{array}{l}
35 c_{2}=\cfrac{\left(-2\,v_{0}-v_{1}\right)\,t+3\,p}{t^2}\\
36 c_{3}=\cfrac{\left(v_{0}+v_{1}\right)\,t-2\,p}{t^3}
39 @param[in,out] ctx points to an instance of cubic polynomial trajectory
40 @param[in] ts difference between final time and initial time
41 @param[in] p0 initial position
42 @param[in] p1 final position
43 @param[in] v0 initial velocity
44 @param[in] v1 final velocity
46 A_EXTERN
void a_trajpoly3_gen(a_trajpoly3
*ctx
, a_float ts
,
47 a_float p0
, a_float p1
,
48 a_float v0
, a_float v1
);
49 A_EXTERN
void a_trajpoly3_gen0(a_trajpoly3
*ctx
, a_float ts
,
50 a_float p0
, a_float p1
,
51 a_float v0
, a_float v1
);
52 #if defined(A_TRAJPOLY3) && (A_TRAJPOLY3 + 0 > 1)
53 A_EXTERN
void a_trajpoly3_gen1(a_trajpoly3
*ctx
);
54 #endif /* A_TRAJPOLY3 */
55 #if defined(A_TRAJPOLY3) && (A_TRAJPOLY3 + 0 > 2)
56 A_EXTERN
void a_trajpoly3_gen2(a_trajpoly3
*ctx
);
57 #endif /* A_TRAJPOLY3 */
60 @brief calculate position for cubic polynomial trajectory
63 p(t)=c_{0}+c_{1}\left(t-t_{0}\right)+c_{2}\left(t-t_{0}\right)^{2}+c_{3}\left(t-t_{0}\right)^{3} \\
66 @param[in] ctx points to an instance of cubic polynomial trajectory
67 @param[in] dt difference between current time and initial time
68 @return position output
70 A_EXTERN a_float
a_trajpoly3_pos(a_trajpoly3
const *ctx
, a_float dt
);
72 #if defined(A_TRAJPOLY3) && (A_TRAJPOLY3 + 0 > 1)
74 @brief calculate velocity for cubic polynomial trajectory
77 \dot{p}(t)=c_{1}+2 c_{2}\left(t-t_{0}\right)+3 c_{3}\left(t-t_{0}\right)^{2} \\
80 @param[in] ctx points to an instance of cubic polynomial trajectory
81 @param[in] dt difference between current time and initial time
82 @return velocity output
84 A_EXTERN a_float
a_trajpoly3_vel(a_trajpoly3
const *ctx
, a_float dt
);
85 #endif /* A_TRAJPOLY3 */
87 #if defined(A_TRAJPOLY3) && (A_TRAJPOLY3 + 0 > 2)
89 @brief calculate acceleration for cubic polynomial trajectory
92 \ddot{p}(t)=2 c_{2}+6 c_{3}\left(t-t_{0}\right)
95 @param[in] ctx points to an instance of cubic polynomial trajectory
96 @param[in] dt difference between current time and initial time
97 @return acceleration output
99 A_EXTERN a_float
a_trajpoly3_acc(a_trajpoly3
const *ctx
, a_float dt
);
100 #endif /* A_TRAJPOLY3 */
102 #if defined(__cplusplus)
106 typedef struct a_trajpoly3 trajpoly3
;
108 #endif /* __cplusplus */
111 @brief instance structure for cubic polynomial trajectory
114 p(t)=c_{0}+c_{1}\left(t-t_{0}\right)+c_{2}\left(t-t_{0}\right)^{2}+c_{3}\left(t-t_{0}\right)^{3} \\
115 \dot{p}(t)=c_{1}+2 c_{2}\left(t-t_{0}\right)+3 c_{3}\left(t-t_{0}\right)^{2} \\
116 \ddot{p}(t)=2 c_{2}+6 c_{3}\left(t-t_{0}\right)
122 a_float p
[4]; //!< coefficients of position
123 #if defined(A_TRAJPOLY3) && (A_TRAJPOLY3 + 0 > 1)
124 a_float v
[3]; //!< coefficients of velocity
125 #endif /* A_TRAJPOLY3 */
126 #if defined(A_TRAJPOLY3) && (A_TRAJPOLY3 + 0 > 2)
127 a_float a
[2]; //!< coefficients of acceleration
128 #endif /* A_TRAJPOLY3 */
129 #if defined(__cplusplus)
130 A_INLINE
void gen(a_float ts
, a_float p0
, a_float p1
,
131 a_float v0
= 0, a_float v1
= 0)
133 a_trajpoly3_gen(this, ts
, p0
, p1
, v0
, v1
);
135 A_INLINE
void gen0(a_float ts
, a_float p0
, a_float p1
,
136 a_float v0
= 0, a_float v1
= 0)
138 a_trajpoly3_gen0(this, ts
, p0
, p1
, v0
, v1
);
140 A_INLINE a_float
pos(a_float dt
) const
142 return a_trajpoly3_pos(this, dt
);
144 #if defined(A_TRAJPOLY3) && (A_TRAJPOLY3 + 0 > 1)
145 A_INLINE
void gen1() { a_trajpoly3_gen1(this); }
146 A_INLINE a_float
vel(a_float dt
) const
148 return a_trajpoly3_vel(this, dt
);
150 #endif /* A_TRAJPOLY3 */
151 #if defined(A_TRAJPOLY3) && (A_TRAJPOLY3 + 0 > 2)
152 A_INLINE
void gen2() { a_trajpoly3_gen2(this); }
153 A_INLINE a_float
acc(a_float dt
) const
155 return a_trajpoly3_acc(this, dt
);
157 #endif /* A_TRAJPOLY3 */
158 #endif /* __cplusplus */
161 /*! @} A_TRAJPOLY3 */
163 #endif /* a/trajpoly3.h */