mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 12:03:34 +08:00
FlightTask: make applyCommandParameters getting called recursively & pass command by reference
This commit is contained in:
@@ -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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user