mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 08:23:34 +08:00
FlightTask: Weather vane cleanup
Remove the entire external yaw handler, dynamic memory allocation, pointer passing logic. Directly instanciate the weather vane instance in the flight tasks that support it.
This commit is contained in:
@@ -36,4 +36,4 @@ px4_add_library(FlightTaskManualAcceleration
|
||||
)
|
||||
target_include_directories(FlightTaskManualAcceleration PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
target_link_libraries(FlightTaskManualAcceleration PUBLIC FlightTaskManualAltitudeSmoothVel FlightTaskUtility)
|
||||
target_link_libraries(FlightTaskManualAcceleration PUBLIC FlightTaskManualAltitudeSmoothVel FlightTaskUtility WeatherVane)
|
||||
|
||||
+4
-6
@@ -39,10 +39,6 @@
|
||||
|
||||
using namespace matrix;
|
||||
|
||||
FlightTaskManualAcceleration::FlightTaskManualAcceleration() :
|
||||
_stick_acceleration_xy(this)
|
||||
{};
|
||||
|
||||
bool FlightTaskManualAcceleration::activate(const trajectory_setpoint_s &last_setpoint)
|
||||
{
|
||||
bool ret = FlightTaskManualAltitudeSmoothVel::activate(last_setpoint);
|
||||
@@ -78,13 +74,15 @@ bool FlightTaskManualAcceleration::update()
|
||||
_constraints.want_takeoff = _checkTakeoff();
|
||||
|
||||
// check if an external yaw handler is active and if yes, let it update the yaw setpoints
|
||||
if (_weathervane_yaw_handler && _weathervane_yaw_handler->is_active()) {
|
||||
_weathervane.update();
|
||||
|
||||
if (_weathervane.isActive()) {
|
||||
_yaw_setpoint = NAN;
|
||||
|
||||
// only enable the weathervane to change the yawrate when position lock is active (and thus the pos. sp. are NAN)
|
||||
if (PX4_ISFINITE(_position_setpoint(0)) && PX4_ISFINITE(_position_setpoint(1))) {
|
||||
// vehicle is steady
|
||||
_yawspeed_setpoint += _weathervane_yaw_handler->get_weathervane_yawrate();
|
||||
_yawspeed_setpoint += _weathervane.getWeathervaneYawrate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-8
@@ -43,26 +43,22 @@
|
||||
#include "FlightTaskManualAltitudeSmoothVel.hpp"
|
||||
#include "StickAccelerationXY.hpp"
|
||||
#include "StickYaw.hpp"
|
||||
#include <lib/weather_vane/WeatherVane.hpp>
|
||||
|
||||
class FlightTaskManualAcceleration : public FlightTaskManualAltitudeSmoothVel
|
||||
{
|
||||
public:
|
||||
FlightTaskManualAcceleration();
|
||||
FlightTaskManualAcceleration() = default;
|
||||
virtual ~FlightTaskManualAcceleration() = default;
|
||||
bool activate(const trajectory_setpoint_s &last_setpoint) override;
|
||||
bool update() override;
|
||||
|
||||
/**
|
||||
* Sets an external yaw handler which can be used to implement a different yaw control strategy.
|
||||
*/
|
||||
void setYawHandler(WeatherVane *yaw_handler) override { _weathervane_yaw_handler = yaw_handler; }
|
||||
|
||||
private:
|
||||
void _ekfResetHandlerPositionXY(const matrix::Vector2f &delta_xy) override;
|
||||
void _ekfResetHandlerVelocityXY(const matrix::Vector2f &delta_vxy) override;
|
||||
|
||||
StickAccelerationXY _stick_acceleration_xy;
|
||||
StickAccelerationXY _stick_acceleration_xy{this};
|
||||
StickYaw _stick_yaw;
|
||||
|
||||
WeatherVane *_weathervane_yaw_handler{nullptr}; /**< external weathervane library, used to implement a yaw control law that turns the vehicle nose into the wind */
|
||||
WeatherVane _weathervane{this}; /**< weathervane library, used to implement a yaw control law that turns the vehicle nose into the wind */
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user