FlightTasks: adapt POSIX convention to return negative values on error

This commit is contained in:
Matthias Grob
2017-11-20 16:58:45 +01:00
committed by Beat Küng
parent 8a4d51c630
commit 99eb051c0f
4 changed files with 13 additions and 11 deletions
+5 -3
View File
@@ -10,18 +10,20 @@ int FlightTask::update()
_deltatime = math::min((_time_stamp_current - _time_stamp_last), _timeout) / 1e6f;
_time_stamp_last = _time_stamp_current;
updateSubscriptions();
_evaluate_vehicle_position();
return 0;
int ret = _evaluate_vehicle_position();
return ret;
}
void FlightTask::_evaluate_vehicle_position()
int FlightTask::_evaluate_vehicle_position()
{
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;
return 0;
} else {
_velocity.zero(); /* default velocity is all zero */
return -1;
}
}