48 const float v_start,
const float v_target,
const float dist,
49 const float x_start = 0,
const float t_start = 0) {
50 reset(j_max, a_max, v_max, v_start, v_target, dist, x_start, t_start);
70 void reset(
const float j_max,
const float a_max,
const float v_max,
71 const float v_start,
const float v_target,
const float dist,
72 const float x_start = 0,
const float t_start = 0) {
74 auto v_end = v_target;
77 j_max, a_max, v_start,
v_end);
78 if (std::abs(dist) < std::abs(dist_min)) {
79 ctrl_logd <<
"vs -> ve != vt" << std::endl;
85 auto v_sat = dist > 0 ? std::max({v_start, v_max,
v_end})
86 : std::min({v_start, -v_max,
v_end});
88 ac.
reset(j_max, a_max, v_start, v_sat);
92 if (std::abs(dist) < std::abs(d_sum)) {
93 ctrl_logd <<
"vs -> vr -> ve" << std::endl;
96 j_max, a_max, v_start,
v_end, dist);
98 v_sat = dist > 0 ? std::max({v_start, v_rm,
v_end})
99 : std::min({v_start, v_rm,
v_end});
100 ac.
reset(j_max, a_max, v_start, v_sat);
104 if (std::abs(v_sat) < std::numeric_limits<float>::epsilon()) v_sat = 1;
115 const auto e = 0.01f;
116 bool show_info =
false;
123 if (std::abs(v_start -
v_end) > e + std::abs(v_start - v_target)) {
124 std::cerr <<
"Error: Velocity Target!" << std::endl;
128 if (std::abs(v_sat) >
129 e + std::max({v_max, std::abs(v_start), std::abs(
v_end)})) {
130 std::cerr <<
"Error: Velocity Saturation!" << std::endl;
135 ctrl_loge <<
"Error: Time Point Relationship!" << std::endl;
141 <<
"\tj_max: " << j_max <<
"\ta_max: " << a_max
142 <<
"\tv_max: " << v_max <<
"\tv_start: " << v_start
143 <<
"\tv_target: " << v_target <<
"\tdist: " << dist
145 ctrl_loge <<
"ad.reset(" << j_max <<
", " << a_max <<
", " << v_max
146 <<
", " << v_start <<
", " << v_target <<
", " << dist <<
");"
150 <<
"\tt0: " <<
t0 <<
"\tt1: " <<
t1 <<
"\tt2: " <<
t2
151 <<
"\tt3: " <<
t3 << std::endl;
154 <<
"\tx2: " <<
x0 + (dist -
dc.
x_end()) <<
"\tx3: " <<
x3
157 <<
"\tv0: " << v_start <<
"\tv1: " <<
v(
t1) <<
"\tv2: " <<
v(
t2)
158 <<
"\tv3: " <<
v_end << std::endl;
167 float j(
const float t)
const {
178 float a(
const float t)
const {
189 float v(
const float t)
const {
200 float x(
const float t)
const {
252 void printCsv(
const float t_interval = 1e-3f)
const {
258 void printCsv(std::ostream& os,
const float t_interval = 1e-3f)
const {
259 for (
float t =
t0; t <
t_end(); t += t_interval)
260 os << t <<
"," <<
j(t) <<
"," <<
a(t) <<
"," <<
v(t) <<
"," <<
x(t)
267 os <<
"AccelDesigner:";
268 os <<
"\td: " << obj.
x3 - obj.
x0;
269 os <<
"\tvs: " << obj.
ac.
v(0);
270 os <<
"\tvm: " << obj.
ac.
v_end();
271 os <<
"\tve: " << obj.
dc.
v_end();
272 os <<
"\tt0: " << obj.
t0;
273 os <<
"\tt1: " << obj.
t1;
274 os <<
"\tt2: " << obj.
t2;
275 os <<
"\tt3: " << obj.
t3;
躍度0次、加速度1次、速度2次、位置3次関数により、滑らかな加速を実現する
#define ctrl_logd
Definition: accel_curve.h:48
#define ctrl_loge
Definition: accel_curve.h:28
走行距離拘束のない曲線加速の軌道を生成するクラス
Definition: accel_curve.h:64
float a(const float t) const
任意の時刻 t [s] における加速度 a [m/s/s] を返す関数
Definition: accel_curve.h:149
float t_2() const
等加速度直線運動の終了時刻 [s]
Definition: accel_curve.h:218
static float calcReachableVelocityMax(const float j_max, const float a_max, const float vs, const float ve, const float d)
走行距離の拘束から達しうる最大速度を算出する関数
Definition: accel_curve.h:316
float t_3() const
曲線加速の終了時刻 [s]
Definition: accel_curve.h:222
float t_1() const
等加速度直線運動の開始時刻 [s]
Definition: accel_curve.h:214
float x_end() const
終点位置 [m]
Definition: accel_curve.h:206
float x(const float t) const
任意の時刻 t [s] における位置 x [m] を返す関数
Definition: accel_curve.h:183
void reset(const float j_max, const float a_max, const float v_start, const float v_end)
引数の拘束条件から曲線を生成する関数
Definition: accel_curve.h:92
float t_end() const
終点時刻 [s]
Definition: accel_curve.h:198
float j(const float t) const
任意の時刻 t [s] における躍度 j [m/s/s/s] を返す関数
Definition: accel_curve.h:132
float v(const float t) const
任意の時刻 t [s] における速度 v [m/s] を返す関数
Definition: accel_curve.h:166
static float calcReachableVelocityEnd(const float j_max, const float a_max, const float vs, const float vt, const float d)
走行距離の拘束から達しうる終点速度を算出する関数
Definition: accel_curve.h:263
float v_end() const
終点速度 [m/s]
Definition: accel_curve.h:202
float t_0() const
曲線加速の開始時刻 [s]
Definition: accel_curve.h:210
static float calcDistanceFromVelocityStartToEnd(const float j_max, const float a_max, const float v_start, const float v_end)
速度差の拘束から達しうる変位を算出する関数
Definition: accel_curve.h:345
拘束条件を満たす曲線加減速の軌道を生成するクラス
Definition: accel_designer.h:33
float v_end() const
終点速度 [m/s]
Definition: accel_designer.h:213
AccelCurve dc
曲線減速用オブジェクト
Definition: accel_designer.h:283
float j(const float t) const
任意の時刻 t [s] における躍度 j [m/s/s/s] を返す関数
Definition: accel_designer.h:167
float t3
境界点の時刻 [s]
Definition: accel_designer.h:280
float t_2() const
曲線減速の開始時刻 [s]
Definition: accel_designer.h:229
float a(const float t) const
任意の時刻 t [s] における加速度 a [m/s/s] を返す関数
Definition: accel_designer.h:178
float t_end() const
終点時刻 [s]
Definition: accel_designer.h:209
AccelDesigner()
とりあえずインスタンス化を行う空のコンストラクタ
Definition: accel_designer.h:56
float t_3() const
曲線減速の終了時刻 [s]
Definition: accel_designer.h:233
float x3
境界点の位置 [m]
Definition: accel_designer.h:281
friend std::ostream & operator<<(std::ostream &os, const AccelDesigner &obj)
情報の表示
Definition: accel_designer.h:266
float x_end() const
終点位置 [m]
Definition: accel_designer.h:217
void printCsv(const float t_interval=1e-3f) const
stdout に軌道のcsvを出力する関数。
Definition: accel_designer.h:252
float x(const float t) const
任意の時刻 t [s] における位置 x [m] を返す関数
Definition: accel_designer.h:200
float t0
Definition: accel_designer.h:280
float t_1() const
最高速度に達する時刻 [s]
Definition: accel_designer.h:225
void printCsv(std::ostream &os, const float t_interval=1e-3f) const
std::ostream に軌道のcsvを出力する関数。
Definition: accel_designer.h:258
const std::array< float, 8 > getTimeStamps() const
曲線加速の境界のタイムスタンプを取得
Definition: accel_designer.h:237
AccelDesigner(const float j_max, const float a_max, const float v_max, const float v_start, const float v_target, const float dist, const float x_start=0, const float t_start=0)
初期化付きコンストラクタ
Definition: accel_designer.h:47
float t_0() const
曲線加速の開始時刻 [s]
Definition: accel_designer.h:221
float x0
Definition: accel_designer.h:281
AccelCurve ac
曲線加速用オブジェクト
Definition: accel_designer.h:282
float t2
Definition: accel_designer.h:280
float t1
Definition: accel_designer.h:280
float v(const float t) const
任意の時刻 t [s] における速度 v [m/s] を返す関数
Definition: accel_designer.h:189
void reset(const float j_max, const float a_max, const float v_max, const float v_start, const float v_target, const float dist, const float x_start=0, const float t_start=0)
引数の拘束条件から曲線を生成する関数
Definition: accel_designer.h:70
制御関係の名前空間
Definition: accel_curve.h:54