mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 02:16:53 +08:00
FlightTaskOffboard: only start task if control mode flags are met
This commit is contained in:
committed by
Lorenz Meier
parent
bf4ac7a9d6
commit
b5731e0ccd
@@ -55,6 +55,8 @@ bool FlightTaskOffboard::initializeSubscriptions(SubscriptionArray &subscription
|
|||||||
bool FlightTaskOffboard::updateInitialize()
|
bool FlightTaskOffboard::updateInitialize()
|
||||||
{
|
{
|
||||||
bool ret = FlightTask::updateInitialize();
|
bool ret = FlightTask::updateInitialize();
|
||||||
|
// require a valid triplet
|
||||||
|
ret = ret && _sub_triplet_setpoint->get().current.valid;
|
||||||
// require valid position / velocity in xy
|
// require valid position / velocity in xy
|
||||||
return ret && PX4_ISFINITE(_position(0))
|
return ret && PX4_ISFINITE(_position(0))
|
||||||
&& PX4_ISFINITE(_position(1))
|
&& PX4_ISFINITE(_position(1))
|
||||||
@@ -245,5 +247,4 @@ bool FlightTaskOffboard::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -519,7 +519,7 @@ MulticopterPositionControl::task_main()
|
|||||||
setDt(dt);
|
setDt(dt);
|
||||||
|
|
||||||
if (_control_mode.flag_armed) {
|
if (_control_mode.flag_armed) {
|
||||||
// as soon vehicle is armed, start flighttask
|
// as soon vehicle is armed check for flighttask
|
||||||
start_flight_task();
|
start_flight_task();
|
||||||
// arm hysteresis prevents vehicle to takeoff
|
// arm hysteresis prevents vehicle to takeoff
|
||||||
// before propeller reached idle speed.
|
// before propeller reached idle speed.
|
||||||
@@ -646,7 +646,7 @@ MulticopterPositionControl::task_main()
|
|||||||
|
|
||||||
// publish attitude setpoint
|
// publish attitude setpoint
|
||||||
// Note: this requires review. The reason for not sending
|
// Note: this requires review. The reason for not sending
|
||||||
// an attitude setpoint is because for none-flighttask modes
|
// an attitude setpoint is because for non-flighttask modes
|
||||||
// the attitude septoint should come from another source, otherwise
|
// the attitude septoint should come from another source, otherwise
|
||||||
// they might conflict with each other such as in offboard attitude control.
|
// they might conflict with each other such as in offboard attitude control.
|
||||||
publish_attitude();
|
publish_attitude();
|
||||||
@@ -678,7 +678,13 @@ MulticopterPositionControl::start_flight_task()
|
|||||||
bool task_failure = false;
|
bool task_failure = false;
|
||||||
|
|
||||||
// offboard
|
// offboard
|
||||||
if (_vehicle_status.nav_state == vehicle_status_s::NAVIGATION_STATE_OFFBOARD) {
|
if (_vehicle_status.nav_state == vehicle_status_s::NAVIGATION_STATE_OFFBOARD
|
||||||
|
&& (_control_mode.flag_control_altitude_enabled ||
|
||||||
|
_control_mode.flag_control_position_enabled ||
|
||||||
|
_control_mode.flag_control_climb_rate_enabled ||
|
||||||
|
_control_mode.flag_control_velocity_enabled ||
|
||||||
|
_control_mode.flag_control_acceleration_enabled)) {
|
||||||
|
|
||||||
int error = _flight_tasks.switchTask(FlightTaskIndex::Offboard);
|
int error = _flight_tasks.switchTask(FlightTaskIndex::Offboard);
|
||||||
|
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user