void Plane::one_second_loop() { // send a heartbeat gcs().send_message(MSG_HEARTBEAT); // make it possible to change control channel ordering at runtime set_control_channels(); #if HAVE_PX4_MIXER if (!hal.util->get_soft_armed() && (last_mixer_crc == -1)) { // if disarmed try to configure the mixer setup_failsafe_mixing(); } #endif // CONFIG_HAL_BOARD // make it possible to change orientation at runtime ahrs.set_orientation(); adsb.set_stall_speed_cm(aparm.airspeed_min); adsb.set_max_speed(aparm.airspeed_max); // sync MAVLink system ID mavlink_system.sysid = g.sysid_this_mav; update_aux(); // update notify flags AP_Notify::flags.pre_arm_check = arming.pre_arm_checks(false); AP_Notify::flags.pre_arm_gps_check = true; AP_Notify::flags.armed = arming.is_armed() || arming.arming_required() == AP_Arming::NO; #if AP_TERRAIN_AVAILABLE if (should_log(MASK_LOG_GPS)) { terrain.log_terrain_data(DataFlash); } #endif // update home position if armed and gps position has // changed. Update every 5s at most if (!arming.is_armed() && gps.last_message_time_ms() - last_home_update_ms > 5000 && gps.status() >= AP_GPS::GPS_OK_FIX_3D) { last_home_update_ms = gps.last_message_time_ms(); update_home(); // reset the landing altitude correction landing.alt_offset = 0; } // update error mask of sensors and subsystems. The mask uses the // MAV_SYS_STATUS_* values from mavlink. If a bit is set then it // indicates that the sensor or subsystem is present but not // functioning correctly update_sensor_status_flags(); }
/* read update GPS position - 10Hz update */ void Plane::update_GPS_10Hz(void) { // get position from AHRS have_position = ahrs.get_position(current_loc); static uint32_t last_gps_msg_ms; if (gps.last_message_time_ms() != last_gps_msg_ms && gps.status() >= AP_GPS::GPS_OK_FIX_3D) { last_gps_msg_ms = gps.last_message_time_ms(); if (ground_start_count > 1) { ground_start_count--; } else if (ground_start_count == 1) { // We countdown N number of good GPS fixes // so that the altitude is more accurate // ------------------------------------- if (current_loc.lat == 0) { ground_start_count = 5; } else { init_home(); // set system clock for log timestamps hal.util->set_system_clock(gps.time_epoch_usec()); if (g.compass_enabled) { // Set compass declination automatically const Location &loc = gps.location(); compass.set_initial_location(loc.lat, loc.lng); } ground_start_count = 0; } } // see if we've breached the geo-fence geofence_check(false); #if CAMERA == ENABLED if (camera.update_location(current_loc, plane.ahrs ) == true) { do_take_picture(); } #endif if (!hal.util->get_soft_armed()) { update_home(); } // update wind estimate ahrs.estimate_wind(); } calc_gndspeed_undershoot(); }
void Plane::one_second_loop() { // send a heartbeat gcs().send_message(MSG_HEARTBEAT); // make it possible to change control channel ordering at runtime set_control_channels(); #if HAL_WITH_IO_MCU iomcu.setup_mixing(&rcmap, g.override_channel.get(), g.mixing_gain, g2.manual_rc_mask); #endif // make it possible to change orientation at runtime ahrs.update_orientation(); adsb.set_stall_speed_cm(aparm.airspeed_min); adsb.set_max_speed(aparm.airspeed_max); // sync MAVLink system ID mavlink_system.sysid = g.sysid_this_mav; SRV_Channels::enable_aux_servos(); // update notify flags AP_Notify::flags.pre_arm_check = arming.pre_arm_checks(false); AP_Notify::flags.pre_arm_gps_check = true; AP_Notify::flags.armed = arming.is_armed() || arming.arming_required() == AP_Arming::Required::NO; #if AP_TERRAIN_AVAILABLE if (should_log(MASK_LOG_GPS)) { terrain.log_terrain_data(); } #endif // update home position if NOT armed and gps position has // changed. Update every 5s at most if (!arming.is_armed() && gps.last_message_time_ms() - last_home_update_ms > 5000 && gps.status() >= AP_GPS::GPS_OK_FIX_3D) { last_home_update_ms = gps.last_message_time_ms(); update_home(); // reset the landing altitude correction landing.alt_offset = 0; } // update error mask of sensors and subsystems. The mask uses the // MAV_SYS_STATUS_* values from mavlink. If a bit is set then it // indicates that the sensor or subsystem is present but not // functioning correctly gcs().update_sensor_status_flags(); }
void Plane::one_second_loop() { // send a heartbeat gcs_send_message(MSG_HEARTBEAT); // make it possible to change control channel ordering at runtime set_control_channels(); #if HAVE_PX4_MIXER if (!hal.util->get_soft_armed() && (last_mixer_crc == -1)) { // if disarmed try to configure the mixer setup_failsafe_mixing(); } #endif // CONFIG_HAL_BOARD // make it possible to change orientation at runtime ahrs.set_orientation(); adsb.set_stall_speed_cm(aparm.airspeed_min); // sync MAVLink system ID mavlink_system.sysid = g.sysid_this_mav; update_aux(); // update notify flags AP_Notify::flags.pre_arm_check = arming.pre_arm_checks(false); AP_Notify::flags.pre_arm_gps_check = true; AP_Notify::flags.armed = arming.is_armed() || arming.arming_required() == AP_Arming::NO; #if AP_TERRAIN_AVAILABLE if (should_log(MASK_LOG_GPS)) { terrain.log_terrain_data(DataFlash); } #endif ins.set_raw_logging(should_log(MASK_LOG_IMU_RAW)); // update home position if soft armed and gps position has // changed. Update every 5s at most if (!hal.util->get_soft_armed() && gps.last_message_time_ms() - last_home_update_ms > 5000 && gps.status() >= AP_GPS::GPS_OK_FIX_3D) { last_home_update_ms = gps.last_message_time_ms(); update_home(); // reset the landing altitude correction auto_state.land_alt_offset = 0; } }
void Rover::update_GPS_10Hz(void) { have_position = ahrs.get_position(current_loc); if (gps.last_message_time_ms() != last_gps_msg_ms && gps.status() >= AP_GPS::GPS_OK_FIX_3D) { last_gps_msg_ms = gps.last_message_time_ms(); if (ground_start_count > 1){ ground_start_count--; } else if (ground_start_count == 1) { // We countdown N number of good GPS fixes // so that the altitude is more accurate // ------------------------------------- if (current_loc.lat == 0) { ground_start_count = 20; } else { init_home(); // set system clock for log timestamps uint64_t gps_timestamp = gps.time_epoch_usec(); hal.util->set_system_clock(gps_timestamp); // update signing timestamp GCS_MAVLINK::update_signing_timestamp(gps_timestamp); if (g.compass_enabled) { // Set compass declination automatically compass.set_initial_location(gps.location().lat, gps.location().lng); } ground_start_count = 0; } } // get ground speed estimate from AHRS ground_speed = ahrs.groundspeed(); #if CAMERA == ENABLED if (camera.update_location(current_loc, rover.ahrs) == true) { do_take_picture(); } #endif if (!hal.util->get_soft_armed()) { update_home(); } } }
void Rover::update_GPS_10Hz(void) { have_position = ahrs.get_position(current_loc); if (gps.last_message_time_ms() != last_gps_msg_ms && gps.status() >= AP_GPS::GPS_OK_FIX_3D) { last_gps_msg_ms = gps.last_message_time_ms(); if (ground_start_count > 1){ ground_start_count--; } else if (ground_start_count == 1) { // We countdown N number of good GPS fixes // so that the altitude is more accurate // ------------------------------------- if (current_loc.lat == 0) { ground_start_count = 20; } else { init_home(); // set system clock for log timestamps hal.util->set_system_clock(gps.time_epoch_usec()); if (g.compass_enabled) { // Set compass declination automatically compass.set_initial_location(gps.location().lat, gps.location().lng); } ground_start_count = 0; } } Vector3f velocity; if (ahrs.get_velocity_NED(velocity)) { ground_speed = pythagorous2(velocity.x, velocity.y); } else { ground_speed = gps.ground_speed(); } #if CAMERA == ENABLED if (camera.update_location(current_loc, rover.ahrs) == true) { do_take_picture(); } #endif if (!hal.util->get_soft_armed()) { update_home(); } } }
/* once a second events */ void Rover::one_second_loop(void) { // send a heartbeat gcs().send_message(MSG_HEARTBEAT); // allow orientation change at runtime to aid config ahrs.set_orientation(); set_control_channels(); // cope with changes to aux functions update_aux(); // update notify flags AP_Notify::flags.pre_arm_check = arming.pre_arm_checks(false); AP_Notify::flags.pre_arm_gps_check = true; AP_Notify::flags.armed = arming.is_armed() || arming.arming_required() == AP_Arming::NO; // cope with changes to mavlink system ID mavlink_system.sysid = g.sysid_this_mav; static uint8_t counter; counter++; // save compass offsets once a minute if (counter >= 60) { if (g.compass_enabled) { compass.save_offsets(); } counter = 0; } // update home position if not soft armed and gps position has // changed. Update every 1s at most if (!hal.util->get_soft_armed() && gps.status() >= AP_GPS::GPS_OK_FIX_3D) { update_home(); } // update error mask of sensors and subsystems. The mask uses the // MAV_SYS_STATUS_* values from mavlink. If a bit is set then it // indicates that the sensor or subsystem is present but not // functioning correctly update_sensor_status_flags(); }