mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-29 20:00:35 +08:00
FlightTasks: replaced all hrt_elapsed() calls and unneeded hrt_ calls to safe performance
This commit is contained in:
@@ -5,9 +5,10 @@ constexpr uint64_t FlightTask::_timeout;
|
||||
|
||||
int FlightTask::update()
|
||||
{
|
||||
_time = hrt_elapsed_time(&_starting_time_stamp) / 1e6f;
|
||||
_deltatime = math::min(hrt_elapsed_time(&_last_time_stamp), _timeout) / 1e6f;
|
||||
_last_time_stamp = hrt_absolute_time();
|
||||
_time_stamp_current = hrt_absolute_time();
|
||||
_time = (_time_stamp_current - _time_stamp_activate) / 1e6f;
|
||||
_deltatime = math::min((_time_stamp_current - _time_stamp_last), _timeout) / 1e6f;
|
||||
_time_stamp_last = _time_stamp_current;
|
||||
updateSubscriptions();
|
||||
_evaluate_vehicle_position();
|
||||
return 0;
|
||||
@@ -15,7 +16,7 @@ int FlightTask::update()
|
||||
|
||||
void FlightTask::_evaluate_vehicle_position()
|
||||
{
|
||||
if (hrt_elapsed_time(&_sub_vehicle_local_position.get().timestamp) < _timeout) {
|
||||
if ((_time_stamp_current - _sub_vehicle_local_position.get().timestamp) < _timeout) {
|
||||
_position = matrix::Vector3f(&_sub_vehicle_local_position.get().x);
|
||||
_velocity = matrix::Vector3f(&_sub_vehicle_local_position.get().vx);
|
||||
_yaw = _sub_vehicle_local_position.get().yaw;
|
||||
|
||||
Reference in New Issue
Block a user