mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-18 15:09:05 +08:00
FlightTask: rename mehtod and add default parameter for constraints
This commit is contained in:
parent
edb2e3256f
commit
962c2eff61
@ -17,7 +17,7 @@ bool FlightTask::initializeSubscriptions(SubscriptionArray &subscription_array)
|
||||
bool FlightTask::activate()
|
||||
{
|
||||
_resetSetpoints();
|
||||
_updateSetpointLimits();
|
||||
_setDefaultConstraints();
|
||||
_time_stamp_activate = hrt_absolute_time();
|
||||
return true;
|
||||
}
|
||||
@ -75,9 +75,10 @@ bool FlightTask::_evaluateVehicleLocalPosition()
|
||||
}
|
||||
}
|
||||
|
||||
void FlightTask::_updateSetpointLimits()
|
||||
void FlightTask::_setDefaultConstraints()
|
||||
{
|
||||
_limits.speed_NE_max = MPC_XY_VEL_MAX.get();
|
||||
_limits.speed_up_max = MPC_Z_VEL_MAX_UP.get();
|
||||
_limits.speed_dn_max = MPC_Z_VEL_MAX_DN.get();
|
||||
_constraints.speed_xy = MPC_XY_VEL_MAX.get();
|
||||
_constraints.speed_up = MPC_Z_VEL_MAX_UP.get();
|
||||
_constraints.speed_down = MPC_Z_VEL_MAX_DN.get();
|
||||
_constraints.tilt = math::radians(MPC_TILTMAX_AIR.get());
|
||||
}
|
||||
|
||||
@ -55,7 +55,10 @@ class FlightTask : public ModuleParams
|
||||
public:
|
||||
FlightTask() :
|
||||
ModuleParams(nullptr)
|
||||
{ _resetSetpoints(); }
|
||||
{
|
||||
_resetSetpoints();
|
||||
_constraints = empty_constraints;
|
||||
}
|
||||
|
||||
virtual ~FlightTask() = default;
|
||||
|
||||
@ -124,7 +127,6 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
uORB::Subscription<vehicle_local_position_s> *_sub_vehicle_local_position{nullptr};
|
||||
|
||||
/**
|
||||
@ -132,25 +134,15 @@ protected:
|
||||
*/
|
||||
void _resetSetpoints();
|
||||
|
||||
/**
|
||||
* Update Flighttask limits
|
||||
*/
|
||||
void virtual _updateSetpointLimits();
|
||||
|
||||
/*
|
||||
* Check and update local position
|
||||
*/
|
||||
bool _evaluateVehicleLocalPosition();
|
||||
|
||||
/**
|
||||
* @brief Setpoint limits
|
||||
* Set constraints to default values
|
||||
*/
|
||||
struct Limits {
|
||||
float speed_NE_max = 1.0f; /**< maximum speed in NE-direction */
|
||||
float speed_up_max = 1.0f; /**< maximum speed upwards */
|
||||
float speed_dn_max = 1.0f; /**< maximum speed downwards */
|
||||
};
|
||||
Limits _limits;
|
||||
virtual void _setDefaultConstraints();
|
||||
|
||||
/* Time abstraction */
|
||||
static constexpr uint64_t _timeout = 500000; /**< maximal time in us before a loop or data times out */
|
||||
@ -190,6 +182,7 @@ protected:
|
||||
DEFINE_PARAMETERS_CUSTOM_PARENT(ModuleParams,
|
||||
(ParamFloat<px4::params::MPC_XY_VEL_MAX>) MPC_XY_VEL_MAX,
|
||||
(ParamFloat<px4::params::MPC_Z_VEL_MAX_DN>) MPC_Z_VEL_MAX_DN,
|
||||
(ParamFloat<px4::params::MPC_Z_VEL_MAX_UP>) MPC_Z_VEL_MAX_UP
|
||||
);
|
||||
(ParamFloat<px4::params::MPC_Z_VEL_MAX_UP>) MPC_Z_VEL_MAX_UP,
|
||||
(ParamFloat<px4::params::MPC_TILTMAX_AIR>) MPC_TILTMAX_AIR
|
||||
)
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user