Browse Source

launchdetection: send warning to qgc every 4s

sbg
Thomas Gubler 11 years ago
parent
commit
ac7787e2a2
  1. 12
      src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp

12
src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp

@ -175,7 +175,6 @@ private:
/* takeoff/launch states */ /* takeoff/launch states */
bool launch_detected; bool launch_detected;
bool usePreTakeoffThrust; bool usePreTakeoffThrust;
bool launch_detection_message_sent;
/* Landingslope object */ /* Landingslope object */
Landingslope landingslope; Landingslope landingslope;
@ -397,8 +396,7 @@ FixedwingPositionControl::FixedwingPositionControl() :
_mavlink_fd(-1), _mavlink_fd(-1),
launchDetector(), launchDetector(),
launch_detected(false), launch_detected(false),
usePreTakeoffThrust(false), usePreTakeoffThrust(false)
launch_detection_message_sent(false)
{ {
/* safely initialize structs */ /* safely initialize structs */
vehicle_attitude_s _att = {0}; vehicle_attitude_s _att = {0};
@ -985,10 +983,11 @@ FixedwingPositionControl::control_position(const math::Vector2f &current_positio
// warnx("Launch detection running"); // warnx("Launch detection running");
if(!launch_detected) { //do not do further checks once a launch was detected if(!launch_detected) { //do not do further checks once a launch was detected
if (launchDetector.launchDetectionEnabled()) { if (launchDetector.launchDetectionEnabled()) {
// warnx("Launch detection enabled"); static hrt_abstime last_sent = 0;
if(!launch_detection_message_sent) { if(hrt_absolute_time() - last_sent > 4e6) {
// warnx("Launch detection running");
mavlink_log_info(_mavlink_fd, "#audio: Launchdetection running"); mavlink_log_info(_mavlink_fd, "#audio: Launchdetection running");
launch_detection_message_sent = true; last_sent = hrt_absolute_time();
} }
launchDetector.update(_sensor_combined.accelerometer_m_s2[0]); launchDetector.update(_sensor_combined.accelerometer_m_s2[0]);
if (launchDetector.getLaunchDetected()) { if (launchDetector.getLaunchDetected()) {
@ -1057,7 +1056,6 @@ FixedwingPositionControl::control_position(const math::Vector2f &current_positio
if (mission_item_triplet.current.nav_cmd != NAV_CMD_TAKEOFF) { if (mission_item_triplet.current.nav_cmd != NAV_CMD_TAKEOFF) {
launch_detected = false; launch_detected = false;
usePreTakeoffThrust = false; usePreTakeoffThrust = false;
launch_detection_message_sent = false;
} }
if (was_circle_mode && !_l1_control.circle_mode()) { if (was_circle_mode && !_l1_control.circle_mode()) {

Loading…
Cancel
Save