mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 16:23:34 +08:00
FlightTasks: added possibility to apply task parameters from the vehicle command
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
#include <matrix/matrix/math.hpp>
|
||||
#include <uORB/topics/vehicle_local_position.h>
|
||||
#include <uORB/topics/vehicle_local_position_setpoint.h>
|
||||
#include <uORB/topics/vehicle_command.h>
|
||||
|
||||
#include "../SubscriptionArray.hpp"
|
||||
|
||||
@@ -71,6 +72,12 @@ public:
|
||||
*/
|
||||
virtual bool activate();
|
||||
|
||||
/**
|
||||
* To be called to adopt parameters from an arrived vehicle command
|
||||
* @return true if accepted, false if declined
|
||||
*/
|
||||
virtual bool applyCommandParameters(vehicle_command_s command) = 0;
|
||||
|
||||
/**
|
||||
* Call before activate() or update()
|
||||
* to initialize time and input data
|
||||
|
||||
@@ -56,6 +56,8 @@ public:
|
||||
|
||||
bool initializeSubscriptions(SubscriptionArray &subscription_array) override;
|
||||
|
||||
bool applyCommandParameters(vehicle_command_s command) override { return false; };
|
||||
|
||||
bool updateInitialize() override;
|
||||
|
||||
bool update() override;
|
||||
|
||||
@@ -51,6 +51,21 @@ FlightTaskOrbit::FlightTaskOrbit(control::SuperBlock *parent, const char *name)
|
||||
_sticks_data_required = false;
|
||||
}
|
||||
|
||||
bool FlightTaskOrbit::applyCommandParameters(vehicle_command_s command)
|
||||
{
|
||||
float &r = command.param3;
|
||||
float &v = command.param4;
|
||||
|
||||
if (math::isInRange(r, 5.f, 50.f) &&
|
||||
fabs(v) < 10.f) {
|
||||
_r = r;
|
||||
_v = v;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FlightTaskOrbit::activate()
|
||||
{
|
||||
bool ret = FlightTaskManual::activate();
|
||||
|
||||
@@ -50,6 +50,8 @@ public:
|
||||
|
||||
virtual ~FlightTaskOrbit() = default;
|
||||
|
||||
bool applyCommandParameters(vehicle_command_s command) override;
|
||||
|
||||
bool activate() override;
|
||||
|
||||
bool update() override;
|
||||
|
||||
Reference in New Issue
Block a user