fixed somereview comments

This commit is contained in:
Friedemann Ludwig
2014-11-30 20:51:01 +01:00
parent 8e8b622f4f
commit 6efc63d709
2 changed files with 9 additions and 7 deletions
@@ -768,8 +768,7 @@ FixedwingAttitudeControl::task_main()
if (_att_sp.yaw_reset_integral) {
_yaw_ctrl.reset_integrator();
}
}
else if (_vcontrol_mode.flag_control_velocity_enabled) {
} else if (_vcontrol_mode.flag_control_velocity_enabled) {
/*
* Velocity should be controlled and manual is enabled.
*/
@@ -164,6 +164,7 @@ private:
perf_counter_t _loop_perf; /**< loop performance counter */
float _hold_alt; /**< hold altitude for velocity mode */
hrt_abstime _control_position_last_called; /**<last call of control_position */
/* land states */
bool land_noreturn_horizontal;
@@ -448,6 +449,9 @@ FixedwingPositionControl::FixedwingPositionControl() :
/* performance counters */
_loop_perf(perf_alloc(PC_ELAPSED, "fw l1 control")),
_hold_alt(0.0f),
_control_position_last_called(0),
land_noreturn_horizontal(false),
land_noreturn_vertical(false),
land_stayonground(false),
@@ -877,12 +881,11 @@ bool
FixedwingPositionControl::control_position(const math::Vector<2> &current_position, const math::Vector<3> &ground_speed,
const struct position_setpoint_triplet_s &pos_sp_triplet)
{
static hrt_abstime functionLastCalled = 0;
float dt = 0.0f;
if (functionLastCalled > 0) {
dt = (float)hrt_elapsed_time(&functionLastCalled) * 1e-6f;
float dt = FLT_MIN; // Using non zero value to a avoid division by zero
if (_control_position_last_called > 0) {
dt = (float)hrt_elapsed_time(&_control_position_last_called) * 1e-6f;
}
functionLastCalled = hrt_absolute_time();
_control_position_last_called = hrt_absolute_time();
bool setpoint = true;