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

This commit is contained in:
Matthias Grob
2018-04-05 07:30:12 +02:00
committed by Beat Küng
parent 4bb3692020
commit 4d0dca5dd5
4 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -76,7 +76,7 @@ public:
* To be called to adopt parameters from an arrived vehicle command * To be called to adopt parameters from an arrived vehicle command
* @return true if accepted, false if declined * @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() * Call before activate() or update()
@@ -56,7 +56,7 @@ public:
bool initializeSubscriptions(SubscriptionArray &subscription_array) override; 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; bool updateInitialize() override;
@@ -51,16 +51,16 @@ FlightTaskOrbit::FlightTaskOrbit(control::SuperBlock *parent, const char *name)
_sticks_data_required = false; _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 */ const float &r = command.param3; /**< commanded radius */
float &v = command.param4; /**< commanded velocity */ const float &v = command.param4; /**< commanded velocity */
if (math::isInRange(r, 5.f, 50.f) && if (math::isInRange(r, 5.f, 50.f) &&
fabs(v) < 10.f) { fabs(v) < 10.f) {
_r = r; _r = r;
_v = v; _v = v;
return true; return FlightTaskManual::applyCommandParameters(command);
} }
return false; return false;
@@ -50,7 +50,7 @@ public:
virtual ~FlightTaskOrbit() = default; virtual ~FlightTaskOrbit() = default;
bool applyCommandParameters(vehicle_command_s command) override; bool applyCommandParameters(const vehicle_command_s &command) override;
bool activate() override; bool activate() override;