Skip to content
Snippets Groups Projects
Commit 4ee74e9b authored by Angel's avatar Angel
Browse files

fixed infinite loop when battery low

parent 2339b385
No related branches found
No related tags found
No related merge requests found
......@@ -710,7 +710,8 @@ void setBatteryStateTo(int new_battery_state)
case BATTERY_STATE_LOW:
m_battery_state = BATTERY_STATE_LOW;
ROS_INFO("changed battery state to low");
changeFlyingStateTo(STATE_LAND);
if(flying_state != STATE_MOTORS_OFF)
changeFlyingStateTo(STATE_LAND);
break;
default:
ROS_INFO("Unknown battery state command, set to normal");
......@@ -733,7 +734,8 @@ void CFBatteryCallback(const std_msgs::Float32& msg)
if((flying_state != STATE_MOTORS_OFF && (filtered_battery_voltage < m_battery_threshold_while_flying)) ||
(flying_state == STATE_MOTORS_OFF && (filtered_battery_voltage < m_battery_threshold_while_motors_off)))
{
setBatteryStateTo(BATTERY_STATE_LOW);
if(getBatteryState() != BATTERY_STATE_LOW)
setBatteryStateTo(BATTERY_STATE_LOW);
ROS_INFO("low level battery triggered");
}
else //maybe add hysteresis somewhere here?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment