FlightTask: make applyCommandParameters getting called recursively & pass command by reference

This commit is contained in:
Matthias Grob 2017-12-16 10:14:15 +01:00 committed by Beat Küng
parent 4bb3692020
commit 4d0dca5dd5
4 changed files with 7 additions and 7 deletions

View File

@ -76,7 +76,7 @@ public:
* 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;
virtual bool applyCommandParameters(const vehicle_command_s &command) { return true; };
/**
* Call before activate() or update()

View File

@ -56,7 +56,7 @@ public:
bool initializeSubscriptions(SubscriptionArray &subscription_array) override;
bool applyCommandParameters(vehicle_command_s command) override { return false; };
bool applyCommandParameters(const vehicle_command_s &command) override { return FlightTask::applyCommandParameters(command); };
bool updateInitialize() override;

View File

@ -51,16 +51,16 @@ FlightTaskOrbit::FlightTaskOrbit(control::SuperBlock *parent, const char *name)
_sticks_data_required = false;
}
bool FlightTaskOrbit::applyCommandParameters(vehicle_command_s command)
bool FlightTaskOrbit::applyCommandParameters(const vehicle_command_s &command)
{
float &r = command.param3; /**< commanded radius */
float &v = command.param4; /**< commanded velocity */
const float &r = command.param3; /**< commanded radius */
const float &v = command.param4; /**< commanded velocity */
if (math::isInRange(r, 5.f, 50.f) &&
fabs(v) < 10.f) {
_r = r;
_v = v;
return true;
return FlightTaskManual::applyCommandParameters(command);
}
return false;

View File

@ -50,7 +50,7 @@ public:
virtual ~FlightTaskOrbit() = default;
bool applyCommandParameters(vehicle_command_s command) override;
bool applyCommandParameters(const vehicle_command_s &command) override;
bool activate() override;