mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-06-26 07:30:35 +08:00
Merge pull request #1186 from PX4/logging
Multi-instance handling for sensors
This commit is contained in:
@@ -92,7 +92,7 @@ int do_gyro_calibration(int mavlink_fd)
|
||||
unsigned poll_errcount = 0;
|
||||
|
||||
/* subscribe to gyro sensor topic */
|
||||
int sub_sensor_gyro = orb_subscribe(ORB_ID(sensor_gyro));
|
||||
int sub_sensor_gyro = orb_subscribe(ORB_ID(sensor_gyro0));
|
||||
struct gyro_report gyro_report;
|
||||
|
||||
while (calibration_counter < calibration_count) {
|
||||
@@ -104,7 +104,7 @@ int do_gyro_calibration(int mavlink_fd)
|
||||
int poll_ret = poll(fds, 1, 1000);
|
||||
|
||||
if (poll_ret > 0) {
|
||||
orb_copy(ORB_ID(sensor_gyro), sub_sensor_gyro, &gyro_report);
|
||||
orb_copy(ORB_ID(sensor_gyro0), sub_sensor_gyro, &gyro_report);
|
||||
gyro_scale.x_offset += gyro_report.x;
|
||||
gyro_scale.y_offset += gyro_report.y;
|
||||
gyro_scale.z_offset += gyro_report.z;
|
||||
|
||||
@@ -145,7 +145,7 @@ int do_mag_calibration(int mavlink_fd)
|
||||
}
|
||||
|
||||
if (res == OK) {
|
||||
int sub_mag = orb_subscribe(ORB_ID(sensor_mag));
|
||||
int sub_mag = orb_subscribe(ORB_ID(sensor_mag0));
|
||||
struct mag_report mag;
|
||||
|
||||
/* limit update rate to get equally spaced measurements over time (in ms) */
|
||||
@@ -170,7 +170,7 @@ int do_mag_calibration(int mavlink_fd)
|
||||
int poll_ret = poll(fds, 1, 1000);
|
||||
|
||||
if (poll_ret > 0) {
|
||||
orb_copy(ORB_ID(sensor_mag), sub_mag, &mag);
|
||||
orb_copy(ORB_ID(sensor_mag0), sub_mag, &mag);
|
||||
|
||||
x[calibration_counter] = mag.x;
|
||||
y[calibration_counter] = mag.y;
|
||||
|
||||
@@ -704,7 +704,7 @@ FixedwingEstimator::task_main()
|
||||
/*
|
||||
* do subscriptions
|
||||
*/
|
||||
_baro_sub = orb_subscribe(ORB_ID(sensor_baro));
|
||||
_baro_sub = orb_subscribe(ORB_ID(sensor_baro0));
|
||||
_airspeed_sub = orb_subscribe(ORB_ID(airspeed));
|
||||
_gps_sub = orb_subscribe(ORB_ID(vehicle_gps_position));
|
||||
_vstatus_sub = orb_subscribe(ORB_ID(vehicle_status));
|
||||
@@ -1052,7 +1052,7 @@ FixedwingEstimator::task_main()
|
||||
orb_check(_baro_sub, &baro_updated);
|
||||
|
||||
if (baro_updated) {
|
||||
orb_copy(ORB_ID(sensor_baro), _baro_sub, &_baro);
|
||||
orb_copy(ORB_ID(sensor_baro0), _baro_sub, &_baro);
|
||||
|
||||
_ekf->baroHgt = _baro.altitude;
|
||||
|
||||
@@ -1144,7 +1144,7 @@ FixedwingEstimator::task_main()
|
||||
initVelNED[2] = _gps.vel_d_m_s;
|
||||
|
||||
// Set up height correctly
|
||||
orb_copy(ORB_ID(sensor_baro), _baro_sub, &_baro);
|
||||
orb_copy(ORB_ID(sensor_baro0), _baro_sub, &_baro);
|
||||
_baro_ref_offset = _ekf->states[9]; // this should become zero in the local frame
|
||||
_baro_gps_offset = _baro.altitude - gps_alt;
|
||||
_ekf->baroHgt = _baro.altitude;
|
||||
|
||||
@@ -529,7 +529,7 @@ FixedwingAttitudeControl::vehicle_accel_poll()
|
||||
orb_check(_accel_sub, &accel_updated);
|
||||
|
||||
if (accel_updated) {
|
||||
orb_copy(ORB_ID(sensor_accel), _accel_sub, &_accel);
|
||||
orb_copy(ORB_ID(sensor_accel0), _accel_sub, &_accel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,7 +577,7 @@ FixedwingAttitudeControl::task_main()
|
||||
*/
|
||||
_att_sp_sub = orb_subscribe(ORB_ID(vehicle_attitude_setpoint));
|
||||
_att_sub = orb_subscribe(ORB_ID(vehicle_attitude));
|
||||
_accel_sub = orb_subscribe(ORB_ID(sensor_accel));
|
||||
_accel_sub = orb_subscribe(ORB_ID(sensor_accel0));
|
||||
_airspeed_sub = orb_subscribe(ORB_ID(airspeed));
|
||||
_vcontrol_mode_sub = orb_subscribe(ORB_ID(vehicle_control_mode));
|
||||
_params_sub = orb_subscribe(ORB_ID(parameter_update));
|
||||
|
||||
@@ -546,10 +546,10 @@ MavlinkReceiver::handle_message_hil_sensor(mavlink_message_t *msg)
|
||||
gyro.temperature = imu.temperature;
|
||||
|
||||
if (_gyro_pub < 0) {
|
||||
_gyro_pub = orb_advertise(ORB_ID(sensor_gyro), &gyro);
|
||||
_gyro_pub = orb_advertise(ORB_ID(sensor_gyro0), &gyro);
|
||||
|
||||
} else {
|
||||
orb_publish(ORB_ID(sensor_gyro), _gyro_pub, &gyro);
|
||||
orb_publish(ORB_ID(sensor_gyro0), _gyro_pub, &gyro);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -568,10 +568,10 @@ MavlinkReceiver::handle_message_hil_sensor(mavlink_message_t *msg)
|
||||
accel.temperature = imu.temperature;
|
||||
|
||||
if (_accel_pub < 0) {
|
||||
_accel_pub = orb_advertise(ORB_ID(sensor_accel), &accel);
|
||||
_accel_pub = orb_advertise(ORB_ID(sensor_accel0), &accel);
|
||||
|
||||
} else {
|
||||
orb_publish(ORB_ID(sensor_accel), _accel_pub, &accel);
|
||||
orb_publish(ORB_ID(sensor_accel0), _accel_pub, &accel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -589,10 +589,10 @@ MavlinkReceiver::handle_message_hil_sensor(mavlink_message_t *msg)
|
||||
mag.z = imu.zmag;
|
||||
|
||||
if (_mag_pub < 0) {
|
||||
_mag_pub = orb_advertise(ORB_ID(sensor_mag), &mag);
|
||||
_mag_pub = orb_advertise(ORB_ID(sensor_mag0), &mag);
|
||||
|
||||
} else {
|
||||
orb_publish(ORB_ID(sensor_mag), _mag_pub, &mag);
|
||||
orb_publish(ORB_ID(sensor_mag0), _mag_pub, &mag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -607,10 +607,10 @@ MavlinkReceiver::handle_message_hil_sensor(mavlink_message_t *msg)
|
||||
baro.temperature = imu.temperature;
|
||||
|
||||
if (_baro_pub < 0) {
|
||||
_baro_pub = orb_advertise(ORB_ID(sensor_baro), &baro);
|
||||
_baro_pub = orb_advertise(ORB_ID(sensor_baro0), &baro);
|
||||
|
||||
} else {
|
||||
orb_publish(ORB_ID(sensor_baro), _baro_pub, &baro);
|
||||
orb_publish(ORB_ID(sensor_baro0), _baro_pub, &baro);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -884,10 +884,10 @@ MavlinkReceiver::handle_message_hil_state_quaternion(mavlink_message_t *msg)
|
||||
accel.temperature = 25.0f;
|
||||
|
||||
if (_accel_pub < 0) {
|
||||
_accel_pub = orb_advertise(ORB_ID(sensor_accel), &accel);
|
||||
_accel_pub = orb_advertise(ORB_ID(sensor_accel0), &accel);
|
||||
|
||||
} else {
|
||||
orb_publish(ORB_ID(sensor_accel), _accel_pub, &accel);
|
||||
orb_publish(ORB_ID(sensor_accel0), _accel_pub, &accel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1073,6 +1073,12 @@ int sdlog2_thread_main(int argc, char *argv[])
|
||||
hrt_abstime magnetometer_timestamp = 0;
|
||||
hrt_abstime barometer_timestamp = 0;
|
||||
hrt_abstime differential_pressure_timestamp = 0;
|
||||
hrt_abstime gyro1_timestamp = 0;
|
||||
hrt_abstime accelerometer1_timestamp = 0;
|
||||
hrt_abstime magnetometer1_timestamp = 0;
|
||||
hrt_abstime gyro2_timestamp = 0;
|
||||
hrt_abstime accelerometer2_timestamp = 0;
|
||||
hrt_abstime magnetometer2_timestamp = 0;
|
||||
|
||||
/* initialize calculated mean SNR */
|
||||
float snr_mean = 0.0f;
|
||||
@@ -1209,6 +1215,8 @@ int sdlog2_thread_main(int argc, char *argv[])
|
||||
/* --- SENSOR COMBINED --- */
|
||||
if (copy_if_updated(ORB_ID(sensor_combined), subs.sensor_sub, &buf.sensor)) {
|
||||
bool write_IMU = false;
|
||||
bool write_IMU1 = false;
|
||||
bool write_IMU2 = false;
|
||||
bool write_SENS = false;
|
||||
|
||||
if (buf.sensor.timestamp != gyro_timestamp) {
|
||||
@@ -1260,6 +1268,64 @@ int sdlog2_thread_main(int argc, char *argv[])
|
||||
LOGBUFFER_WRITE_AND_COUNT(SENS);
|
||||
}
|
||||
|
||||
if (buf.sensor.accelerometer1_timestamp != accelerometer1_timestamp) {
|
||||
accelerometer1_timestamp = buf.sensor.accelerometer1_timestamp;
|
||||
write_IMU1 = true;
|
||||
}
|
||||
|
||||
if (buf.sensor.gyro1_timestamp != gyro1_timestamp) {
|
||||
gyro1_timestamp = buf.sensor.gyro1_timestamp;
|
||||
write_IMU1 = true;
|
||||
}
|
||||
|
||||
if (buf.sensor.magnetometer1_timestamp != magnetometer1_timestamp) {
|
||||
magnetometer1_timestamp = buf.sensor.magnetometer1_timestamp;
|
||||
write_IMU1 = true;
|
||||
}
|
||||
|
||||
if (write_IMU1) {
|
||||
log_msg.msg_type = LOG_IMU1_MSG;
|
||||
log_msg.body.log_IMU.gyro_x = buf.sensor.gyro1_rad_s[0];
|
||||
log_msg.body.log_IMU.gyro_y = buf.sensor.gyro1_rad_s[1];
|
||||
log_msg.body.log_IMU.gyro_z = buf.sensor.gyro1_rad_s[2];
|
||||
log_msg.body.log_IMU.acc_x = buf.sensor.accelerometer1_m_s2[0];
|
||||
log_msg.body.log_IMU.acc_y = buf.sensor.accelerometer1_m_s2[1];
|
||||
log_msg.body.log_IMU.acc_z = buf.sensor.accelerometer1_m_s2[2];
|
||||
log_msg.body.log_IMU.mag_x = buf.sensor.magnetometer1_ga[0];
|
||||
log_msg.body.log_IMU.mag_y = buf.sensor.magnetometer1_ga[1];
|
||||
log_msg.body.log_IMU.mag_z = buf.sensor.magnetometer1_ga[2];
|
||||
LOGBUFFER_WRITE_AND_COUNT(IMU);
|
||||
}
|
||||
|
||||
if (buf.sensor.accelerometer2_timestamp != accelerometer2_timestamp) {
|
||||
accelerometer2_timestamp = buf.sensor.accelerometer2_timestamp;
|
||||
write_IMU2 = true;
|
||||
}
|
||||
|
||||
if (buf.sensor.gyro2_timestamp != gyro2_timestamp) {
|
||||
gyro2_timestamp = buf.sensor.gyro2_timestamp;
|
||||
write_IMU2 = true;
|
||||
}
|
||||
|
||||
if (buf.sensor.magnetometer2_timestamp != magnetometer2_timestamp) {
|
||||
magnetometer2_timestamp = buf.sensor.magnetometer2_timestamp;
|
||||
write_IMU2 = true;
|
||||
}
|
||||
|
||||
if (write_IMU2) {
|
||||
log_msg.msg_type = LOG_IMU2_MSG;
|
||||
log_msg.body.log_IMU.gyro_x = buf.sensor.gyro2_rad_s[0];
|
||||
log_msg.body.log_IMU.gyro_y = buf.sensor.gyro2_rad_s[1];
|
||||
log_msg.body.log_IMU.gyro_z = buf.sensor.gyro2_rad_s[2];
|
||||
log_msg.body.log_IMU.acc_x = buf.sensor.accelerometer2_m_s2[0];
|
||||
log_msg.body.log_IMU.acc_y = buf.sensor.accelerometer2_m_s2[1];
|
||||
log_msg.body.log_IMU.acc_z = buf.sensor.accelerometer2_m_s2[2];
|
||||
log_msg.body.log_IMU.mag_x = buf.sensor.magnetometer2_ga[0];
|
||||
log_msg.body.log_IMU.mag_y = buf.sensor.magnetometer2_ga[1];
|
||||
log_msg.body.log_IMU.mag_z = buf.sensor.magnetometer2_ga[2];
|
||||
LOGBUFFER_WRITE_AND_COUNT(IMU);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* --- ATTITUDE --- */
|
||||
|
||||
@@ -73,6 +73,8 @@ struct log_ATSP_s {
|
||||
|
||||
/* --- IMU - IMU SENSORS --- */
|
||||
#define LOG_IMU_MSG 4
|
||||
#define LOG_IMU1_MSG 22
|
||||
#define LOG_IMU2_MSG 23
|
||||
struct log_IMU_s {
|
||||
float acc_x;
|
||||
float acc_y;
|
||||
@@ -276,8 +278,8 @@ struct log_DIST_s {
|
||||
uint8_t flags;
|
||||
};
|
||||
|
||||
// ID 22 available
|
||||
// ID 23 available
|
||||
/* LOG IMU1 and IMU2 MSGs consume IDs 22 and 23 */
|
||||
|
||||
|
||||
/* --- PWR - ONBOARD POWER SYSTEM --- */
|
||||
#define LOG_PWR_MSG 24
|
||||
@@ -420,7 +422,9 @@ static const struct log_format_s log_formats[] = {
|
||||
/* business-level messages, ID < 0x80 */
|
||||
LOG_FORMAT(ATT, "fffffffff", "Roll,Pitch,Yaw,RollRate,PitchRate,YawRate,GX,GY,GZ"),
|
||||
LOG_FORMAT(ATSP, "ffff", "RollSP,PitchSP,YawSP,ThrustSP"),
|
||||
LOG_FORMAT(IMU, "fffffffff", "AccX,AccY,AccZ,GyroX,GyroY,GyroZ,MagX,MagY,MagZ"),
|
||||
LOG_FORMAT_S(IMU, IMU, "fffffffff", "AccX,AccY,AccZ,GyroX,GyroY,GyroZ,MagX,MagY,MagZ"),
|
||||
LOG_FORMAT_S(IMU1, IMU, "fffffffff", "AccX,AccY,AccZ,GyroX,GyroY,GyroZ,MagX,MagY,MagZ"),
|
||||
LOG_FORMAT_S(IMU2, IMU, "fffffffff", "AccX,AccY,AccZ,GyroX,GyroY,GyroZ,MagX,MagY,MagZ"),
|
||||
LOG_FORMAT(SENS, "fffff", "BaroPres,BaroAlt,BaroTemp,DiffPres,DiffPresFilt"),
|
||||
LOG_FORMAT(LPOS, "ffffffffLLfBBBff", "X,Y,Z,Dist,DistR,VX,VY,VZ,RLat,RLon,RAlt,PFlg,LFlg,GFlg,EPH,EPV"),
|
||||
LOG_FORMAT(LPSP, "ffff", "X,Y,Z,Yaw"),
|
||||
|
||||
@@ -292,6 +292,19 @@ PARAM_DEFINE_FLOAT(SENS_BOARD_Z_OFF, 0.0f);
|
||||
*/
|
||||
PARAM_DEFINE_INT32(SENS_EXT_MAG_ROT, 0);
|
||||
|
||||
/**
|
||||
* Set usage of external magnetometer
|
||||
*
|
||||
* * Set to 0 (default) to auto-detect (will try to get the external as primary)
|
||||
* * Set to 1 to force the external magnetometer as primary
|
||||
* * Set to 2 to force the internal magnetometer as primary
|
||||
*
|
||||
* @min 0
|
||||
* @max 2
|
||||
* @group Sensor Calibration
|
||||
*/
|
||||
PARAM_DEFINE_INT32(SENS_EXT_MAG, 0);
|
||||
|
||||
|
||||
/**
|
||||
* RC Channel 1 Minimum
|
||||
|
||||
+115
-11
@@ -199,9 +199,15 @@ private:
|
||||
bool _hil_enabled; /**< if true, HIL is active */
|
||||
bool _publishing; /**< if true, we are publishing sensor data */
|
||||
|
||||
int _gyro_sub; /**< raw gyro data subscription */
|
||||
int _accel_sub; /**< raw accel data subscription */
|
||||
int _mag_sub; /**< raw mag data subscription */
|
||||
int _gyro_sub; /**< raw gyro0 data subscription */
|
||||
int _accel_sub; /**< raw accel0 data subscription */
|
||||
int _mag_sub; /**< raw mag0 data subscription */
|
||||
int _gyro1_sub; /**< raw gyro1 data subscription */
|
||||
int _accel1_sub; /**< raw accel1 data subscription */
|
||||
int _mag1_sub; /**< raw mag1 data subscription */
|
||||
int _gyro2_sub; /**< raw gyro2 data subscription */
|
||||
int _accel2_sub; /**< raw accel2 data subscription */
|
||||
int _mag2_sub; /**< raw mag2 data subscription */
|
||||
int _rc_sub; /**< raw rc channels data subscription */
|
||||
int _baro_sub; /**< raw baro data subscription */
|
||||
int _airspeed_sub; /**< airspeed subscription */
|
||||
@@ -478,6 +484,12 @@ Sensors::Sensors() :
|
||||
_gyro_sub(-1),
|
||||
_accel_sub(-1),
|
||||
_mag_sub(-1),
|
||||
_gyro1_sub(-1),
|
||||
_accel1_sub(-1),
|
||||
_mag1_sub(-1),
|
||||
_gyro2_sub(-1),
|
||||
_accel2_sub(-1),
|
||||
_mag2_sub(-1),
|
||||
_rc_sub(-1),
|
||||
_baro_sub(-1),
|
||||
_vcontrol_mode_sub(-1),
|
||||
@@ -1004,7 +1016,7 @@ Sensors::accel_poll(struct sensor_combined_s &raw)
|
||||
if (accel_updated) {
|
||||
struct accel_report accel_report;
|
||||
|
||||
orb_copy(ORB_ID(sensor_accel), _accel_sub, &accel_report);
|
||||
orb_copy(ORB_ID(sensor_accel0), _accel_sub, &accel_report);
|
||||
|
||||
math::Vector<3> vect(accel_report.x, accel_report.y, accel_report.z);
|
||||
vect = _board_rotation * vect;
|
||||
@@ -1019,6 +1031,48 @@ Sensors::accel_poll(struct sensor_combined_s &raw)
|
||||
|
||||
raw.accelerometer_timestamp = accel_report.timestamp;
|
||||
}
|
||||
|
||||
orb_check(_accel1_sub, &accel_updated);
|
||||
|
||||
if (accel_updated) {
|
||||
struct accel_report accel_report;
|
||||
|
||||
orb_copy(ORB_ID(sensor_accel1), _accel_sub, &accel_report);
|
||||
|
||||
math::Vector<3> vect(accel_report.x, accel_report.y, accel_report.z);
|
||||
vect = _board_rotation * vect;
|
||||
|
||||
raw.accelerometer1_m_s2[0] = vect(0);
|
||||
raw.accelerometer1_m_s2[1] = vect(1);
|
||||
raw.accelerometer1_m_s2[2] = vect(2);
|
||||
|
||||
raw.accelerometer1_raw[0] = accel_report.x_raw;
|
||||
raw.accelerometer1_raw[1] = accel_report.y_raw;
|
||||
raw.accelerometer1_raw[2] = accel_report.z_raw;
|
||||
|
||||
raw.accelerometer1_timestamp = accel_report.timestamp;
|
||||
}
|
||||
|
||||
orb_check(_accel2_sub, &accel_updated);
|
||||
|
||||
if (accel_updated) {
|
||||
struct accel_report accel_report;
|
||||
|
||||
orb_copy(ORB_ID(sensor_accel2), _accel_sub, &accel_report);
|
||||
|
||||
math::Vector<3> vect(accel_report.x, accel_report.y, accel_report.z);
|
||||
vect = _board_rotation * vect;
|
||||
|
||||
raw.accelerometer2_m_s2[0] = vect(0);
|
||||
raw.accelerometer2_m_s2[1] = vect(1);
|
||||
raw.accelerometer2_m_s2[2] = vect(2);
|
||||
|
||||
raw.accelerometer2_raw[0] = accel_report.x_raw;
|
||||
raw.accelerometer2_raw[1] = accel_report.y_raw;
|
||||
raw.accelerometer2_raw[2] = accel_report.z_raw;
|
||||
|
||||
raw.accelerometer2_timestamp = accel_report.timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1030,7 +1084,7 @@ Sensors::gyro_poll(struct sensor_combined_s &raw)
|
||||
if (gyro_updated) {
|
||||
struct gyro_report gyro_report;
|
||||
|
||||
orb_copy(ORB_ID(sensor_gyro), _gyro_sub, &gyro_report);
|
||||
orb_copy(ORB_ID(sensor_gyro0), _gyro_sub, &gyro_report);
|
||||
|
||||
math::Vector<3> vect(gyro_report.x, gyro_report.y, gyro_report.z);
|
||||
vect = _board_rotation * vect;
|
||||
@@ -1045,6 +1099,48 @@ Sensors::gyro_poll(struct sensor_combined_s &raw)
|
||||
|
||||
raw.timestamp = gyro_report.timestamp;
|
||||
}
|
||||
|
||||
orb_check(_gyro1_sub, &gyro_updated);
|
||||
|
||||
if (gyro_updated) {
|
||||
struct gyro_report gyro_report;
|
||||
|
||||
orb_copy(ORB_ID(sensor_gyro1), _gyro1_sub, &gyro_report);
|
||||
|
||||
math::Vector<3> vect(gyro_report.x, gyro_report.y, gyro_report.z);
|
||||
vect = _board_rotation * vect;
|
||||
|
||||
raw.gyro1_rad_s[0] = vect(0);
|
||||
raw.gyro1_rad_s[1] = vect(1);
|
||||
raw.gyro1_rad_s[2] = vect(2);
|
||||
|
||||
raw.gyro1_raw[0] = gyro_report.x_raw;
|
||||
raw.gyro1_raw[1] = gyro_report.y_raw;
|
||||
raw.gyro1_raw[2] = gyro_report.z_raw;
|
||||
|
||||
raw.gyro1_timestamp = gyro_report.timestamp;
|
||||
}
|
||||
|
||||
orb_check(_gyro2_sub, &gyro_updated);
|
||||
|
||||
if (gyro_updated) {
|
||||
struct gyro_report gyro_report;
|
||||
|
||||
orb_copy(ORB_ID(sensor_gyro2), _gyro_sub, &gyro_report);
|
||||
|
||||
math::Vector<3> vect(gyro_report.x, gyro_report.y, gyro_report.z);
|
||||
vect = _board_rotation * vect;
|
||||
|
||||
raw.gyro2_rad_s[0] = vect(0);
|
||||
raw.gyro2_rad_s[1] = vect(1);
|
||||
raw.gyro2_rad_s[2] = vect(2);
|
||||
|
||||
raw.gyro2_raw[0] = gyro_report.x_raw;
|
||||
raw.gyro2_raw[1] = gyro_report.y_raw;
|
||||
raw.gyro2_raw[2] = gyro_report.z_raw;
|
||||
|
||||
raw.gyro2_timestamp = gyro_report.timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1056,10 +1152,12 @@ Sensors::mag_poll(struct sensor_combined_s &raw)
|
||||
if (mag_updated) {
|
||||
struct mag_report mag_report;
|
||||
|
||||
orb_copy(ORB_ID(sensor_mag), _mag_sub, &mag_report);
|
||||
orb_copy(ORB_ID(sensor_mag0), _mag_sub, &mag_report);
|
||||
|
||||
math::Vector<3> vect(mag_report.x, mag_report.y, mag_report.z);
|
||||
|
||||
// XXX we need device-id based handling here
|
||||
|
||||
if (_mag_is_external) {
|
||||
vect = _external_mag_rotation * vect;
|
||||
|
||||
@@ -1087,7 +1185,7 @@ Sensors::baro_poll(struct sensor_combined_s &raw)
|
||||
|
||||
if (baro_updated) {
|
||||
|
||||
orb_copy(ORB_ID(sensor_baro), _baro_sub, &_barometer);
|
||||
orb_copy(ORB_ID(sensor_baro0), _baro_sub, &_barometer);
|
||||
|
||||
raw.baro_pres_mbar = _barometer.pressure; // Pressure in mbar
|
||||
raw.baro_alt_meter = _barometer.altitude; // Altitude in meters
|
||||
@@ -1618,11 +1716,17 @@ Sensors::task_main()
|
||||
/*
|
||||
* do subscriptions
|
||||
*/
|
||||
_gyro_sub = orb_subscribe(ORB_ID(sensor_gyro));
|
||||
_accel_sub = orb_subscribe(ORB_ID(sensor_accel));
|
||||
_mag_sub = orb_subscribe(ORB_ID(sensor_mag));
|
||||
_gyro_sub = orb_subscribe(ORB_ID(sensor_gyro0));
|
||||
_accel_sub = orb_subscribe(ORB_ID(sensor_accel0));
|
||||
_mag_sub = orb_subscribe(ORB_ID(sensor_mag0));
|
||||
_gyro1_sub = orb_subscribe(ORB_ID(sensor_gyro1));
|
||||
_accel1_sub = orb_subscribe(ORB_ID(sensor_accel1));
|
||||
_mag1_sub = orb_subscribe(ORB_ID(sensor_mag1));
|
||||
_gyro2_sub = orb_subscribe(ORB_ID(sensor_gyro2));
|
||||
_accel2_sub = orb_subscribe(ORB_ID(sensor_accel2));
|
||||
_mag2_sub = orb_subscribe(ORB_ID(sensor_mag2));
|
||||
_rc_sub = orb_subscribe(ORB_ID(input_rc));
|
||||
_baro_sub = orb_subscribe(ORB_ID(sensor_baro));
|
||||
_baro_sub = orb_subscribe(ORB_ID(sensor_baro0));
|
||||
_diff_pres_sub = orb_subscribe(ORB_ID(differential_pressure));
|
||||
_vcontrol_mode_sub = orb_subscribe(ORB_ID(vehicle_control_mode));
|
||||
_params_sub = orb_subscribe(ORB_ID(parameter_update));
|
||||
|
||||
@@ -46,16 +46,23 @@
|
||||
#include <drivers/drv_orb_dev.h>
|
||||
|
||||
#include <drivers/drv_mag.h>
|
||||
ORB_DEFINE(sensor_mag, struct mag_report);
|
||||
ORB_DEFINE(sensor_mag0, struct mag_report);
|
||||
ORB_DEFINE(sensor_mag1, struct mag_report);
|
||||
ORB_DEFINE(sensor_mag2, struct mag_report);
|
||||
|
||||
#include <drivers/drv_accel.h>
|
||||
ORB_DEFINE(sensor_accel, struct accel_report);
|
||||
ORB_DEFINE(sensor_accel0, struct accel_report);
|
||||
ORB_DEFINE(sensor_accel1, struct accel_report);
|
||||
ORB_DEFINE(sensor_accel2, struct accel_report);
|
||||
|
||||
#include <drivers/drv_gyro.h>
|
||||
ORB_DEFINE(sensor_gyro, struct gyro_report);
|
||||
ORB_DEFINE(sensor_gyro0, struct gyro_report);
|
||||
ORB_DEFINE(sensor_gyro1, struct gyro_report);
|
||||
ORB_DEFINE(sensor_gyro2, struct gyro_report);
|
||||
|
||||
#include <drivers/drv_baro.h>
|
||||
ORB_DEFINE(sensor_baro, struct baro_report);
|
||||
ORB_DEFINE(sensor_baro0, struct baro_report);
|
||||
ORB_DEFINE(sensor_baro1, struct baro_report);
|
||||
|
||||
#include <drivers/drv_range_finder.h>
|
||||
ORB_DEFINE(sensor_range_finder, struct range_finder_report);
|
||||
|
||||
@@ -95,6 +95,30 @@ struct sensor_combined_s {
|
||||
float magnetometer_cuttoff_freq_hz; /**< Internal analog low pass frequency of sensor */
|
||||
uint64_t magnetometer_timestamp; /**< Magnetometer timestamp */
|
||||
|
||||
int16_t gyro1_raw[3]; /**< Raw sensor values of angular velocity */
|
||||
float gyro1_rad_s[3]; /**< Angular velocity in radian per seconds */
|
||||
uint64_t gyro1_timestamp; /**< Gyro timestamp */
|
||||
|
||||
int16_t accelerometer1_raw[3]; /**< Raw acceleration in NED body frame */
|
||||
float accelerometer1_m_s2[3]; /**< Acceleration in NED body frame, in m/s^2 */
|
||||
uint64_t accelerometer1_timestamp; /**< Accelerometer timestamp */
|
||||
|
||||
int16_t magnetometer1_raw[3]; /**< Raw magnetic field in NED body frame */
|
||||
float magnetometer1_ga[3]; /**< Magnetic field in NED body frame, in Gauss */
|
||||
uint64_t magnetometer1_timestamp; /**< Magnetometer timestamp */
|
||||
|
||||
int16_t gyro2_raw[3]; /**< Raw sensor values of angular velocity */
|
||||
float gyro2_rad_s[3]; /**< Angular velocity in radian per seconds */
|
||||
uint64_t gyro2_timestamp; /**< Gyro timestamp */
|
||||
|
||||
int16_t accelerometer2_raw[3]; /**< Raw acceleration in NED body frame */
|
||||
float accelerometer2_m_s2[3]; /**< Acceleration in NED body frame, in m/s^2 */
|
||||
uint64_t accelerometer2_timestamp; /**< Accelerometer timestamp */
|
||||
|
||||
int16_t magnetometer2_raw[3]; /**< Raw magnetic field in NED body frame */
|
||||
float magnetometer2_ga[3]; /**< Magnetic field in NED body frame, in Gauss */
|
||||
uint64_t magnetometer2_timestamp; /**< Magnetometer timestamp */
|
||||
|
||||
float baro_pres_mbar; /**< Barometric pressure, already temp. comp. */
|
||||
float baro_alt_meter; /**< Altitude, already temp. comp. */
|
||||
float baro_temp_celcius; /**< Temperature in degrees celsius */
|
||||
|
||||
Reference in New Issue
Block a user