FlightTasks: replaced all hrt_elapsed() calls and unneeded hrt_ calls to safe performance

This commit is contained in:
Matthias Grob
2017-11-20 14:27:56 +01:00
committed by Beat Küng
parent 9fdb3ace0c
commit 8a4d51c630
3 changed files with 11 additions and 10 deletions
+5 -4
View File
@@ -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;