FlightTasks: added possibility to apply task parameters from the vehicle command

This commit is contained in:
Matthias Grob
2018-04-05 07:30:12 +02:00
committed by Beat Küng
parent b1f24da05e
commit efd240904f
7 changed files with 45 additions and 3 deletions
+7
View File
@@ -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;