You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.4 KiB
55 lines
1.4 KiB
13 years ago
|
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||
13 years ago
|
|
||
12 years ago
|
#include "AP_InertialSensor_HIL.h"
|
||
13 years ago
|
#include <AP_HAL.h>
|
||
|
const extern AP_HAL::HAL& hal;
|
||
13 years ago
|
|
||
12 years ago
|
AP_InertialSensor_HIL::AP_InertialSensor_HIL() : AP_InertialSensor() {
|
||
12 years ago
|
Vector3f accels;
|
||
12 years ago
|
accels.z = -GRAVITY_MSS;
|
||
12 years ago
|
set_accel(accels);
|
||
12 years ago
|
}
|
||
12 years ago
|
|
||
12 years ago
|
uint16_t AP_InertialSensor_HIL::_init_sensor( Sample_rate sample_rate ) {
|
||
12 years ago
|
switch (sample_rate) {
|
||
|
case RATE_50HZ:
|
||
|
_sample_period_ms = 20;
|
||
|
break;
|
||
|
case RATE_100HZ:
|
||
|
_sample_period_ms = 10;
|
||
|
break;
|
||
|
case RATE_200HZ:
|
||
|
_sample_period_ms = 5;
|
||
|
break;
|
||
|
}
|
||
13 years ago
|
return AP_PRODUCT_ID_NONE;
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
|
/*================ AP_INERTIALSENSOR PUBLIC INTERFACE ==================== */
|
||
|
|
||
12 years ago
|
bool AP_InertialSensor_HIL::update( void ) {
|
||
13 years ago
|
uint32_t now = hal.scheduler->millis();
|
||
12 years ago
|
_delta_time_usec = (now - _last_update_ms) * 1000;
|
||
|
_last_update_ms = now;
|
||
13 years ago
|
return true;
|
||
|
}
|
||
13 years ago
|
|
||
12 years ago
|
float AP_InertialSensor_HIL::get_delta_time() {
|
||
12 years ago
|
return _delta_time_usec * 1.0e-6;
|
||
13 years ago
|
}
|
||
12 years ago
|
uint32_t AP_InertialSensor_HIL::get_last_sample_time_micros() {
|
||
12 years ago
|
return _last_update_ms * 1000;
|
||
13 years ago
|
}
|
||
12 years ago
|
float AP_InertialSensor_HIL::get_gyro_drift_rate(void) {
|
||
12 years ago
|
// 0.5 degrees/second/minute
|
||
|
return ToRad(0.5/60);
|
||
13 years ago
|
}
|
||
12 years ago
|
|
||
12 years ago
|
bool AP_InertialSensor_HIL::sample_available()
|
||
13 years ago
|
{
|
||
13 years ago
|
uint16_t ret = (hal.scheduler->millis() - _last_update_ms)
|
||
|
/ _sample_period_ms;
|
||
12 years ago
|
|
||
12 years ago
|
return ret > 0;
|
||
13 years ago
|
}
|