mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-08 22:41:36 +08:00
Make LandingTargetEstimator a lib and run on work_queue
Currently only precision landing is using the LandingTargetEstimator and it is a waste to have it running in the background all the time. With this change the estimator is only started once the precision landing flight task is activated, and stopped when the flight task is deactivated.
This commit is contained in:
@@ -32,8 +32,16 @@
|
||||
############################################################################
|
||||
|
||||
px4_add_library(FlightTaskAutoPrecisionLanding
|
||||
FlightTaskAutoPrecisionLanding.cpp
|
||||
FlightTaskAutoPrecisionLanding.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(FlightTaskAutoPrecisionLanding PUBLIC FlightTaskAuto)
|
||||
target_include_directories(FlightTaskAutoPrecisionLanding PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(FlightTaskAutoPrecisionLanding
|
||||
PUBLIC
|
||||
FlightTaskAuto
|
||||
LandingTargetEstimator
|
||||
)
|
||||
|
||||
target_include_directories(FlightTaskAutoPrecisionLanding
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
+10
@@ -45,6 +45,16 @@
|
||||
|
||||
static constexpr const char *LOST_TARGET_ERROR_MESSAGE = "Lost landing target while landing";
|
||||
|
||||
FlightTaskAutoPrecisionLanding::FlightTaskAutoPrecisionLanding()
|
||||
{
|
||||
_landing_target_estimator.Start();
|
||||
}
|
||||
|
||||
FlightTaskAutoPrecisionLanding::~FlightTaskAutoPrecisionLanding()
|
||||
{
|
||||
_landing_target_estimator.Stop();
|
||||
}
|
||||
|
||||
bool FlightTaskAutoPrecisionLanding::activate(const trajectory_setpoint_s &last_setpoint)
|
||||
{
|
||||
bool ret = FlightTask::activate(last_setpoint);
|
||||
|
||||
+5
-2
@@ -45,6 +45,7 @@
|
||||
|
||||
#include <matrix/math.hpp>
|
||||
#include <mathlib/mathlib.h>
|
||||
#include <landing_target_estimator/LandingTargetEstimator.h>
|
||||
#include <lib/geo/geo.h>
|
||||
#include <px4_platform_common/module_params.h>
|
||||
#include <uORB/Subscription.hpp>
|
||||
@@ -74,8 +75,8 @@ enum class PrecLandMode {
|
||||
class FlightTaskAutoPrecisionLanding : public FlightTaskAuto
|
||||
{
|
||||
public:
|
||||
FlightTaskAutoPrecisionLanding() = default;
|
||||
virtual ~FlightTaskAutoPrecisionLanding() = default;
|
||||
FlightTaskAutoPrecisionLanding();
|
||||
~FlightTaskAutoPrecisionLanding();
|
||||
|
||||
bool activate(const trajectory_setpoint_s &last_setpoint) override;
|
||||
|
||||
@@ -104,6 +105,8 @@ private:
|
||||
bool check_state_conditions(PrecLandState state);
|
||||
void slewrate(float &sp_x, float &sp_y);
|
||||
|
||||
landing_target_estimator::LandingTargetEstimator _landing_target_estimator;
|
||||
|
||||
landing_target_pose_s _target_pose{}; /**< precision landing target position */
|
||||
|
||||
uORB::Subscription _target_pose_sub{ORB_ID(landing_target_pose)};
|
||||
|
||||
Reference in New Issue
Block a user