mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-01 23:11:37 +08:00
Trajectory - Add position lock-unlock logic and proper initialization from controller feedback
This commit is contained in:
@@ -214,7 +214,7 @@ void VelocitySmoothing::updateDurations(float T123)
|
||||
_T3 = T3;
|
||||
}
|
||||
|
||||
void VelocitySmoothing::integrate(float pos, float &vel_setpoint_smooth,
|
||||
void VelocitySmoothing::integrate(float &accel_setpoint_smooth, float &vel_setpoint_smooth,
|
||||
float &pos_setpoint_smooth)
|
||||
{
|
||||
/* Integrate the trajectory */
|
||||
@@ -238,14 +238,8 @@ void VelocitySmoothing::integrate(float pos, float &vel_setpoint_smooth,
|
||||
_accel = accel_new;
|
||||
_vel = vel_new;
|
||||
|
||||
/* Lock the position setpoint if the error is bigger than some value */
|
||||
float x_err = pos_new - pos;
|
||||
|
||||
if (fabsf(x_err) <= max_pos_err) {
|
||||
_pos = pos_new;
|
||||
} // else: keep last position
|
||||
|
||||
/* set output variables */
|
||||
accel_setpoint_smooth = _accel;
|
||||
vel_setpoint_smooth = _vel;
|
||||
pos_setpoint_smooth = _pos;
|
||||
}
|
||||
|
||||
@@ -77,11 +77,11 @@ public:
|
||||
|
||||
/**
|
||||
* Generate the trajectory (acceleration, velocity and position) by integrating the current jerk
|
||||
* @param pos Current vehicle's position (used for position error clamping)
|
||||
* @param acc_setpoint_smooth returned smoothed acceleration setpoint
|
||||
* @param vel_setpoint_smooth returned smoothed velocity setpoint
|
||||
* @param pos_setpoint_smooth returned smoothed position setpoint
|
||||
*/
|
||||
void integrate(float pos, float &vel_setpoint_smooth, float &pos_setpoint_smooth);
|
||||
void integrate(float &accel_setpoint_smooth, float &vel_setpoint_smooth, float &pos_setpoint_smooth);
|
||||
|
||||
/* Get / Set constraints (constraints can be updated at any time) */
|
||||
float getMaxJerk() const { return _max_jerk; }
|
||||
@@ -93,6 +93,9 @@ public:
|
||||
float getMaxVel() const { return _max_vel; }
|
||||
void setMaxVel(float max_vel) { _max_vel = max_vel; }
|
||||
|
||||
void setCurrentVelocity(const float vel) { _vel = vel; }
|
||||
void setCurrentPosition(const float pos) { _pos = pos; }
|
||||
|
||||
/**
|
||||
* Synchronize several trajectories to have the same total time. This is required to generate
|
||||
* straight lines.
|
||||
|
||||
Reference in New Issue
Block a user