当前位置: 首页>>代码示例>>C++>>正文


C++ RunOnceEvery函数代码示例

本文整理汇总了C++中RunOnceEvery函数的典型用法代码示例。如果您正苦于以下问题:C++ RunOnceEvery函数的具体用法?C++ RunOnceEvery怎么用?C++ RunOnceEvery使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了RunOnceEvery函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main_periodic

STATIC_INLINE void main_periodic(void)
{

#if USE_IMU
  imu_periodic();
#endif

  //FIXME: temporary hack, remove me
#ifdef InsPeriodic
  InsPeriodic();
#endif

  /* run control loops */
  autopilot_periodic();
  /* set actuators     */
  //actuators_set(autopilot_motors_on);
  SetActuatorsFromCommands(commands, autopilot_mode);

  if (autopilot_in_flight) {
    RunOnceEvery(PERIODIC_FREQUENCY, autopilot_flight_time++);
  }

#if defined DATALINK || defined SITL
  RunOnceEvery(PERIODIC_FREQUENCY, datalink_time++);
#endif

  RunOnceEvery(10, LED_PERIODIC());
}
开发者ID:budebulai,项目名称:paparazzi,代码行数:28,代码来源:main.c

示例2: main_periodic

STATIC_INLINE void main_periodic(void)
{
#if INTER_MCU_AP
    /* Inter-MCU watchdog */
    intermcu_periodic();
#endif

    /* run control loops */
    autopilot_periodic();
    /* set actuators     */
    //actuators_set(autopilot_motors_on);
#ifndef INTER_MCU_AP
    SetActuatorsFromCommands(commands, autopilot_mode);
#else
    intermcu_set_actuators(commands, autopilot_mode);
#endif

    if (autopilot_in_flight) {
        RunOnceEvery(PERIODIC_FREQUENCY, autopilot_flight_time++);
    }

#if defined DATALINK || defined SITL
    RunOnceEvery(PERIODIC_FREQUENCY, datalink_time++);
#endif

    RunOnceEvery(10, LED_PERIODIC());
}
开发者ID:paparazzi,项目名称:paparazzi,代码行数:27,代码来源:main.c

示例3: parse_ins_msg

void parse_ins_msg( void )
{
  while (InsLink(ChAvailable()))
  {
    uint8_t ch = InsLink(Getch());
    
    if (CHIMU_Parse(ch, 0, &CHIMU_DATA))
    {
      if(CHIMU_DATA.m_MsgID==0x03)
      {
	new_ins_attitude = 1;
	RunOnceEvery(25, LED_TOGGLE(3) );
	if (CHIMU_DATA.m_attitude.euler.phi > M_PI)
	{
	  CHIMU_DATA.m_attitude.euler.phi -= 2 * M_PI;
	}
	
	EstimatorSetAtt(CHIMU_DATA.m_attitude.euler.phi, CHIMU_DATA.m_attitude.euler.psi, CHIMU_DATA.m_attitude.euler.theta);
	EstimatorSetRate(CHIMU_DATA.m_sensor.rate[0],CHIMU_DATA.m_attrates.euler.theta);
      }
      else if(CHIMU_DATA.m_MsgID==0x02)
      {
	
	RunOnceEvery(25,DOWNLINK_SEND_AHRS_EULER(DefaultChannel, &CHIMU_DATA.m_sensor.rate[0], &CHIMU_DATA.m_sensor.rate[1], &CHIMU_DATA.m_sensor.rate[2]));
	
      }
    }
  }
}
开发者ID:aibara,项目名称:paparazzi,代码行数:29,代码来源:ins_chimu_spi.c

示例4: autopilot_periodic

void autopilot_periodic(void)
{

  RunOnceEvery(NAV_PRESCALER, compute_dist2_to_home());

  if (autopilot_in_flight && autopilot_mode == AP_MODE_NAV) {
    if (too_far_from_home || datalink_lost() || higher_than_max_altitude()) {
      if (dist2_to_home > failsafe_mode_dist2) {
        autopilot_set_mode(FAILSAFE_MODE_TOO_FAR_FROM_HOME);
      } else {
        autopilot_set_mode(AP_MODE_HOME);
      }
    }
  }

  if (autopilot_mode == AP_MODE_HOME) {
    RunOnceEvery(NAV_PRESCALER, nav_home());
  } else {
    // otherwise always call nav_periodic_task so that carrot is always updated in GCS for other modes
    RunOnceEvery(NAV_PRESCALER, nav_periodic_task());
  }


  /* If in FAILSAFE mode and either already not in_flight anymore
   * or just "detected" ground, go to KILL mode.
   */
  if (autopilot_mode == AP_MODE_FAILSAFE) {
    if (!autopilot_in_flight) {
      autopilot_set_mode(AP_MODE_KILL);
    }

#if FAILSAFE_GROUND_DETECT
    INFO("Using FAILSAFE_GROUND_DETECT: KILL")
    if (autopilot_ground_detected) {
      autopilot_set_mode(AP_MODE_KILL);
    }
#endif
  }

  /* Reset ground detection _after_ running flight plan
   */
  if (!autopilot_in_flight) {
    autopilot_ground_detected = false;
    autopilot_detect_ground_once = false;
  }

  /* Set fixed "failsafe" commands from airframe file if in KILL mode.
   * If in FAILSAFE mode, run normal loops with failsafe attitude and
   * downwards velocity setpoints.
   */
  if (autopilot_mode == AP_MODE_KILL) {
    SetCommands(commands_failsafe);
  } else {
    guidance_v_run(autopilot_in_flight);
    guidance_h_run(autopilot_in_flight);
    SetRotorcraftCommands(stabilization_cmd, autopilot_in_flight, autopilot_motors_on);
  }

}
开发者ID:ls90911,项目名称:ppzr,代码行数:59,代码来源:autopilot.c

示例5: periodic_task_fbw

void periodic_task_fbw(void) {
    /* static float t; */
    /* t += 1./60.; */
    /* uint16_t servo_value = 1500+ 500*sin(t); */
    /* SetServo(SERVO_THROTTLE, servo_value); */

    RunOnceEvery(300, DOWNLINK_SEND_ALIVE(DefaultChannel, DefaultDevice, 16, MD5SUM));
    RunOnceEvery(300, DOWNLINK_SEND_ACTUATORS(DefaultChannel, DefaultDevice, SERVOS_NB, actuators ));
}
开发者ID:Paolo-Maffei,项目名称:lxyppc-tetrix,代码行数:9,代码来源:setup_actuators.c

示例6: autopilot_periodic

void autopilot_periodic(void) {

  if (autopilot_in_flight) {
    if (too_far_from_home) {
      if (dist2_to_home > failsafe_mode_dist2)
        autopilot_set_mode(FAILSAFE_MODE_TOO_FAR_FROM_HOME);
      else
        autopilot_set_mode(AP_MODE_HOME);
    }
  }

  if (autopilot_mode == AP_MODE_HOME) {
    RunOnceEvery(NAV_PRESCALER, nav_home());
  }
  else {
    RunOnceEvery(NAV_PRESCALER, nav_periodic_task());
  }


  /* If in FAILSAFE mode and either already not in_flight anymore
   * or just "detected" ground, go to KILL mode.
   */
  if (autopilot_mode == AP_MODE_FAILSAFE) {
    if (!autopilot_in_flight)
      autopilot_set_mode(AP_MODE_KILL);

#if FAILSAFE_GROUND_DETECT
INFO("Using FAILSAFE_GROUND_DETECT: KILL")
    if (autopilot_ground_detected)
      autopilot_set_mode(AP_MODE_KILL);
#endif
  }

  /* Reset ground detection _after_ running flight plan
   */
  if (!autopilot_in_flight || autopilot_ground_detected) {
    autopilot_ground_detected = FALSE;
    autopilot_detect_ground_once = FALSE;
  }

  /* Set fixed "failsafe" commands from airframe file if in KILL mode.
   * If in FAILSAFE mode, run normal loops with failsafe attitude and
   * downwards velocity setpoints.
   */
  if (autopilot_mode == AP_MODE_KILL) {
    SetCommands(commands_failsafe);
  }
  else {
    guidance_v_run( autopilot_in_flight );
    guidance_h_run( autopilot_in_flight );
    SetRotorcraftCommands(stabilization_cmd, autopilot_in_flight, autopilot_motors_on);
  }

}
开发者ID:jouvencel,项目名称:paparazzi,代码行数:54,代码来源:autopilot.c

示例7: ArduIMU_event

void ArduIMU_event(void)
{
  // Handle INS I2C event
  if (ardu_ins_trans.status == I2CTransSuccess) {
    // received data from I2C transaction
    recievedData[0] = (ardu_ins_trans.buf[1] << 8) | ardu_ins_trans.buf[0];
    recievedData[1] = (ardu_ins_trans.buf[3] << 8) | ardu_ins_trans.buf[2];
    recievedData[2] = (ardu_ins_trans.buf[5] << 8) | ardu_ins_trans.buf[4];
    recievedData[3] = (ardu_ins_trans.buf[7] << 8) | ardu_ins_trans.buf[6];
    recievedData[4] = (ardu_ins_trans.buf[9] << 8) | ardu_ins_trans.buf[8];
    recievedData[5] = (ardu_ins_trans.buf[11] << 8) | ardu_ins_trans.buf[10];
    recievedData[6] = (ardu_ins_trans.buf[13] << 8) | ardu_ins_trans.buf[12];
    recievedData[7] = (ardu_ins_trans.buf[15] << 8) | ardu_ins_trans.buf[14];
    recievedData[8] = (ardu_ins_trans.buf[17] << 8) | ardu_ins_trans.buf[16];

    // Update ArduIMU data
    arduimu_eulers.phi = ANGLE_FLOAT_OF_BFP(recievedData[0]) - ins_roll_neutral;
    arduimu_eulers.theta = ANGLE_FLOAT_OF_BFP(recievedData[1]) - ins_pitch_neutral;
    arduimu_eulers.psi = ANGLE_FLOAT_OF_BFP(recievedData[2]);
    arduimu_rates.p = RATE_FLOAT_OF_BFP(recievedData[3]);
    arduimu_rates.q = RATE_FLOAT_OF_BFP(recievedData[4]);
    arduimu_rates.r = RATE_FLOAT_OF_BFP(recievedData[5]);
    arduimu_accel.x = ACCEL_FLOAT_OF_BFP(recievedData[6]);
    arduimu_accel.y = ACCEL_FLOAT_OF_BFP(recievedData[7]);
    arduimu_accel.z = ACCEL_FLOAT_OF_BFP(recievedData[8]);

    // Update estimator
    stateSetNedToBodyEulers_f(&arduimu_eulers);
    stateSetBodyRates_f(&arduimu_rates);
    stateSetAccelNed_f(&((struct NedCoor_f)arduimu_accel));
    ardu_ins_trans.status = I2CTransDone;

#ifdef ARDUIMU_SYNC_SEND
    // uint8_t arduimu_id = 102;
    //RunOnceEvery(15, DOWNLINK_SEND_AHRS_EULER(DefaultChannel, DefaultDevice, &arduimu_eulers.phi, &arduimu_eulers.theta, &arduimu_eulers.psi, &arduimu_id));
    RunOnceEvery(15, DOWNLINK_SEND_IMU_GYRO(DefaultChannel, DefaultDevice, &arduimu_rates.p, &arduimu_rates.q,
                                            &arduimu_rates.r));
    RunOnceEvery(15, DOWNLINK_SEND_IMU_ACCEL(DefaultChannel, DefaultDevice, &arduimu_accel.x, &arduimu_accel.y,
                 &arduimu_accel.z));
#endif
  } else if (ardu_ins_trans.status == I2CTransFailed) {
    ardu_ins_trans.status = I2CTransDone;
  }
  // Handle GPS I2C event
  if (ardu_gps_trans.status == I2CTransSuccess || ardu_gps_trans.status == I2CTransFailed) {
    ardu_gps_trans.status = I2CTransDone;
  }
}
开发者ID:AE4317group07,项目名称:paparazzi,代码行数:48,代码来源:ins_arduimu_basic.c

示例8: actuators_mkk_v2_set

void actuators_mkk_v2_set(void)
{
#if defined ACTUATORS_START_DELAY && ! defined SITL
  if (!actuators_delay_done) {
    if (SysTimeTimer(actuators_delay_time) < USEC_OF_SEC(ACTUATORS_START_DELAY)) { return; }
    else { actuators_delay_done = TRUE; }
  }
#endif

  // Read result
  for (uint8_t i = 0; i < ACTUATORS_MKK_V2_NB; i++) {
    if (actuators_mkk_v2.trans[i].type != I2CTransTx) {
      actuators_mkk_v2.trans[i].type = I2CTransTx;

      actuators_mkk_v2.data[i].Current     = actuators_mkk_v2.trans[i].buf[0];
      actuators_mkk_v2.data[i].MaxPWM      = actuators_mkk_v2.trans[i].buf[1];
      actuators_mkk_v2.data[i].Temperature = actuators_mkk_v2.trans[i].buf[2];
    }
  }

  RunOnceEvery(10, actuators_mkk_v2_read());

  for (uint8_t i = 0; i < ACTUATORS_MKK_V2_NB; i++) {

#ifdef KILL_MOTORS
    actuators_mkk_v2.trans[i].buf[0] = 0;
    actuators_mkk_v2.trans[i].buf[1] = 0;
#else
    actuators_mkk_v2.trans[i].buf[0] = (actuators_mkk_v2.setpoint[i] >> 3);
    actuators_mkk_v2.trans[i].buf[1] = actuators_mkk_v2.setpoint[i] & 0x07;
#endif

    i2c_submit(&ACTUATORS_MKK_V2_DEVICE, &actuators_mkk_v2.trans[i]);
  }
}
开发者ID:AULA-PPZ,项目名称:paparazzi,代码行数:35,代码来源:actuators_mkk_v2.c

示例9: atmega_i2c_cam_ctrl_send

void atmega_i2c_cam_ctrl_send(uint8_t cmd)
{
  static uint8_t zoom = 0;
  static uint8_t mode = 0;
  unsigned char cam_ret[1];

  if (cmd == DC_SHOOT)
  {
    dc_send_shot_position();
  }
  else if (cmd == DC_TALLER)
  {
    zoom = 1;
  }
  else if (cmd == DC_WIDER)
  {
    zoom = 0;
  }
  else if (cmd == DC_GET_STATUS)
  {
    mode++;
    if (mode > 15)
      mode = 0;
  }

  cam_ret[0] = mode + zoom * 0x20;
  RunOnceEvery(6,DOWNLINK_SEND_PAYLOAD(DefaultChannel, DefaultDevice, 1, cam_ret ));

}
开发者ID:BrandoJS,项目名称:paparazzi,代码行数:29,代码来源:sim_i2c_cam_ctrl.c

示例10: imu_periodic

void imu_periodic(void)
{
  mpu60x0_spi_periodic(&imu_px4fmu.mpu);

  // Read HMC58XX at 50Hz (main loop for rotorcraft: 512Hz)
  RunOnceEvery(10, hmc58xx_periodic(&imu_px4fmu.hmc));
}
开发者ID:1bitsquared,项目名称:paparazzi,代码行数:7,代码来源:imu_px4fmu.c

示例11: autopilot_periodic

void autopilot_periodic(void) {

  RunOnceEvery(NAV_PRESCALER, nav_periodic_task());
#ifdef FAILSAFE_GROUND_DETECT
  if (autopilot_mode == AP_MODE_FAILSAFE && autopilot_detect_ground) {
    autopilot_set_mode(AP_MODE_KILL);
    autopilot_detect_ground = FALSE;
  }
#endif
  if ( !autopilot_motors_on ||
#ifndef FAILSAFE_GROUND_DETECT
       autopilot_mode == AP_MODE_FAILSAFE ||
#endif
       autopilot_mode == AP_MODE_KILL ) {
    SetCommands(commands_failsafe,
		autopilot_in_flight, autopilot_motors_on);
  }
  else {
    guidance_v_run( autopilot_in_flight );
    guidance_h_run( autopilot_in_flight );
    SetCommands(stabilization_cmd,
        autopilot_in_flight, autopilot_motors_on);
  }
#ifdef AUTOPILOT_LOBATT_WING_WAGGLE
  if (electrical.vsupply < (MIN_BAT_LEVEL * 10)){
    RunOnceEvery(autopilot_lobatt_wing_waggle_interval,{setpoint_lobatt_wing_waggle_num=0;})
  }
开发者ID:dirkdokter,项目名称:paparazzi,代码行数:27,代码来源:autopilot.c

示例12: baro_bmp_event

void baro_bmp_event(void) {

  bmp085_event(&baro_bmp);

  if (baro_bmp.data_available) {

    float tmp = baro_bmp.pressure / 101325.0; // pressure at sea level
    tmp = pow(tmp, 0.190295);
    baro_bmp_alt = 44330 * (1.0 - tmp);

    float pressure = (float)baro_bmp.pressure;
    AbiSendMsgBARO_ABS(BARO_BMP_SENDER_ID, &pressure);
    baro_bmp.data_available = FALSE;

#ifdef SENSOR_SYNC_SEND
    DOWNLINK_SEND_BMP_STATUS(DefaultChannel, DefaultDevice, &baro_bmp.up,
                             &baro_bmp.ut, &baro_bmp.pressure,
                             &baro_bmp.temperature);
#else
    RunOnceEvery(10, DOWNLINK_SEND_BMP_STATUS(DefaultChannel, DefaultDevice,
                                              &baro_bmp.up, &baro_bmp.ut,
                                              &baro_bmp.pressure,
                                              &baro_bmp.temperature));
#endif
  }
}
开发者ID:1bitsquared,项目名称:paparazzi,代码行数:26,代码来源:baro_bmp.c

示例13: ins_periodic_task

void ins_periodic_task( void ) {
  if (xsens_configured > 0)
    {
      switch (xsens_configured)
        {
        case 20:
          /* send mode and settings to MT */
          XSENS_GoToConfig();
          XSENS_SetOutputMode(xsens_output_mode);
          XSENS_SetOutputSettings(xsens_output_settings);
          break;
        case 18:
          // Give pulses on SyncOut
          XSENS_SetSyncOutSettings(0,0x0002);
          break;
        case 17:
          // 1 pulse every 100 samples
          XSENS_SetSyncOutSettings(1,100);
          break;
        case 2:
          XSENS_ReqLeverArmGps();
          break;

        case 6:
          XSENS_ReqMagneticDeclination();
          break;

        case 13:
#ifdef AHRS_H_X
#pragma message "Sending XSens Magnetic Declination."
          xsens_declination = atan2(AHRS_H_Y, AHRS_H_X);
          XSENS_SetMagneticDeclination(xsens_declination);
#endif
          break;
        case 12:
#ifdef GPS_IMU_LEVER_ARM_X
#pragma message "Sending XSens GPS Arm."
          XSENS_SetLeverArmGps(GPS_IMU_LEVER_ARM_X,GPS_IMU_LEVER_ARM_Y,GPS_IMU_LEVER_ARM_Z);
#endif
          break;
        case 10:
          {
            uint8_t baud = 1;
            XSENS_SetBaudrate(baud);
          }
          break;

        case 1:
          XSENS_GoToMeasurment();
          break;

        default:
          break;
        }
      xsens_configured--;
      return;
    }

  RunOnceEvery(100,XSENS_ReqGPSStatus());
}
开发者ID:ERAUBB,项目名称:paparazzi,代码行数:60,代码来源:ins_xsens.c

示例14: parse_ins_msg

void parse_ins_msg(void)
{
  struct link_device *dev = InsLinkDevice;
  while (dev->char_available(dev->periph)) {
    uint8_t ch = dev->get_byte(dev->periph);

    if (CHIMU_Parse(ch, 0, &CHIMU_DATA)) {
      if (CHIMU_DATA.m_MsgID == 0x03) {
        new_ins_attitude = 1;
        RunOnceEvery(25, LED_TOGGLE(3));
        if (CHIMU_DATA.m_attitude.euler.phi > M_PI) {
          CHIMU_DATA.m_attitude.euler.phi -= 2 * M_PI;
        }

        struct FloatEulers att = {
          CHIMU_DATA.m_attitude.euler.phi,
          CHIMU_DATA.m_attitude.euler.theta,
          CHIMU_DATA.m_attitude.euler.psi
        };
        stateSetNedToBodyEulers_f(&att);
        ahrs_chimu.is_aligned = TRUE;
#if CHIMU_DOWNLINK_IMMEDIATE
        DOWNLINK_SEND_AHRS_EULER(DefaultChannel, DefaultDevice, &CHIMU_DATA.m_attitude.euler.phi,
                                 &CHIMU_DATA.m_attitude.euler.theta, &CHIMU_DATA.m_attitude.euler.psi);
#endif

      }
    }
  }
}
开发者ID:Djeef,项目名称:paparazzi,代码行数:30,代码来源:ahrs_chimu_uart.c

示例15: autopilot_periodic

void autopilot_periodic(void) {

  RunOnceEvery(NAV_PRESCALER, nav_periodic_task());
#ifdef FAILSAFE_GROUND_DETECT
  if (autopilot_mode == AP_MODE_FAILSAFE && autopilot_detect_ground) {
    autopilot_set_mode(AP_MODE_KILL);
    autopilot_detect_ground = FALSE;
  }
#endif
  if ( !autopilot_motors_on ||
#ifndef FAILSAFE_GROUND_DETECT
       autopilot_mode == AP_MODE_FAILSAFE ||
#endif
       autopilot_mode == AP_MODE_KILL ) {
    SetCommands(commands_failsafe,
		autopilot_in_flight, autopilot_motors_on);
  }
  else {
    guidance_v_run( autopilot_in_flight );
    guidance_h_run( autopilot_in_flight );
    SetCommands(stabilization_cmd,
        autopilot_in_flight, autopilot_motors_on);
  }

}
开发者ID:Ludo6431,项目名称:paparazzi,代码行数:25,代码来源:autopilot.c


注:本文中的RunOnceEvery函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。