mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-03 01:21:35 +08:00
Remove FlightTaskManual from the inheritance structure
This commit is contained in:
committed by
Julian Kent
parent
9daff24e79
commit
1e56eed2aa
@@ -34,7 +34,6 @@
|
|||||||
# add the core Flight tasks that the additional flight tasks depend on
|
# add the core Flight tasks that the additional flight tasks depend on
|
||||||
add_subdirectory(FlightTask)
|
add_subdirectory(FlightTask)
|
||||||
add_subdirectory(Utility)
|
add_subdirectory(Utility)
|
||||||
add_subdirectory(Manual)
|
|
||||||
add_subdirectory(Auto)
|
add_subdirectory(Auto)
|
||||||
add_subdirectory(AutoMapper)
|
add_subdirectory(AutoMapper)
|
||||||
|
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
############################################################################
|
|
||||||
#
|
|
||||||
# Copyright (c) 2018 PX4 Development Team. All rights reserved.
|
|
||||||
#
|
|
||||||
# Redistribution and use in source and binary forms, with or without
|
|
||||||
# modification, are permitted provided that the following conditions
|
|
||||||
# are met:
|
|
||||||
#
|
|
||||||
# 1. Redistributions of source code must retain the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer.
|
|
||||||
# 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
# notice, this list of conditions and the following disclaimer in
|
|
||||||
# the documentation and/or other materials provided with the
|
|
||||||
# distribution.
|
|
||||||
# 3. Neither the name PX4 nor the names of its contributors may be
|
|
||||||
# used to endorse or promote products derived from this software
|
|
||||||
# without specific prior written permission.
|
|
||||||
#
|
|
||||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
#
|
|
||||||
############################################################################
|
|
||||||
|
|
||||||
px4_add_library(FlightTaskManual
|
|
||||||
FlightTaskManual.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(FlightTaskManual PUBLIC FlightTask FlightTaskUtility)
|
|
||||||
target_include_directories(FlightTaskManual PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018 PX4 Development Team. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
/**
|
|
||||||
* @file FlightTaskManual.cpp
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "FlightTaskManual.hpp"
|
|
||||||
#include <mathlib/mathlib.h>
|
|
||||||
#include <float.h>
|
|
||||||
#include <drivers/drv_hrt.h>
|
|
||||||
|
|
||||||
using namespace matrix;
|
|
||||||
using namespace time_literals;
|
|
||||||
|
|
||||||
FlightTaskManual::FlightTaskManual() :
|
|
||||||
_sticks(this)
|
|
||||||
{};
|
|
||||||
|
|
||||||
bool FlightTaskManual::updateInitialize()
|
|
||||||
{
|
|
||||||
bool ret = FlightTask::updateInitialize();
|
|
||||||
|
|
||||||
const bool sticks_available = _sticks.evaluateSticks(_time_stamp_current, _gear);
|
|
||||||
|
|
||||||
if (_sticks_data_required) {
|
|
||||||
ret = ret && sticks_available;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
*
|
|
||||||
* Copyright (c) 2018 PX4 Development Team. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name PX4 nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file FlightTaskManual.hpp
|
|
||||||
*
|
|
||||||
* Linear and exponential map from stick inputs to range -1 and 1.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "FlightTask.hpp"
|
|
||||||
#include "Sticks.hpp"
|
|
||||||
|
|
||||||
class FlightTaskManual : public FlightTask
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
FlightTaskManual();
|
|
||||||
virtual ~FlightTaskManual() = default;
|
|
||||||
bool updateInitialize() override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Sticks _sticks;
|
|
||||||
bool _sticks_data_required = true; /**< let inherited task-class define if it depends on stick data */
|
|
||||||
};
|
|
||||||
@@ -35,5 +35,5 @@ px4_add_library(FlightTaskManualAltitude
|
|||||||
FlightTaskManualAltitude.cpp
|
FlightTaskManualAltitude.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(FlightTaskManualAltitude PUBLIC FlightTaskManual)
|
target_link_libraries(FlightTaskManualAltitude PUBLIC FlightTask FlightTaskUtility)
|
||||||
target_include_directories(FlightTaskManualAltitude PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(FlightTaskManualAltitude PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|||||||
@@ -42,9 +42,19 @@
|
|||||||
|
|
||||||
using namespace matrix;
|
using namespace matrix;
|
||||||
|
|
||||||
|
FlightTaskManualAltitude::FlightTaskManualAltitude() :
|
||||||
|
_sticks(this)
|
||||||
|
{};
|
||||||
|
|
||||||
bool FlightTaskManualAltitude::updateInitialize()
|
bool FlightTaskManualAltitude::updateInitialize()
|
||||||
{
|
{
|
||||||
bool ret = FlightTaskManual::updateInitialize();
|
bool ret = FlightTask::updateInitialize();
|
||||||
|
|
||||||
|
const bool sticks_available = _sticks.evaluateSticks(_time_stamp_current, _gear);
|
||||||
|
|
||||||
|
if (_sticks_data_required) {
|
||||||
|
ret = ret && sticks_available;
|
||||||
|
}
|
||||||
|
|
||||||
// in addition to manual require valid position and velocity in D-direction and valid yaw
|
// in addition to manual require valid position and velocity in D-direction and valid yaw
|
||||||
return ret && PX4_ISFINITE(_position(2)) && PX4_ISFINITE(_velocity(2)) && PX4_ISFINITE(_yaw);
|
return ret && PX4_ISFINITE(_position(2)) && PX4_ISFINITE(_velocity(2)) && PX4_ISFINITE(_yaw);
|
||||||
@@ -52,7 +62,7 @@ bool FlightTaskManualAltitude::updateInitialize()
|
|||||||
|
|
||||||
bool FlightTaskManualAltitude::activate(vehicle_local_position_setpoint_s last_setpoint)
|
bool FlightTaskManualAltitude::activate(vehicle_local_position_setpoint_s last_setpoint)
|
||||||
{
|
{
|
||||||
bool ret = FlightTaskManual::activate(last_setpoint);
|
bool ret = FlightTask::activate(last_setpoint);
|
||||||
_yaw_setpoint = NAN;
|
_yaw_setpoint = NAN;
|
||||||
_yawspeed_setpoint = 0.f;
|
_yawspeed_setpoint = 0.f;
|
||||||
_acceleration_setpoint = Vector3f(0.f, 0.f, NAN); // altitude is controlled from position/velocity
|
_acceleration_setpoint = Vector3f(0.f, 0.f, NAN); // altitude is controlled from position/velocity
|
||||||
@@ -365,7 +375,7 @@ bool FlightTaskManualAltitude::_checkTakeoff()
|
|||||||
|
|
||||||
bool FlightTaskManualAltitude::update()
|
bool FlightTaskManualAltitude::update()
|
||||||
{
|
{
|
||||||
bool ret = FlightTaskManual::update();
|
bool ret = FlightTask::update();
|
||||||
_updateConstraintsFromEstimator();
|
_updateConstraintsFromEstimator();
|
||||||
_scaleSticks();
|
_scaleSticks();
|
||||||
_updateSetpoints();
|
_updateSetpoints();
|
||||||
|
|||||||
@@ -39,13 +39,14 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "FlightTaskManual.hpp"
|
#include "FlightTask.hpp"
|
||||||
|
#include "Sticks.hpp"
|
||||||
#include <lib/ecl/AlphaFilter/AlphaFilter.hpp>
|
#include <lib/ecl/AlphaFilter/AlphaFilter.hpp>
|
||||||
|
|
||||||
class FlightTaskManualAltitude : public FlightTaskManual
|
class FlightTaskManualAltitude : public FlightTask
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FlightTaskManualAltitude() = default;
|
FlightTaskManualAltitude();
|
||||||
virtual ~FlightTaskManualAltitude() = default;
|
virtual ~FlightTaskManualAltitude() = default;
|
||||||
bool activate(vehicle_local_position_setpoint_s last_setpoint) override;
|
bool activate(vehicle_local_position_setpoint_s last_setpoint) override;
|
||||||
bool updateInitialize() override;
|
bool updateInitialize() override;
|
||||||
@@ -71,7 +72,10 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void _updateAltitudeLock();
|
void _updateAltitudeLock();
|
||||||
|
|
||||||
DEFINE_PARAMETERS_CUSTOM_PARENT(FlightTaskManual,
|
Sticks _sticks;
|
||||||
|
bool _sticks_data_required = true; ///< let inherited task-class define if it depends on stick data
|
||||||
|
|
||||||
|
DEFINE_PARAMETERS_CUSTOM_PARENT(FlightTask,
|
||||||
(ParamFloat<px4::params::MPC_HOLD_MAX_Z>) _param_mpc_hold_max_z,
|
(ParamFloat<px4::params::MPC_HOLD_MAX_Z>) _param_mpc_hold_max_z,
|
||||||
(ParamInt<px4::params::MPC_ALT_MODE>) _param_mpc_alt_mode,
|
(ParamInt<px4::params::MPC_ALT_MODE>) _param_mpc_alt_mode,
|
||||||
(ParamFloat<px4::params::MPC_HOLD_MAX_XY>) _param_mpc_hold_max_xy,
|
(ParamFloat<px4::params::MPC_HOLD_MAX_XY>) _param_mpc_hold_max_xy,
|
||||||
|
|||||||
Reference in New Issue
Block a user