FlightTasks: adapt POSIX convention to return negative values on error

This commit is contained in:
Matthias Grob
2018-04-05 07:30:12 +02:00
committed by Beat Küng
parent 8a4d51c630
commit 99eb051c0f
4 changed files with 13 additions and 11 deletions
+3 -3
View File
@@ -57,7 +57,7 @@ public:
/**
* Call regularly in the control loop cycle to execute the task
* @return 0 on success, >0 on error
* @return 0 on success, <0 on error
*/
int update()
{
@@ -87,7 +87,7 @@ public:
/**
* Switch to the next task in the available list (for testing)
* @return 0 on success, >0 on error
* @return 0 on success, <0 on error
*/
void switch_task()
{
@@ -97,7 +97,7 @@ public:
/**
* Switch to a specific task (for normal usage)
* @param task number to switch to
* @return 0 on success, >0 on error
* @return 0 on success, <0 on error
*/
int switch_task(int task_number)
{
+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;
}
}
+4 -4
View File
@@ -59,7 +59,7 @@ public:
/**
* Call once on the event where you switch to the task
* @return 0 on success, >0 on error
* @return 0 on success, <0 on error
*/
virtual int activate()
{
@@ -70,13 +70,13 @@ public:
/**
* Call once on the event of switching away from the task
* @return 0 on success, >0 on error
* @return 0 on success, <0 on error
*/
virtual int disable() { return 0; };
/**
* To be called regularly in the control loop cycle to execute the task
* @return 0 on success, >0 on error
* @return 0 on success, <0 on error
*/
virtual int update();
@@ -122,5 +122,5 @@ private:
vehicle_local_position_setpoint_s _vehicle_local_position_setpoint; /**< Output position setpoint that every task has */
void _evaluate_vehicle_position();
int _evaluate_vehicle_position();
};
@@ -136,7 +136,7 @@ int FlightTaskManual::_evaluate_sticks()
} else {
_sticks.zero(); /* default is all zero */
return 1;
return -1;
}
}