mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-01 14:21:35 +08:00
use subscription array in ObstacleAvoidance library
This commit is contained in:
committed by
bresch
parent
a9bab81eb8
commit
320ed40806
@@ -42,6 +42,12 @@ using namespace matrix;
|
||||
|
||||
static constexpr float SIGMA_NORM = 0.001f;
|
||||
|
||||
FlightTaskAuto::FlightTaskAuto() :
|
||||
_obstacle_avoidance(this)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool FlightTaskAuto::initializeSubscriptions(SubscriptionArray &subscription_array)
|
||||
{
|
||||
if (!FlightTask::initializeSubscriptions(subscription_array)) {
|
||||
@@ -60,6 +66,10 @@ bool FlightTaskAuto::initializeSubscriptions(SubscriptionArray &subscription_arr
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_obstacle_avoidance.initializeSubscriptions(subscription_array)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
#include <uORB/topics/position_controller_status.h>
|
||||
#include <uORB/topics/vehicle_status.h>
|
||||
#include <lib/ecl/geo/geo.h>
|
||||
#include "lib/FlightTasks/tasks/Utility/ObstacleAvoidance.hpp"
|
||||
|
||||
|
||||
/**
|
||||
* This enum has to agree with position_setpoint_s type definition
|
||||
@@ -73,7 +75,7 @@ enum class State {
|
||||
class FlightTaskAuto : public FlightTask
|
||||
{
|
||||
public:
|
||||
FlightTaskAuto() = default;
|
||||
FlightTaskAuto();
|
||||
|
||||
virtual ~FlightTaskAuto() = default;
|
||||
bool initializeSubscriptions(SubscriptionArray &subscription_array) override;
|
||||
@@ -84,6 +86,7 @@ public:
|
||||
* Sets an external yaw handler which can be used to implement a different yaw control strategy.
|
||||
*/
|
||||
void setYawHandler(WeatherVane *ext_yaw_handler) override {_ext_yaw_handler = ext_yaw_handler;}
|
||||
ObstacleAvoidance _obstacle_avoidance;
|
||||
|
||||
protected:
|
||||
void _setDefaultConstraints() override;
|
||||
@@ -113,6 +116,8 @@ protected:
|
||||
(ParamInt<px4::params::COM_OBS_AVOID>) _param_com_obs_avoid // obstacle avoidance active
|
||||
);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
matrix::Vector2f _lock_position_xy{NAN, NAN}; /**< if no valid triplet is received, lock positition to current position */
|
||||
bool _yaw_lock = false; /**< if within acceptance radius, lock yaw to current yaw */
|
||||
|
||||
Reference in New Issue
Block a user