mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-06 15:38:53 +08:00
FlightTask StraightLine: set max vel/acc/dec if value is bigger
This commit is contained in:
committed by
Lorenz Meier
parent
c619009364
commit
090db6a115
@@ -187,22 +187,34 @@ void StraightLine::setOrigin(const matrix::Vector3f &origin)
|
||||
|
||||
void StraightLine::setSpeed(const float &speed)
|
||||
{
|
||||
if (speed > 0 && speed < getMaxVel()) {
|
||||
float vel_max = getMaxVel();
|
||||
|
||||
if (speed > 0 && speed < vel_max) {
|
||||
_desired_speed = speed;
|
||||
} else if (speed > vel_max) {
|
||||
_desired_speed = vel_max;
|
||||
}
|
||||
}
|
||||
|
||||
void StraightLine::setSpeedAtTarget(const float &speed_at_target)
|
||||
{
|
||||
if (speed_at_target > 0 && speed_at_target < getMaxVel()) {
|
||||
float vel_max = getMaxVel();
|
||||
|
||||
if (speed_at_target > 0 && speed_at_target < vel_max) {
|
||||
_desired_speed_at_target = speed_at_target;
|
||||
} else if (speed_at_target > vel_max) {
|
||||
_desired_speed_at_target = vel_max;
|
||||
}
|
||||
}
|
||||
|
||||
void StraightLine::setAcceleration(const float &acc)
|
||||
{
|
||||
if (acc > 0 && acc < getMaxAcc()) {
|
||||
float acc_max = getMaxVel();
|
||||
|
||||
if (acc > 0 && acc < acc_max) {
|
||||
_desired_acceleration = acc;
|
||||
} else if (acc > acc_max) {
|
||||
_desired_acceleration = acc_max;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,5 +222,7 @@ void StraightLine::setDeceleration(const float &dec)
|
||||
{
|
||||
if (dec > 0 && dec < DECELERATION_MAX) {
|
||||
_desired_deceleration = dec;
|
||||
} else if (dec > DECELERATION_MAX) {
|
||||
_desired_deceleration = DECELERATION_MAX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user