예제 #1
0
파일: main.c 프로젝트: paparazzi/paparazzi
STATIC_INLINE void handle_periodic_tasks(void)
{
    if (sys_time_check_and_ack_timer(main_periodic_tid)) {
        main_periodic();
#if PERIODIC_FREQUENCY == MODULES_FREQUENCY
        /* Use the main periodc freq timer for modules if the freqs are the same
         * This is mainly useful for logging each step.
         */
        modules_periodic_task();
#else
    }
    /* separate timer for modules, since it has a different freq than main */
    if (sys_time_check_and_ack_timer(modules_tid)) {
        modules_periodic_task();
#endif
    }
    if (sys_time_check_and_ack_timer(radio_control_tid)) {
        radio_control_periodic_task();
    }
    if (sys_time_check_and_ack_timer(failsafe_tid)) {
        failsafe_check();
    }
    if (sys_time_check_and_ack_timer(electrical_tid)) {
        electrical_periodic();
    }
    if (sys_time_check_and_ack_timer(telemetry_tid)) {
        telemetry_periodic();
    }
#if USE_BARO_BOARD
    if (sys_time_check_and_ack_timer(baro_tid)) {
        baro_periodic();
    }
#endif
}
예제 #2
0
파일: main_ap.c 프로젝트: WenFly123/openPPZ
void handle_periodic_tasks_ap(void) 
{

  if (sys_time_check_and_ack_timer(sensors_tid))
    sensors_task();//imu数据读取

  if (sys_time_check_and_ack_timer(navigation_tid))
    navigation_task();//估算期望的航线,故障保护

#ifndef AHRS_TRIGGERED_ATTITUDE_LOOP
  if (sys_time_check_and_ack_timer(attitude_tid))
    attitude_loop();//姿态循环
#endif

  if (sys_time_check_and_ack_timer(modules_tid))
    modules_periodic_task();//没有该函数说明

  if (sys_time_check_and_ack_timer(monitor_tid))
    monitor_task();//监听

  if (sys_time_check_and_ack_timer(telemetry_tid)) 
  {
    reporting_task();//汇报
    LED_PERIODIC();
  }

}
예제 #3
0
파일: main.c 프로젝트: budebulai/paparazzi
STATIC_INLINE void handle_periodic_tasks(void)
{
  if (sys_time_check_and_ack_timer(main_periodic_tid)) {
    main_periodic();
  }
  if (sys_time_check_and_ack_timer(modules_tid)) {
    modules_periodic_task();
  }
  if (sys_time_check_and_ack_timer(radio_control_tid)) {
    radio_control_periodic_task();
  }
  if (sys_time_check_and_ack_timer(failsafe_tid)) {
    failsafe_check();
  }
  if (sys_time_check_and_ack_timer(electrical_tid)) {
    electrical_periodic();
  }
  if (sys_time_check_and_ack_timer(telemetry_tid)) {
    telemetry_periodic();
  }
#if USE_BARO_BOARD
  if (sys_time_check_and_ack_timer(baro_tid)) {
    baro_periodic();
  }
#endif
}
예제 #4
0
void handle_periodic_tasks_ap(void) {

  if (sys_time_check_and_ack_timer(sensors_tid))
    sensors_task();

  if (sys_time_check_and_ack_timer(navigation_tid))
    navigation_task();

#ifndef AHRS_TRIGGERED_ATTITUDE_LOOP
  if (sys_time_check_and_ack_timer(attitude_tid))
    attitude_loop();
#endif

  if (sys_time_check_and_ack_timer(modules_tid))
    modules_periodic_task();

  if (sys_time_check_and_ack_timer(monitor_tid))
    monitor_task();

  if (sys_time_check_and_ack_timer(telemetry_tid)) {
    reporting_task();
    LED_PERIODIC();
  }

}
예제 #5
0
파일: main.c 프로젝트: EwoudSmeur/paparazzi
static inline void main_periodic_task(void)
{
  LED_TOGGLE(1);
  DOWNLINK_SEND_TAKEOFF(&motor_power);
  wt_baro_periodic();
  modules_periodic_task();
  DOWNLINK_SEND_DEBUG(3, buf_input);
}
예제 #6
0
파일: sim_ap.c 프로젝트: CheBuzz/paparazzi
value sim_periodic_task(value unit) {
  sensors_task();
  attitude_loop();
  reporting_task();
  modules_periodic_task();
  periodic_task_fbw();
  event_task_ap();
  event_task_fbw();
  return unit;
}
예제 #7
0
STATIC_INLINE void main_periodic( void ) {

  imu_periodic();

  /* run control loops */
  autopilot_periodic();
  /* set actuators     */
  actuators_set(autopilot_motors_on);

  modules_periodic_task();

  if (autopilot_in_flight) {
    RunOnceEvery(PERIODIC_FREQUENCY, { autopilot_flight_time++; datalink_time++; });
  }
예제 #8
0
static inline void main_periodic_task(void)
{
  /* Simply set current roll/pitch as commands.
   * Scale DEMO_MAX_ROLL/PITCH to MAX_PPRZ (the max commands)
   */
  commands[COMMAND_ROLL] = stateGetNedToBodyEulers_f()->phi * MAX_PPRZ / DEMO_MAX_ROLL;
  commands[COMMAND_PITCH] = stateGetNedToBodyEulers_f()->theta * MAX_PPRZ / DEMO_MAX_ROLL;

  /* generated macro from airframe file, seconds AP_MODE param not used */
  SetActuatorsFromCommands(commands, 0);

  if (sys_time.nb_sec > 1) {
    modules_periodic_task();
  }
  RunOnceEvery(10, { LED_PERIODIC();});
예제 #9
0
파일: main.c 프로젝트: JadeGeek/paparazzi
STATIC_INLINE void handle_periodic_tasks( void ) {
  if (sys_time_check_and_ack_timer(main_periodic_tid))
    main_periodic();
  if (sys_time_check_and_ack_timer(modules_tid))
    modules_periodic_task();
  if (sys_time_check_and_ack_timer(radio_control_tid))
    radio_control_periodic_task();
  if (sys_time_check_and_ack_timer(failsafe_tid))
    failsafe_check();
  if (sys_time_check_and_ack_timer(electrical_tid))
    electrical_periodic();
  if (sys_time_check_and_ack_timer(baro_tid))
    baro_periodic();
  if (sys_time_check_and_ack_timer(telemetry_tid))
    telemetry_periodic();
}
예제 #10
0
value sim_periodic_task(value unit)
{
  sensors_task();
#if USE_GENERATED_AUTOPILOT
  autopilot_periodic();
#else
  attitude_loop();
#endif
  reporting_task();
  modules_periodic_task();
  periodic_task_fbw();
  electrical_periodic();
  event_task_ap();
  event_task_fbw();
  return unit;
}
예제 #11
0
void handle_periodic_tasks_ap(void)
{

  if (sys_time_check_and_ack_timer(sensors_tid)) {
    sensors_task();
  }

#if USE_BARO_BOARD
  if (sys_time_check_and_ack_timer(baro_tid)) {
    baro_periodic();
  }
#endif

#if USE_GENERATED_AUTOPILOT
  if (sys_time_check_and_ack_timer(attitude_tid)) {
    autopilot_periodic();
  }
#else
  // static autopilot
  if (sys_time_check_and_ack_timer(navigation_tid)) {
    navigation_task();
  }

#ifndef AHRS_TRIGGERED_ATTITUDE_LOOP
  if (sys_time_check_and_ack_timer(attitude_tid)) {
    attitude_loop();
  }
#endif

#endif

  if (sys_time_check_and_ack_timer(modules_tid)) {
    modules_periodic_task();
  }

  if (sys_time_check_and_ack_timer(monitor_tid)) {
    monitor_task();
  }

  if (sys_time_check_and_ack_timer(telemetry_tid)) {
    reporting_task();
    LED_PERIODIC();
  }

}
예제 #12
0
STATIC_INLINE void handle_periodic_tasks(void)
{
  if (sys_time_check_and_ack_timer(main_periodic_tid)) {
    main_periodic();
  }
  if (sys_time_check_and_ack_timer(modules_tid)) {
    modules_periodic_task();
  }
  if (sys_time_check_and_ack_timer(radio_control_tid)) {
    radio_control_periodic_task();
  }
  if (sys_time_check_and_ack_timer(electrical_tid)) {
    electrical_periodic();
  }
  if (sys_time_check_and_ack_timer(telemetry_tid)) {
    telemetry_periodic();
  }
}
예제 #13
0
파일: main_ap.c 프로젝트: lxl/paparazzi
void periodic_task_ap( void ) {

  static uint8_t _60Hz = 0;
  static uint8_t _20Hz = 0;
  static uint8_t _10Hz = 0;
  static uint8_t _4Hz  = 0;
  static uint8_t _1Hz  = 0;

#ifdef USE_IMU
  // Run at PERIODIC_FREQUENCY (60Hz if not defined)
  imu_periodic();

#endif // USE_IMU

#define _check_periodic_freq_ PERIODIC_FREQUENCY % 60
#if _check_periodic_freq_
#error Using HighSpeed Periodic: PERIODIC_FREQUENCY has to be a multiple of 60!
#endif
  _60Hz++;
  if (_60Hz >= (PERIODIC_FREQUENCY / 60))
  {
    _60Hz = 0;
  }
  else
  {
    return;
  }


  // Rest of the periodic function still runs at 60Hz like always
  _20Hz++;
  if (_20Hz>=3) _20Hz=0;
  _10Hz++;
  if (_10Hz>=6) _10Hz=0;
  _4Hz++;
  if (_4Hz>=15) _4Hz=0;
  _1Hz++;
  if (_1Hz>=60) _1Hz=0;

  reporting_task();

  if (!_1Hz) {
    if (estimator_flight_time) estimator_flight_time++;
#if defined DATALINK || defined SITL
    datalink_time++;
#endif

    static uint8_t t = 0;
    if (vsupply < LOW_BATTERY_DECIVOLT) t++; else t = 0;
    kill_throttle |= (t >= LOW_BATTERY_DELAY);
    kill_throttle |= launch && (dist2_to_home > Square(KILL_MODE_DISTANCE));
  }

  switch(_4Hz) {
  case 0:
#ifdef SITL
#ifdef GPS_TRIGGERED_FUNCTION
    GPS_TRIGGERED_FUNCTION();
#endif
#endif
    estimator_propagate_state();
#ifdef EXTRA_DOWNLINK_DEVICE
    DOWNLINK_SEND_ATTITUDE(ExtraPprzTransport,&estimator_phi,&estimator_psi,&estimator_theta);
#endif
    navigation_task();
    break;
  case 1:
    if (!estimator_flight_time &&
    estimator_hspeed_mod > MIN_SPEED_FOR_TAKEOFF) {
      estimator_flight_time = 1;
      launch = TRUE; /* Not set in non auto launch */
      DOWNLINK_SEND_TAKEOFF(DefaultChannel, &cpu_time_sec);
  default:
    break;
    }

    break;

#ifdef USE_GPIO
  case 3:
    GpioUpdate1();
    break;
#endif

    /*  default: */
  }

#ifndef CONTROL_RATE
#define CONTROL_RATE 20
#endif

#if CONTROL_RATE != 60 && CONTROL_RATE != 20
#error "Only 20 and 60 allowed for CONTROL_RATE"
#endif

#if CONTROL_RATE == 20
  if (!_20Hz)
#endif
    {

#ifndef AHRS_TRIGGERED_ATTITUDE_LOOP
      attitude_loop();
#endif

    }


  modules_periodic_task();
}
예제 #14
0
파일: main_ap.c 프로젝트: agreee45/SNUT
void periodic_task_ap( void ) {
  static uint8_t _20Hz   = 0;
  static uint8_t _10Hz   = 0;
  static uint8_t _4Hz   = 0;
  static uint8_t _1Hz   = 0;

  _20Hz++;
  if (_20Hz>=3) _20Hz=0;
  _10Hz++;
  if (_10Hz>=6) _10Hz=0;
  _4Hz++;
  if (_4Hz>=15) _4Hz=0;
  _1Hz++;
  if (_1Hz>=60) _1Hz=0;

  reporting_task();

  if (!_1Hz) {
    if (estimator_flight_time) estimator_flight_time++;
#if defined DATALINK || defined SITL
    datalink_time++;
#endif

    static uint8_t t = 0;
    if (vsupply < LOW_BATTERY_DECIVOLT) t++; else t = 0;
    kill_throttle |= (t >= LOW_BATTERY_DELAY);
    kill_throttle |= launch && (dist2_to_home > Square(KILL_MODE_DISTANCE));
  }

  switch(_4Hz) {
  case 0:
#ifdef SITL
#ifdef GPS_TRIGGERED_FUNCTION
    GPS_TRIGGERED_FUNCTION();
#endif
#endif
    estimator_propagate_state();
#ifdef EXTRA_DOWNLINK_DEVICE
    DOWNLINK_SEND_ATTITUDE(ExtraPprzTransport,&estimator_phi,&estimator_psi,&estimator_theta);
#endif
    navigation_task();
    break;
  case 1:
    if (!estimator_flight_time &&
    estimator_hspeed_mod > MIN_SPEED_FOR_TAKEOFF) {
      estimator_flight_time = 1;
      launch = TRUE; /* Not set in non auto launch */
      DOWNLINK_SEND_TAKEOFF(DefaultChannel, &cpu_time_sec);
  default:
    break;
    }

    break;

#ifdef USE_GPIO
  case 3:
    GpioUpdate1();
    break;
#endif

    /*  default: */
  }

#ifndef CONTROL_RATE
#define CONTROL_RATE 20
#endif

#if CONTROL_RATE != 60 && CONTROL_RATE != 20
#error "Only 20 and 60 allowed for CONTROL_RATE"
#endif

#ifdef USE_ANALOG_IMU
  if (!_20Hz) {
    imu_periodic();
  }
#endif // USE_ANALOG_IMU

#if CONTROL_RATE == 20
  if (!_20Hz)
#endif
    {

#ifdef USE_GYRO
      gyro_update();
#endif

#ifdef USE_INFRARED
      infrared_update();
      estimator_update_state_infrared();
#endif /* USE_INFRARED */
      h_ctl_attitude_loop(); /* Set  h_ctl_aileron_setpoint & h_ctl_elevator_setpoint */
      v_ctl_throttle_slew();
      ap_state->commands[COMMAND_THROTTLE] = v_ctl_throttle_slewed;
      ap_state->commands[COMMAND_ROLL] = h_ctl_aileron_setpoint;
      ap_state->commands[COMMAND_PITCH] = h_ctl_elevator_setpoint;

#if defined MCU_SPI_LINK
      link_mcu_send();
#elif defined INTER_MCU && defined SINGLE_MCU
      /**Directly set the flag indicating to FBW that shared buffer is available*/
      inter_mcu_received_ap = TRUE;
#endif

    }

  modules_periodic_task();
}