mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
FlightTaskAutoMapper: move update() into FlightTaskAutoLineSmooth
This commit is contained in:
+64
@@ -110,6 +110,70 @@ void FlightTaskAutoLineSmoothVel::_ekfResetHandlerHeading(float delta_psi)
|
|||||||
_yaw_sp_prev += delta_psi;
|
_yaw_sp_prev += delta_psi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FlightTaskAutoLineSmoothVel::update()
|
||||||
|
{
|
||||||
|
bool ret = FlightTaskAuto::update();
|
||||||
|
// always reset constraints because they might change depending on the type
|
||||||
|
_setDefaultConstraints();
|
||||||
|
|
||||||
|
// The only time a thrust set-point is sent out is during
|
||||||
|
// idle. Hence, reset thrust set-point to NAN in case the
|
||||||
|
// vehicle exits idle.
|
||||||
|
|
||||||
|
if (_type_previous == WaypointType::idle) {
|
||||||
|
_acceleration_setpoint.setNaN();
|
||||||
|
}
|
||||||
|
|
||||||
|
// during mission and reposition, raise the landing gears but only
|
||||||
|
// if altitude is high enough
|
||||||
|
if (_highEnoughForLandingGear()) {
|
||||||
|
_gear.landing_gear = landing_gear_s::GEAR_UP;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (_type) {
|
||||||
|
case WaypointType::idle:
|
||||||
|
_prepareIdleSetpoints();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WaypointType::land:
|
||||||
|
_prepareLandSetpoints();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WaypointType::loiter:
|
||||||
|
|
||||||
|
/* fallthrought */
|
||||||
|
case WaypointType::position:
|
||||||
|
_preparePositionSetpoints();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WaypointType::takeoff:
|
||||||
|
_prepareTakeoffSetpoints();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WaypointType::velocity:
|
||||||
|
_prepareVelocitySetpoints();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
_preparePositionSetpoints();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_param_com_obs_avoid.get()) {
|
||||||
|
_obstacle_avoidance.updateAvoidanceDesiredSetpoints(_position_setpoint, _velocity_setpoint, (int)_type);
|
||||||
|
_obstacle_avoidance.injectAvoidanceSetpoints(_position_setpoint, _velocity_setpoint, _yaw_setpoint,
|
||||||
|
_yawspeed_setpoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_generateSetpoints();
|
||||||
|
|
||||||
|
// update previous type
|
||||||
|
_type_previous = _type;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void FlightTaskAutoLineSmoothVel::_generateSetpoints()
|
void FlightTaskAutoLineSmoothVel::_generateSetpoints()
|
||||||
{
|
{
|
||||||
_checkEmergencyBraking();
|
_checkEmergencyBraking();
|
||||||
|
|||||||
+2
-1
@@ -51,6 +51,7 @@ public:
|
|||||||
|
|
||||||
bool activate(const vehicle_local_position_setpoint_s &last_setpoint) override;
|
bool activate(const vehicle_local_position_setpoint_s &last_setpoint) override;
|
||||||
void reActivate() override;
|
void reActivate() override;
|
||||||
|
bool update() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PositionSmoothing _position_smoothing;
|
PositionSmoothing _position_smoothing;
|
||||||
@@ -65,7 +66,7 @@ protected:
|
|||||||
void _ekfResetHandlerVelocityZ(float delta_vz) override;
|
void _ekfResetHandlerVelocityZ(float delta_vz) override;
|
||||||
void _ekfResetHandlerHeading(float delta_psi) override;
|
void _ekfResetHandlerHeading(float delta_psi) override;
|
||||||
|
|
||||||
void _generateSetpoints() override; /**< Generate setpoints along line. */
|
void _generateSetpoints(); /**< Generate setpoints along line. */
|
||||||
void _generateHeading();
|
void _generateHeading();
|
||||||
void _checkEmergencyBraking();
|
void _checkEmergencyBraking();
|
||||||
bool _generateHeadingAlongTraj(); /**< Generates heading along trajectory. */
|
bool _generateHeadingAlongTraj(); /**< Generates heading along trajectory. */
|
||||||
|
|||||||
@@ -45,70 +45,6 @@ FlightTaskAutoMapper::FlightTaskAutoMapper() :
|
|||||||
_stick_acceleration_xy(this)
|
_stick_acceleration_xy(this)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool FlightTaskAutoMapper::update()
|
|
||||||
{
|
|
||||||
bool ret = FlightTaskAuto::update();
|
|
||||||
// always reset constraints because they might change depending on the type
|
|
||||||
_setDefaultConstraints();
|
|
||||||
|
|
||||||
// The only time a thrust set-point is sent out is during
|
|
||||||
// idle. Hence, reset thrust set-point to NAN in case the
|
|
||||||
// vehicle exits idle.
|
|
||||||
|
|
||||||
if (_type_previous == WaypointType::idle) {
|
|
||||||
_acceleration_setpoint.setNaN();
|
|
||||||
}
|
|
||||||
|
|
||||||
// during mission and reposition, raise the landing gears but only
|
|
||||||
// if altitude is high enough
|
|
||||||
if (_highEnoughForLandingGear()) {
|
|
||||||
_gear.landing_gear = landing_gear_s::GEAR_UP;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (_type) {
|
|
||||||
case WaypointType::idle:
|
|
||||||
_prepareIdleSetpoints();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WaypointType::land:
|
|
||||||
_prepareLandSetpoints();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WaypointType::loiter:
|
|
||||||
|
|
||||||
/* fallthrought */
|
|
||||||
case WaypointType::position:
|
|
||||||
_preparePositionSetpoints();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WaypointType::takeoff:
|
|
||||||
_prepareTakeoffSetpoints();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WaypointType::velocity:
|
|
||||||
_prepareVelocitySetpoints();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
_preparePositionSetpoints();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_param_com_obs_avoid.get()) {
|
|
||||||
_obstacle_avoidance.updateAvoidanceDesiredSetpoints(_position_setpoint, _velocity_setpoint, (int)_type);
|
|
||||||
_obstacle_avoidance.injectAvoidanceSetpoints(_position_setpoint, _velocity_setpoint, _yaw_setpoint,
|
|
||||||
_yawspeed_setpoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_generateSetpoints();
|
|
||||||
|
|
||||||
// update previous type
|
|
||||||
_type_previous = _type;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FlightTaskAutoMapper::_prepareIdleSetpoints()
|
void FlightTaskAutoMapper::_prepareIdleSetpoints()
|
||||||
{
|
{
|
||||||
// Send zero thrust setpoint
|
// Send zero thrust setpoint
|
||||||
|
|||||||
@@ -50,12 +50,8 @@ class FlightTaskAutoMapper : public FlightTaskAuto
|
|||||||
public:
|
public:
|
||||||
FlightTaskAutoMapper();
|
FlightTaskAutoMapper();
|
||||||
virtual ~FlightTaskAutoMapper() = default;
|
virtual ~FlightTaskAutoMapper() = default;
|
||||||
bool update() override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void _generateSetpoints() = 0; /**< Generate velocity and position setpoint for following line. */
|
|
||||||
|
|
||||||
void _prepareIdleSetpoints();
|
void _prepareIdleSetpoints();
|
||||||
void _prepareLandSetpoints();
|
void _prepareLandSetpoints();
|
||||||
void _prepareVelocitySetpoints();
|
void _prepareVelocitySetpoints();
|
||||||
@@ -77,7 +73,7 @@ protected:
|
|||||||
(ParamFloat<px4::params::MPC_MAN_Y_MAX>) _param_mpc_man_y_max
|
(ParamFloat<px4::params::MPC_MAN_Y_MAX>) _param_mpc_man_y_max
|
||||||
);
|
);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
Sticks _sticks;
|
Sticks _sticks;
|
||||||
StickAccelerationXY _stick_acceleration_xy;
|
StickAccelerationXY _stick_acceleration_xy;
|
||||||
StickYaw _stick_yaw;
|
StickYaw _stick_yaw;
|
||||||
|
|||||||
Reference in New Issue
Block a user