void nps_autopilot_run_step(double time) { nps_electrical_run_step(time); #if RADIO_CONTROL && !RADIO_CONTROL_TYPE_DATALINK if (nps_radio_control_available(time)) { radio_control_feed(); main_event(); } #endif if (nps_sensors_gyro_available()) { imu_feed_gyro_accel(); main_event(); } if (nps_sensors_mag_available()) { imu_feed_mag(); main_event(); } if (nps_sensors_baro_available()) { float pressure = (float) sensors.baro.value; AbiSendMsgBARO_ABS(BARO_SIM_SENDER_ID, pressure); main_event(); } #if USE_SONAR if (nps_sensors_sonar_available()) { float dist = (float) sensors.sonar.value; AbiSendMsgAGL(AGL_SONAR_NPS_ID, dist); uint16_t foo = 0; DOWNLINK_SEND_SONAR(DefaultChannel, DefaultDevice, &foo, &dist); main_event(); } #endif if (nps_sensors_gps_available()) { gps_feed_value(); main_event(); } if (nps_bypass_ahrs) { sim_overwrite_ahrs(); } if (nps_bypass_ins) { sim_overwrite_ins(); } handle_periodic_tasks(); /* scale final motor commands to 0-1 for feeding the fdm */ for (uint8_t i = 0; i < NPS_COMMANDS_NB; i++) { autopilot.commands[i] = (double)motor_mixing.commands[i] / MAX_PPRZ; } }
void nps_autopilot_run_step(double time __attribute__ ((unused))) { if (nps_radio_control_available(time)) { radio_control_feed(); main_event(); } if (nps_sensors_gyro_available()) { imu_feed_gyro_accel(); main_event(); } if (nps_sensors_mag_available()) { imu_feed_mag(); main_event(); } if (nps_sensors_baro_available()) { baro_feed_value(sensors.baro.value); main_event(); } if (nps_sensors_gps_available()) { booz_gps_feed_value(); main_event(); } if (nps_bypass_ahrs) { sim_overwrite_ahrs(); } main_periodic(); if (time < 8) { /* start with a little bit of hovering */ int32_t init_cmd[4]; init_cmd[COMMAND_THRUST] = 0.253*SUPERVISION_MAX_MOTOR; init_cmd[COMMAND_ROLL] = 0; init_cmd[COMMAND_PITCH] = 0; init_cmd[COMMAND_YAW] = 0; supervision_run(TRUE, FALSE, init_cmd); } for (uint8_t i=0; i<ACTUATORS_MKK_NB; i++) autopilot.commands[i] = (double)supervision.commands[i] / SUPERVISION_MAX_MOTOR; }
void nps_autopilot_run_step(double time __attribute__ ((unused))) { if (nps_radio_control_available(time)) { radio_control_feed(); main_event(); } if (nps_sensors_gyro_available()) { imu_feed_gyro_accel(); main_event(); } if (nps_sensors_mag_available()) { imu_feed_mag(); main_event(); } if (nps_sensors_baro_available()) { baro_feed_value(sensors.baro.value); main_event(); } if (nps_sensors_gps_available()) { gps_feed_value(); main_event(); } if (nps_bypass_ahrs) { sim_overwrite_ahrs(); } handle_periodic_tasks(); /* scale final motor commands to 0-1 for feeding the fdm */ /* FIXME: autopilot.commands is of length NB_COMMANDS instead of number of motors */ for (uint8_t i=0; i<SUPERVISION_NB_MOTOR; i++) autopilot.commands[i] = (double)(supervision.commands[i] - SUPERVISION_MIN_MOTOR) / SUPERVISION_MAX_MOTOR; }