mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 11:06:04 +08:00
FlightTask: rename and move setCruisingSpeed() -> overrideCruiseSpeed()
This commit is contained in:
committed by
Roman Bapst
parent
f892a624b7
commit
68cf686892
@@ -447,7 +447,7 @@ void FlightModeManager::handleCommand()
|
|||||||
if ((command.command == vehicle_command_s::VEHICLE_CMD_DO_CHANGE_SPEED)
|
if ((command.command == vehicle_command_s::VEHICLE_CMD_DO_CHANGE_SPEED)
|
||||||
&& (static_cast<uint8_t>(command.param1 + .5f) == vehicle_command_s::SPEED_TYPE_GROUNDSPEED)
|
&& (static_cast<uint8_t>(command.param1 + .5f) == vehicle_command_s::SPEED_TYPE_GROUNDSPEED)
|
||||||
&& (command.param2 > 0.f)) {
|
&& (command.param2 > 0.f)) {
|
||||||
_current_task.task->setCruisingSpeed(command.param2);
|
_current_task.task->overrideCruiseSpeed(command.param2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,6 +223,12 @@ bool FlightTaskAuto::update()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FlightTaskAuto::overrideCruiseSpeed(const float cruise_speed_m_s)
|
||||||
|
{
|
||||||
|
_mc_cruise_speed = cruise_speed_m_s;
|
||||||
|
_commanded_speed_ts = hrt_absolute_time();
|
||||||
|
}
|
||||||
|
|
||||||
void FlightTaskAuto::_prepareLandSetpoints()
|
void FlightTaskAuto::_prepareLandSetpoints()
|
||||||
{
|
{
|
||||||
_velocity_setpoint.setNaN(); // Don't take over any smoothed velocity setpoint
|
_velocity_setpoint.setNaN(); // Don't take over any smoothed velocity setpoint
|
||||||
@@ -345,7 +351,7 @@ bool FlightTaskAuto::_evaluateTriplets()
|
|||||||
|
|
||||||
_type = (WaypointType)_sub_triplet_setpoint.get().current.type;
|
_type = (WaypointType)_sub_triplet_setpoint.get().current.type;
|
||||||
|
|
||||||
// Override a commanded cruise speed if the cruise speed from the triplet is valid and more recent
|
// Prioritize cruise speed from the triplet when it's valid and more recent than the previously commanded cruise speed
|
||||||
const float cruise_speed_from_triplet = _sub_triplet_setpoint.get().current.cruising_speed;
|
const float cruise_speed_from_triplet = _sub_triplet_setpoint.get().current.cruising_speed;
|
||||||
|
|
||||||
if (PX4_ISFINITE(cruise_speed_from_triplet) && cruise_speed_from_triplet >= 0
|
if (PX4_ISFINITE(cruise_speed_from_triplet) && cruise_speed_from_triplet >= 0
|
||||||
|
|||||||
@@ -92,17 +92,11 @@ public:
|
|||||||
bool updateInitialize() override;
|
bool updateInitialize() override;
|
||||||
bool update() override;
|
bool update() override;
|
||||||
|
|
||||||
bool setCruisingSpeed(const float cruising_speed_m_s) override
|
|
||||||
{
|
|
||||||
_mc_cruise_speed = cruising_speed_m_s;
|
|
||||||
_commanded_speed_ts = hrt_absolute_time();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets an external yaw handler which can be used to implement a different yaw control strategy.
|
* Sets an external yaw handler which can be used to implement a different yaw control strategy.
|
||||||
*/
|
*/
|
||||||
void setYawHandler(WeatherVane *ext_yaw_handler) override {_ext_yaw_handler = ext_yaw_handler;}
|
void setYawHandler(WeatherVane *ext_yaw_handler) override {_ext_yaw_handler = ext_yaw_handler;}
|
||||||
|
void overrideCruiseSpeed(const float cruise_speed_m_s) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
matrix::Vector2f _getTargetVelocityXY(); /**< only used for follow-me and only here because of legacy reason.*/
|
matrix::Vector2f _getTargetVelocityXY(); /**< only used for follow-me and only here because of legacy reason.*/
|
||||||
|
|||||||
@@ -167,6 +167,7 @@ public:
|
|||||||
* This method does nothing, each flighttask which wants to use the yaw handler needs to override this method.
|
* This method does nothing, each flighttask which wants to use the yaw handler needs to override this method.
|
||||||
*/
|
*/
|
||||||
virtual void setYawHandler(WeatherVane *ext_yaw_handler) {}
|
virtual void setYawHandler(WeatherVane *ext_yaw_handler) {}
|
||||||
|
virtual void overrideCruiseSpeed(const float cruise_speed_m_s) {}
|
||||||
|
|
||||||
void updateVelocityControllerFeedback(const matrix::Vector3f &vel_sp,
|
void updateVelocityControllerFeedback(const matrix::Vector3f &vel_sp,
|
||||||
const matrix::Vector3f &acc_sp)
|
const matrix::Vector3f &acc_sp)
|
||||||
@@ -175,8 +176,6 @@ public:
|
|||||||
_acceleration_setpoint_feedback = acc_sp;
|
_acceleration_setpoint_feedback = acc_sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool setCruisingSpeed(const float cruising_speed_m_s) { return false; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uORB::SubscriptionData<vehicle_local_position_s> _sub_vehicle_local_position{ORB_ID(vehicle_local_position)};
|
uORB::SubscriptionData<vehicle_local_position_s> _sub_vehicle_local_position{ORB_ID(vehicle_local_position)};
|
||||||
uORB::SubscriptionData<home_position_s> _sub_home_position{ORB_ID(home_position)};
|
uORB::SubscriptionData<home_position_s> _sub_home_position{ORB_ID(home_position)};
|
||||||
|
|||||||
Reference in New Issue
Block a user