mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-04 13:15:08 +08:00
VelocitySmoothing - Get rid of math.h, math.cpp and px4_defines dependencies
This commit is contained in:
@@ -35,8 +35,6 @@
|
|||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <math.h>
|
|
||||||
#include <px4_defines.h>
|
|
||||||
|
|
||||||
#include <mathlib/mathlib.h>
|
#include <mathlib/mathlib.h>
|
||||||
|
|
||||||
@@ -210,22 +208,22 @@ void VelocitySmoothing::updateDurations(float T123)
|
|||||||
_max_jerk_T1 = (_vel_sp - _vel > 0.f) ? _max_jerk : -_max_jerk;
|
_max_jerk_T1 = (_vel_sp - _vel > 0.f) ? _max_jerk : -_max_jerk;
|
||||||
|
|
||||||
// compute increasing acceleration time
|
// compute increasing acceleration time
|
||||||
if (PX4_ISFINITE(T123)) {
|
if (T123 < 0.f) {
|
||||||
T1 = computeT1(T123, _accel, _vel, _vel_sp, _max_jerk_T1);
|
T1 = computeT1(_accel, _vel, _vel_sp, _max_jerk_T1);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
T1 = computeT1(_accel, _vel, _vel_sp, _max_jerk_T1);
|
T1 = computeT1(T123, _accel, _vel, _vel_sp, _max_jerk_T1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute decreasing acceleration time
|
// compute decreasing acceleration time
|
||||||
T3 = computeT3(T1, _accel, _max_jerk_T1);
|
T3 = computeT3(T1, _accel, _max_jerk_T1);
|
||||||
|
|
||||||
// compute constant acceleration time
|
// compute constant acceleration time
|
||||||
if (PX4_ISFINITE(T123)) {
|
if (T123 < 0.f) {
|
||||||
T2 = computeT2(T123, T1, T3);
|
T2 = computeT2(T1, T3, _accel, _vel, _vel_sp, _max_jerk_T1);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
T2 = computeT2(T1, T3, _accel, _vel, _vel_sp, _max_jerk_T1);
|
T2 = computeT2(T123, T1, T3);
|
||||||
}
|
}
|
||||||
|
|
||||||
_T1 = T1;
|
_T1 = T1;
|
||||||
|
|||||||
@@ -33,8 +33,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <matrix/matrix/math.hpp>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class VelocitySmoothing
|
* @class VelocitySmoothing
|
||||||
*
|
*
|
||||||
@@ -115,6 +113,9 @@ public:
|
|||||||
static void timeSynchronization(VelocitySmoothing *traj, int n_traj);
|
static void timeSynchronization(VelocitySmoothing *traj, int n_traj);
|
||||||
|
|
||||||
float getTotalTime() const { return _T1 + _T2 + _T3; }
|
float getTotalTime() const { return _T1 + _T2 + _T3; }
|
||||||
|
float getT1() const { return _T1; }
|
||||||
|
float getT2() const { return _T2; }
|
||||||
|
float getT3() const { return _T3; }
|
||||||
float getVelSp() const { return _vel_sp; }
|
float getVelSp() const { return _vel_sp; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -124,7 +125,7 @@ private:
|
|||||||
* @param T123 optional parameter. If set, the total trajectory time will be T123, if not,
|
* @param T123 optional parameter. If set, the total trajectory time will be T123, if not,
|
||||||
* the algorithm optimizes for time.
|
* the algorithm optimizes for time.
|
||||||
*/
|
*/
|
||||||
void updateDurations(float T123 = NAN);
|
void updateDurations(float T123 = -1.f);
|
||||||
/**
|
/**
|
||||||
* Compute increasing acceleration time
|
* Compute increasing acceleration time
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user