姿态传感器

常用的 API


/**
 * @brief:绕X转过的角度  
 * 
 * @param channel:传感器接口编号
 */
float SENSOR_ATTITUDE::Get_X_Angle(unsigned char channel)

/**
 * @brief:绕Y转过的角度
 * 
 * @param channel:传感器接口编号  
 */
float SENSOR_ATTITUDE::Get_Y_Angle(unsigned char channel)

/**
 * @brief:绕Z转过的角度 
 * 
 * @param channel:传感器接口编号 
 */
float SENSOR_ATTITUDE::Get_Z_Angle(unsigned char channel)

/**
 * @brief:绕X转的角速度  
 * 
 * @param channel:传感器接口编号
 */
float SENSOR_ATTITUDE::Get_X_Angle_Speed(unsigned char channel)

/**
 * @brief:绕Y转的角速度 
 * 
 * @param channel:传感器接口编号 
 */
float SENSOR_ATTITUDE::Get_Y_Angle_Speed(unsigned char channel)

/**
 * @brief:绕Z转的角速度  
 * 
 * @param channel:传感器接口编号
 */
float SENSOR_ATTITUDE::Get_Z_Angle_Speed(unsigned char channel)

/**
 * @brief:获取X轴加速度
 * 
 * @param channel:传感器接口编号
 */
float SENSOR_ATTITUDE::Get_X_Acc(unsigned char channel)

/**
 * @brief:获取Y轴加速度
 * 
 * @param channel:传感器接口编号
 */
float SENSOR_ATTITUDE::Get_Y_Acc(unsigned char channel)

/**
 * @brief:获取Z轴加速度
 * 
 * @param channel:传感器接口编号
 */
float SENSOR_ATTITUDE::Get_Z_Acc(unsigned char channel)

/**
 * @brief:获取俯仰角
 * 
 * @param channel:传感器接口编号
 */
float SENSOR_ATTITUDE::Get_Pitch(unsigned char channel)

/**
 * @brief:获取翻滚角
 * 
 * @param channel:传感器接口编号
 */
float SENSOR_ATTITUDE::Get_Roll(unsigned char channel)

/**
 * @brief:获取航向角
 * 
 * @param channel:传感器接口编号
 */
float SENSOR_ATTITUDE::Get_Yaw(unsigned char channel)

/**
 * @brief:获取震动强度
 * 
 * @param channel:传感器接口编号
 */
uint8_t SENSOR_ATTITUDE::Get_Shake_Intensity(unsigned char channel)

/**
  * @brief:清除绕X转过的角度
  * 
  * @param channel:传感器接口编号
  */
void SENSOR_ATTITUDE::Clear_X_Angle(unsigned char channel)

/**
  * @brief:清除绕Y转过的角度
  * 
  * @param channel:传感器接口编号
  */
void SENSOR_ATTITUDE::Clear_Y_Angle(unsigned char channel)

/**
  * @brief:清除绕Z转过的角度
  * 
  * @param channel:传感器接口编号
  */
void SENSOR_ATTITUDE::Clear_Z_Angle(unsigned char channel)

/**
  * @brief:校准
  *  
  * @param channel:传感器接口编号
  */
void SENSOR_ATTITUDE::Calibration( unsigned char channel)


/**
  * @brief:获取校正状态  
  * 
  * @param channel:传感器接口编号
  * @return 0x00:未校正  0x01:校正中  0x02:校正完成
  */
uint8_t SENSOR_ATTITUDE::Get_Calibration_Status(unsigned char channel)

/**
  * @brief:设置陀螺仪的量程
  * 
  * @param channel:0x00:±250 DPS 0x01:±500 DPS  0x02:±1000 DPS  0x03:±2000 DPS
  * @param channel:传感器接口编号
  */
void SENSOR_ATTITUDE::Set_Gyro_Range(uint8_t range, unsigned char channel)

/**
  * @brief:设置加速度的量程
  * 
  * @param channel:0x00:±2g  0x01:±4g  0x02:±8g  0x03:±16g
  * @param channel:传感器接口编号
  */
void SENSOR_ATTITUDE::Set_Acc_Range(uint8_t range, unsigned char channel)


Tbot I 系统编程示范

    // 角度
    float x_angle = Sensor_Attitude.Get_X_Angle(0x03);
    float y_angle = Sensor_Attitude.Get_Y_Angle(0x03);
    float z_angle = Sensor_Attitude.Get_Z_Angle(0x03);
    Serial.print("x_angle = ");
    Serial.print(x_angle);
    Serial.print(" y_angle = ");
    Serial.print(y_angle);
    Serial.print("z_angle = ");
    Serial.println(z_angle);
    // 角速度
    float x_angle_speed = Sensor_Attitude.Get_X_Angle_Speed(0x03);
    float y_angle_speed = Sensor_Attitude.Get_Y_Angle_Speed(0x03);
    float z_angle_speed = Sensor_Attitude.Get_Z_Angle_Speed(0x03);
    Serial.print("x_angle_speed = ");
    Serial.print(x_angle_speed);
    Serial.print(" y_angle_speed = ");
    Serial.print(y_angle_speed);
    Serial.print("z_angle_speed = ");
    Serial.println(z_angle_speed);
    // 加速度
    float x_acc = Sensor_Attitude.Get_X_Acc(0x03);
    float y_acc = Sensor_Attitude.Get_Y_Acc(0x03);
    float z_acc = Sensor_Attitude.Get_Z_Acc(0x03);
    Serial.print("x_acc = ");
    Serial.print(x_acc);
    Serial.print(" y_acc = ");
    Serial.print(y_acc);
    Serial.print("z_acc = ");
    Serial.println(z_acc);    
    // 姿态角
    float pitch = Sensor_Attitude.Get_Pitch(0x03);
    float roll = Sensor_Attitude.Get_Roll(0x03);
    float yaw = Sensor_Attitude.Get_Yaw(0x03);
    Serial.print("pitch = ");
    Serial.print(pitch);
    Serial.print(" roll = ");
    Serial.print(roll);
    Serial.print("yaw = ");
    Serial.println(yaw);
    // 震动
    uint8_t shake_value = Sensor_Attitude.Get_Shake_Intensity(0x03);
    Serial.print("shake_value = ");
    Serial.println(shake_value);

results matching ""

    No results matching ""