mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 07:43:35 +08:00
Merge branch 'master' into mpc_local_pos
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
sh /etc/init.d/rc.fw_defaults
|
sh /etc/init.d/rc.fw_defaults
|
||||||
|
|
||||||
echo "HIL Rascal 110 starting.."
|
echo "X Plane HIL starting.."
|
||||||
|
|
||||||
set HIL yes
|
set HIL yes
|
||||||
|
|
||||||
|
|||||||
@@ -33,3 +33,6 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
set MIXER FMU_Q
|
set MIXER FMU_Q
|
||||||
|
# Provide ESC a constant 1000 us pulse
|
||||||
|
set PWM_OUTPUTS 4
|
||||||
|
set PWM_DISARMED 1000
|
||||||
|
|||||||
@@ -3,6 +3,13 @@
|
|||||||
# Standard apps for fixed wing
|
# Standard apps for fixed wing
|
||||||
#
|
#
|
||||||
|
|
||||||
att_pos_estimator_ekf start
|
#
|
||||||
|
# Start the attitude and position estimator
|
||||||
|
#
|
||||||
|
fw_att_pos_estimator start
|
||||||
|
|
||||||
|
#
|
||||||
|
# Start attitude controller
|
||||||
|
#
|
||||||
fw_att_control start
|
fw_att_control start
|
||||||
fw_pos_control_l1 start
|
fw_pos_control_l1 start
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ mavlink start -r 10000 -d /dev/ttyACM0
|
|||||||
# Enable a number of interesting streams we want via USB
|
# Enable a number of interesting streams we want via USB
|
||||||
mavlink stream -d /dev/ttyACM0 -s NAMED_VALUE_FLOAT -r 10
|
mavlink stream -d /dev/ttyACM0 -s NAMED_VALUE_FLOAT -r 10
|
||||||
mavlink stream -d /dev/ttyACM0 -s OPTICAL_FLOW -r 10
|
mavlink stream -d /dev/ttyACM0 -s OPTICAL_FLOW -r 10
|
||||||
|
mavlink stream -d /dev/ttyACM0 -s VFR_HUD -r 20
|
||||||
|
mavlink stream -d /dev/ttyACM0 -s ATTITUDE -r 20
|
||||||
mavlink stream -d /dev/ttyACM0 -s ATTITUDE_CONTROLS -r 30
|
mavlink stream -d /dev/ttyACM0 -s ATTITUDE_CONTROLS -r 30
|
||||||
mavlink stream -d /dev/ttyACM0 -s SERVO_OUTPUT_RAW_0 -r 10
|
mavlink stream -d /dev/ttyACM0 -s SERVO_OUTPUT_RAW_0 -r 10
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ MODULES += modules/gpio_led
|
|||||||
# Estimation modules (EKF/ SO3 / other filters)
|
# Estimation modules (EKF/ SO3 / other filters)
|
||||||
#
|
#
|
||||||
MODULES += modules/attitude_estimator_ekf
|
MODULES += modules/attitude_estimator_ekf
|
||||||
MODULES += modules/att_pos_estimator_ekf
|
MODULES += modules/fw_att_pos_estimator
|
||||||
MODULES += modules/position_estimator_inav
|
MODULES += modules/position_estimator_inav
|
||||||
#MODULES += examples/flow_position_estimator
|
#MODULES += examples/flow_position_estimator
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ MODULES += modules/gpio_led
|
|||||||
#
|
#
|
||||||
MODULES += modules/attitude_estimator_ekf
|
MODULES += modules/attitude_estimator_ekf
|
||||||
MODULES += modules/attitude_estimator_so3
|
MODULES += modules/attitude_estimator_so3
|
||||||
MODULES += modules/att_pos_estimator_ekf
|
MODULES += modules/fw_att_pos_estimator
|
||||||
MODULES += modules/position_estimator_inav
|
MODULES += modules/position_estimator_inav
|
||||||
MODULES += examples/flow_position_estimator
|
MODULES += examples/flow_position_estimator
|
||||||
|
|
||||||
|
|||||||
@@ -176,11 +176,14 @@ ETSAirspeed::collect()
|
|||||||
_max_differential_pressure_pa = diff_pres_pa;
|
_max_differential_pressure_pa = diff_pres_pa;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX we may want to smooth out the readings to remove noise.
|
|
||||||
differential_pressure_s report;
|
differential_pressure_s report;
|
||||||
report.timestamp = hrt_absolute_time();
|
report.timestamp = hrt_absolute_time();
|
||||||
report.error_count = perf_event_count(_comms_errors);
|
report.error_count = perf_event_count(_comms_errors);
|
||||||
report.differential_pressure_pa = (float)diff_pres_pa;
|
report.differential_pressure_pa = (float)diff_pres_pa;
|
||||||
|
|
||||||
|
// XXX we may want to smooth out the readings to remove noise.
|
||||||
|
report.differential_pressure_filtered_pa = (float)diff_pres_pa;
|
||||||
|
report.temperature = -1000.0f;
|
||||||
report.voltage = 0;
|
report.voltage = 0;
|
||||||
report.max_differential_pressure_pa = _max_differential_pressure_pa;
|
report.max_differential_pressure_pa = _max_differential_pressure_pa;
|
||||||
|
|
||||||
|
|||||||
+79
-44
@@ -276,34 +276,11 @@ SF0X::init()
|
|||||||
warnx("advert err");
|
warnx("advert err");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* attempt to get a measurement 5 times */
|
|
||||||
while (ret != OK && i < 5) {
|
|
||||||
|
|
||||||
if (measure()) {
|
|
||||||
ret = ERROR;
|
|
||||||
_sensor_ok = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
usleep(100000);
|
|
||||||
|
|
||||||
if (collect()) {
|
|
||||||
ret = ERROR;
|
|
||||||
_sensor_ok = false;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
ret = OK;
|
|
||||||
/* sensor is ok, but we don't really know if it is within range */
|
|
||||||
_sensor_ok = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* close the fd */
|
/* close the fd */
|
||||||
::close(_fd);
|
::close(_fd);
|
||||||
_fd = -1;
|
_fd = -1;
|
||||||
out:
|
out:
|
||||||
return ret;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -376,6 +353,7 @@ SF0X::ioctl(struct file *filp, int cmd, unsigned long arg)
|
|||||||
|
|
||||||
/* adjust to a legal polling interval in Hz */
|
/* adjust to a legal polling interval in Hz */
|
||||||
default: {
|
default: {
|
||||||
|
|
||||||
/* do we need to start internal polling? */
|
/* do we need to start internal polling? */
|
||||||
bool want_start = (_measure_ticks == 0);
|
bool want_start = (_measure_ticks == 0);
|
||||||
|
|
||||||
@@ -544,10 +522,16 @@ SF0X::collect()
|
|||||||
|
|
||||||
if (read_elapsed > (SF0X_CONVERSION_INTERVAL * 2)) {
|
if (read_elapsed > (SF0X_CONVERSION_INTERVAL * 2)) {
|
||||||
_linebuf_index = 0;
|
_linebuf_index = 0;
|
||||||
|
} else if (_linebuf_index > 0) {
|
||||||
|
/* increment to next read position */
|
||||||
|
_linebuf_index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* the buffer for read chars is buflen minus null termination */
|
||||||
|
unsigned readlen = sizeof(_linebuf) - 1;
|
||||||
|
|
||||||
/* read from the sensor (uart buffer) */
|
/* read from the sensor (uart buffer) */
|
||||||
ret = ::read(_fd, &_linebuf[_linebuf_index], sizeof(_linebuf) - _linebuf_index);
|
ret = ::read(_fd, &_linebuf[_linebuf_index], readlen - _linebuf_index);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
_linebuf[sizeof(_linebuf) - 1] = '\0';
|
_linebuf[sizeof(_linebuf) - 1] = '\0';
|
||||||
@@ -562,42 +546,87 @@ SF0X::collect()
|
|||||||
} else {
|
} else {
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
}
|
}
|
||||||
|
} else if (ret == 0) {
|
||||||
|
return -EAGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
_linebuf_index += ret;
|
/* we did increment the index to the next position already, so just add the additional fields */
|
||||||
|
_linebuf_index += (ret - 1);
|
||||||
if (_linebuf_index >= sizeof(_linebuf)) {
|
|
||||||
_linebuf_index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
_last_read = hrt_absolute_time();
|
_last_read = hrt_absolute_time();
|
||||||
|
|
||||||
if (_linebuf[_linebuf_index - 2] != '\r' || _linebuf[_linebuf_index - 1] != '\n') {
|
if (_linebuf_index < 1) {
|
||||||
|
/* we need at least the two end bytes to make sense of this string */
|
||||||
|
return -EAGAIN;
|
||||||
|
|
||||||
|
} else if (_linebuf[_linebuf_index - 1] != '\r' || _linebuf[_linebuf_index] != '\n') {
|
||||||
|
|
||||||
|
if (_linebuf_index >= readlen - 1) {
|
||||||
|
/* we have a full buffer, but no line ending - abort */
|
||||||
|
_linebuf_index = 0;
|
||||||
|
perf_count(_comms_errors);
|
||||||
|
return -ENOMEM;
|
||||||
|
} else {
|
||||||
/* incomplete read, reschedule ourselves */
|
/* incomplete read, reschedule ourselves */
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char *end;
|
char *end;
|
||||||
float si_units;
|
float si_units;
|
||||||
bool valid;
|
bool valid;
|
||||||
|
|
||||||
/* enforce line ending */
|
/* enforce line ending */
|
||||||
_linebuf[sizeof(_linebuf) - 1] = '\0';
|
unsigned lend = (_linebuf_index < (sizeof(_linebuf) - 1)) ? _linebuf_index : (sizeof(_linebuf) - 1);
|
||||||
|
|
||||||
|
_linebuf[lend] = '\0';
|
||||||
|
|
||||||
if (_linebuf[0] == '-' && _linebuf[1] == '-' && _linebuf[2] == '.') {
|
if (_linebuf[0] == '-' && _linebuf[1] == '-' && _linebuf[2] == '.') {
|
||||||
si_units = -1.0f;
|
si_units = -1.0f;
|
||||||
valid = false;
|
valid = false;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
si_units = strtod(_linebuf, &end);
|
|
||||||
valid = true;
|
/* we need to find a dot in the string, as we're missing the meters part else */
|
||||||
|
valid = false;
|
||||||
|
|
||||||
|
/* wipe out partially read content from last cycle(s), check for dot */
|
||||||
|
for (int i = 0; i < (lend - 2); i++) {
|
||||||
|
if (_linebuf[i] == '\n') {
|
||||||
|
char buf[sizeof(_linebuf)];
|
||||||
|
memcpy(buf, &_linebuf[i+1], (lend + 1) - (i + 1));
|
||||||
|
memcpy(_linebuf, buf, (lend + 1) - (i + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("val (float): %8.4f, raw: %s\n", si_units, _linebuf);
|
if (_linebuf[i] == '.') {
|
||||||
|
valid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* done with this chunk, resetting */
|
if (valid) {
|
||||||
|
si_units = strtod(_linebuf, &end);
|
||||||
|
|
||||||
|
/* we require at least 3 characters for a valid number */
|
||||||
|
if (end > _linebuf + 3) {
|
||||||
|
valid = true;
|
||||||
|
} else {
|
||||||
|
si_units = -1.0f;
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
debug("val (float): %8.4f, raw: %s, valid: %s\n", si_units, _linebuf, ((valid) ? "OK" : "NO"));
|
||||||
|
|
||||||
|
/* done with this chunk, resetting - even if invalid */
|
||||||
_linebuf_index = 0;
|
_linebuf_index = 0;
|
||||||
|
|
||||||
|
/* if its invalid, there is no reason to forward the value */
|
||||||
|
if (!valid) {
|
||||||
|
perf_count(_comms_errors);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
struct range_finder_report report;
|
struct range_finder_report report;
|
||||||
|
|
||||||
/* this should be fairly close to the end of the measurement, so the best approximation of the time */
|
/* this should be fairly close to the end of the measurement, so the best approximation of the time */
|
||||||
@@ -689,7 +718,11 @@ SF0X::cycle()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (OK != collect_ret) {
|
if (OK != collect_ret) {
|
||||||
|
|
||||||
|
/* we know the sensor needs about four seconds to initialize */
|
||||||
|
if (hrt_absolute_time() > 5 * 1000 * 1000LL) {
|
||||||
log("collection error");
|
log("collection error");
|
||||||
|
}
|
||||||
/* restart the measurement state machine */
|
/* restart the measurement state machine */
|
||||||
start();
|
start();
|
||||||
return;
|
return;
|
||||||
@@ -848,10 +881,10 @@ test()
|
|||||||
}
|
}
|
||||||
|
|
||||||
warnx("single read");
|
warnx("single read");
|
||||||
warnx("measurement: %0.2f m", (double)report.distance);
|
warnx("val: %0.2f m", (double)report.distance);
|
||||||
warnx("time: %lld", report.timestamp);
|
warnx("time: %lld", report.timestamp);
|
||||||
|
|
||||||
/* start the sensor polling at 2Hz */
|
/* start the sensor polling at 2 Hz rate */
|
||||||
if (OK != ioctl(fd, SENSORIOCSPOLLRATE, 2)) {
|
if (OK != ioctl(fd, SENSORIOCSPOLLRATE, 2)) {
|
||||||
errx(1, "failed to set 2Hz poll rate");
|
errx(1, "failed to set 2Hz poll rate");
|
||||||
}
|
}
|
||||||
@@ -866,24 +899,26 @@ test()
|
|||||||
int ret = poll(&fds, 1, 2000);
|
int ret = poll(&fds, 1, 2000);
|
||||||
|
|
||||||
if (ret != 1) {
|
if (ret != 1) {
|
||||||
errx(1, "timed out waiting for sensor data");
|
warnx("timed out");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now go get it */
|
/* now go get it */
|
||||||
sz = read(fd, &report, sizeof(report));
|
sz = read(fd, &report, sizeof(report));
|
||||||
|
|
||||||
if (sz != sizeof(report)) {
|
if (sz != sizeof(report)) {
|
||||||
err(1, "periodic read failed");
|
warnx("read failed: got %d vs exp. %d", sz, sizeof(report));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
warnx("periodic read %u", i);
|
warnx("read #%u", i);
|
||||||
warnx("measurement: %0.3f", (double)report.distance);
|
warnx("val: %0.3f m", (double)report.distance);
|
||||||
warnx("time: %lld", report.timestamp);
|
warnx("time: %lld", report.timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reset the sensor polling to default rate */
|
/* reset the sensor polling to the default rate */
|
||||||
if (OK != ioctl(fd, SENSORIOCSPOLLRATE, SENSOR_POLLRATE_DEFAULT)) {
|
if (OK != ioctl(fd, SENSORIOCSPOLLRATE, SENSOR_POLLRATE_DEFAULT)) {
|
||||||
errx(1, "failed to set default poll rate");
|
errx(1, "ERR: DEF RATE");
|
||||||
}
|
}
|
||||||
|
|
||||||
errx(0, "PASS");
|
errx(0, "PASS");
|
||||||
|
|||||||
@@ -341,7 +341,7 @@ test(void)
|
|||||||
err(1, "can't open ADC device");
|
err(1, "can't open ADC device");
|
||||||
|
|
||||||
for (unsigned i = 0; i < 50; i++) {
|
for (unsigned i = 0; i < 50; i++) {
|
||||||
adc_msg_s data[10];
|
adc_msg_s data[12];
|
||||||
ssize_t count = read(fd, data, sizeof(data));
|
ssize_t count = read(fd, data, sizeof(data));
|
||||||
|
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ __EXPORT float get_bearing_to_next_waypoint(double lat_now, double lon_now, doub
|
|||||||
double lat_next_rad = lat_next * M_DEG_TO_RAD;
|
double lat_next_rad = lat_next * M_DEG_TO_RAD;
|
||||||
double lon_next_rad = lon_next * M_DEG_TO_RAD;
|
double lon_next_rad = lon_next * M_DEG_TO_RAD;
|
||||||
|
|
||||||
double d_lat = lat_next_rad - lat_now_rad;
|
|
||||||
double d_lon = lon_next_rad - lon_now_rad;
|
double d_lon = lon_next_rad - lon_now_rad;
|
||||||
|
|
||||||
/* conscious mix of double and float trig function to maximize speed and efficiency */
|
/* conscious mix of double and float trig function to maximize speed and efficiency */
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,235 @@
|
|||||||
|
#include <math.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define GRAVITY_MSS 9.80665f
|
||||||
|
#define deg2rad 0.017453292f
|
||||||
|
#define rad2deg 57.295780f
|
||||||
|
#define pi 3.141592657f
|
||||||
|
#define earthRate 0.000072921f
|
||||||
|
#define earthRadius 6378145.0f
|
||||||
|
#define earthRadiusInv 1.5678540e-7f
|
||||||
|
|
||||||
|
class Vector3f
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
public:
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
float z;
|
||||||
|
|
||||||
|
float length(void) const;
|
||||||
|
Vector3f zero(void) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Mat3f
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
public:
|
||||||
|
Vector3f x;
|
||||||
|
Vector3f y;
|
||||||
|
Vector3f z;
|
||||||
|
|
||||||
|
Mat3f();
|
||||||
|
|
||||||
|
Mat3f transpose(void) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
Vector3f operator*(float sclIn1, Vector3f vecIn1);
|
||||||
|
Vector3f operator+( Vector3f vecIn1, Vector3f vecIn2);
|
||||||
|
Vector3f operator-( Vector3f vecIn1, Vector3f vecIn2);
|
||||||
|
Vector3f operator*( Mat3f matIn, Vector3f vecIn);
|
||||||
|
Vector3f operator%( Vector3f vecIn1, Vector3f vecIn2);
|
||||||
|
Vector3f operator*(Vector3f vecIn1, float sclIn1);
|
||||||
|
|
||||||
|
void swap_var(float &d1, float &d2);
|
||||||
|
|
||||||
|
const unsigned int n_states = 21;
|
||||||
|
const unsigned int data_buffer_size = 50;
|
||||||
|
|
||||||
|
extern uint32_t statetimeStamp[data_buffer_size]; // time stamp for each state vector stored
|
||||||
|
extern Vector3f correctedDelAng; // delta angles about the xyz body axes corrected for errors (rad)
|
||||||
|
extern Vector3f correctedDelVel; // delta velocities along the XYZ body axes corrected for errors (m/s)
|
||||||
|
extern Vector3f summedDelAng; // summed delta angles about the xyz body axes corrected for errors (rad)
|
||||||
|
extern Vector3f summedDelVel; // summed delta velocities along the XYZ body axes corrected for errors (m/s)
|
||||||
|
extern float accNavMag; // magnitude of navigation accel (- used to adjust GPS obs variance (m/s^2)
|
||||||
|
extern Vector3f earthRateNED; // earths angular rate vector in NED (rad/s)
|
||||||
|
extern Vector3f angRate; // angular rate vector in XYZ body axes measured by the IMU (rad/s)
|
||||||
|
extern Vector3f accel; // acceleration vector in XYZ body axes measured by the IMU (m/s^2)
|
||||||
|
extern Vector3f dVelIMU;
|
||||||
|
extern Vector3f dAngIMU;
|
||||||
|
|
||||||
|
extern float P[n_states][n_states]; // covariance matrix
|
||||||
|
extern float Kfusion[n_states]; // Kalman gains
|
||||||
|
extern float states[n_states]; // state matrix
|
||||||
|
extern float storedStates[n_states][data_buffer_size]; // state vectors stored for the last 50 time steps
|
||||||
|
|
||||||
|
extern Vector3f correctedDelAng; // delta angles about the xyz body axes corrected for errors (rad)
|
||||||
|
extern Vector3f correctedDelVel; // delta velocities along the XYZ body axes corrected for errors (m/s)
|
||||||
|
extern Vector3f summedDelAng; // summed delta angles about the xyz body axes corrected for errors (rad)
|
||||||
|
extern Vector3f summedDelVel; // summed delta velocities along the XYZ body axes corrected for errors (m/s)
|
||||||
|
|
||||||
|
extern float dtIMU; // time lapsed since the last IMU measurement or covariance update (sec)
|
||||||
|
|
||||||
|
extern bool onGround; // boolean true when the flight vehicle is on the ground (not flying)
|
||||||
|
extern bool useAirspeed; // boolean true if airspeed data is being used
|
||||||
|
extern bool useCompass; // boolean true if magnetometer data is being used
|
||||||
|
extern uint8_t fusionModeGPS ; // 0 = GPS outputs 3D velocity, 1 = GPS outputs 2D velocity, 2 = GPS outputs no velocity
|
||||||
|
extern float innovVelPos[6]; // innovation output
|
||||||
|
extern float varInnovVelPos[6]; // innovation variance output
|
||||||
|
|
||||||
|
extern bool fuseVelData; // this boolean causes the posNE and velNED obs to be fused
|
||||||
|
extern bool fusePosData; // this boolean causes the posNE and velNED obs to be fused
|
||||||
|
extern bool fuseHgtData; // this boolean causes the hgtMea obs to be fused
|
||||||
|
extern bool fuseMagData; // boolean true when magnetometer data is to be fused
|
||||||
|
|
||||||
|
extern float velNED[3]; // North, East, Down velocity obs (m/s)
|
||||||
|
extern float posNE[2]; // North, East position obs (m)
|
||||||
|
extern float hgtMea; // measured height (m)
|
||||||
|
extern float posNED[3]; // North, East Down position (m)
|
||||||
|
|
||||||
|
extern float statesAtVelTime[n_states]; // States at the effective measurement time for posNE and velNED measurements
|
||||||
|
extern float statesAtPosTime[n_states]; // States at the effective measurement time for posNE and velNED measurements
|
||||||
|
extern float statesAtHgtTime[n_states]; // States at the effective measurement time for the hgtMea measurement
|
||||||
|
|
||||||
|
extern float innovMag[3]; // innovation output
|
||||||
|
extern float varInnovMag[3]; // innovation variance output
|
||||||
|
extern Vector3f magData; // magnetometer flux radings in X,Y,Z body axes
|
||||||
|
extern float statesAtMagMeasTime[n_states]; // filter satates at the effective measurement time
|
||||||
|
extern float innovVtas; // innovation output
|
||||||
|
extern float varInnovVtas; // innovation variance output
|
||||||
|
extern bool fuseVtasData; // boolean true when airspeed data is to be fused
|
||||||
|
extern float VtasMeas; // true airspeed measurement (m/s)
|
||||||
|
extern float statesAtVtasMeasTime[n_states]; // filter states at the effective measurement time
|
||||||
|
extern float latRef; // WGS-84 latitude of reference point (rad)
|
||||||
|
extern float lonRef; // WGS-84 longitude of reference point (rad)
|
||||||
|
extern float hgtRef; // WGS-84 height of reference point (m)
|
||||||
|
extern Vector3f magBias; // states representing magnetometer bias vector in XYZ body axes
|
||||||
|
extern uint8_t covSkipCount; // Number of state prediction frames (IMU daya updates to skip before doing the covariance prediction
|
||||||
|
extern float EAS2TAS; // ratio f true to equivalent airspeed
|
||||||
|
|
||||||
|
// GPS input data variables
|
||||||
|
extern float gpsCourse;
|
||||||
|
extern float gpsVelD;
|
||||||
|
extern float gpsLat;
|
||||||
|
extern float gpsLon;
|
||||||
|
extern float gpsHgt;
|
||||||
|
extern uint8_t GPSstatus;
|
||||||
|
|
||||||
|
// Baro input
|
||||||
|
extern float baroHgt;
|
||||||
|
|
||||||
|
extern bool statesInitialised;
|
||||||
|
extern bool numericalProtection;
|
||||||
|
|
||||||
|
const float covTimeStepMax = 0.07f; // maximum time allowed between covariance predictions
|
||||||
|
const float covDelAngMax = 0.02f; // maximum delta angle between covariance predictions
|
||||||
|
|
||||||
|
extern bool staticMode;
|
||||||
|
|
||||||
|
enum GPS_FIX {
|
||||||
|
GPS_FIX_NOFIX = 0,
|
||||||
|
GPS_FIX_2D = 2,
|
||||||
|
GPS_FIX_3D = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ekf_status_report {
|
||||||
|
bool velHealth;
|
||||||
|
bool posHealth;
|
||||||
|
bool hgtHealth;
|
||||||
|
bool velTimeout;
|
||||||
|
bool posTimeout;
|
||||||
|
bool hgtTimeout;
|
||||||
|
uint32_t velFailTime;
|
||||||
|
uint32_t posFailTime;
|
||||||
|
uint32_t hgtFailTime;
|
||||||
|
float states[n_states];
|
||||||
|
bool statesNaN;
|
||||||
|
bool covarianceNaN;
|
||||||
|
bool kalmanGainsNaN;
|
||||||
|
};
|
||||||
|
|
||||||
|
void UpdateStrapdownEquationsNED();
|
||||||
|
|
||||||
|
void CovariancePrediction(float dt);
|
||||||
|
|
||||||
|
void FuseVelposNED();
|
||||||
|
|
||||||
|
void FuseMagnetometer();
|
||||||
|
|
||||||
|
void FuseAirspeed();
|
||||||
|
|
||||||
|
void zeroRows(float (&covMat)[n_states][n_states], uint8_t first, uint8_t last);
|
||||||
|
|
||||||
|
void zeroCols(float (&covMat)[n_states][n_states], uint8_t first, uint8_t last);
|
||||||
|
|
||||||
|
float sq(float valIn);
|
||||||
|
|
||||||
|
void quatNorm(float (&quatOut)[4], const float quatIn[4]);
|
||||||
|
|
||||||
|
// store staes along with system time stamp in msces
|
||||||
|
void StoreStates(uint64_t timestamp_ms);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recall the state vector.
|
||||||
|
*
|
||||||
|
* Recalls the vector stored at closest time to the one specified by msec
|
||||||
|
*
|
||||||
|
* @return zero on success, integer indicating the number of invalid states on failure.
|
||||||
|
* Does only copy valid states, if the statesForFusion vector was initialized
|
||||||
|
* correctly by the caller, the result can be safely used, but is a mixture
|
||||||
|
* time-wise where valid states were updated and invalid remained at the old
|
||||||
|
* value.
|
||||||
|
*/
|
||||||
|
int RecallStates(float statesForFusion[n_states], uint64_t msec);
|
||||||
|
|
||||||
|
void ResetStoredStates();
|
||||||
|
|
||||||
|
void quat2Tbn(Mat3f &Tbn, const float (&quat)[4]);
|
||||||
|
|
||||||
|
void calcEarthRateNED(Vector3f &omega, float latitude);
|
||||||
|
|
||||||
|
void eul2quat(float (&quat)[4], const float (&eul)[3]);
|
||||||
|
|
||||||
|
void quat2eul(float (&eul)[3], const float (&quat)[4]);
|
||||||
|
|
||||||
|
void calcvelNED(float (&velNED)[3], float gpsCourse, float gpsGndSpd, float gpsVelD);
|
||||||
|
|
||||||
|
void calcposNED(float (&posNED)[3], float lat, float lon, float hgt, float latRef, float lonRef, float hgtRef);
|
||||||
|
|
||||||
|
void calcLLH(float (&posNED)[3], float lat, float lon, float hgt, float latRef, float lonRef, float hgtRef);
|
||||||
|
|
||||||
|
void OnGroundCheck();
|
||||||
|
|
||||||
|
void CovarianceInit();
|
||||||
|
|
||||||
|
void InitialiseFilter(float (&initvelNED)[3]);
|
||||||
|
|
||||||
|
float ConstrainFloat(float val, float min, float max);
|
||||||
|
|
||||||
|
void ConstrainVariances();
|
||||||
|
|
||||||
|
void ConstrainStates();
|
||||||
|
|
||||||
|
void ForceSymmetry();
|
||||||
|
|
||||||
|
int CheckAndBound();
|
||||||
|
|
||||||
|
void ResetPosition();
|
||||||
|
|
||||||
|
void ResetVelocity();
|
||||||
|
|
||||||
|
void ZeroVariables();
|
||||||
|
|
||||||
|
void GetFilterState(struct ekf_status_report *state);
|
||||||
|
|
||||||
|
void GetLastErrorState(struct ekf_status_report *last_error);
|
||||||
|
|
||||||
|
bool StatesNaN(struct ekf_status_report *err_report);
|
||||||
|
void FillErrorReport(struct ekf_status_report *err);
|
||||||
|
|
||||||
|
void InitializeDynamic(float (&initvelNED)[3]);
|
||||||
|
|
||||||
|
uint32_t millis();
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,117 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013, 2014 PX4 Development Team. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file fw_att_pos_estimator_params.c
|
||||||
|
*
|
||||||
|
* Parameters defined by the attitude and position estimator task
|
||||||
|
*
|
||||||
|
* @author Lorenz Meier <lm@inf.ethz.ch>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <systemlib/param/param.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Estimator parameters, accessible via MAVLink
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Velocity estimate delay
|
||||||
|
*
|
||||||
|
* The delay in milliseconds of the velocity estimate from GPS.
|
||||||
|
*
|
||||||
|
* @min 0
|
||||||
|
* @max 1000
|
||||||
|
* @group Position Estimator
|
||||||
|
*/
|
||||||
|
PARAM_DEFINE_INT32(PE_VEL_DELAY_MS, 230);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Position estimate delay
|
||||||
|
*
|
||||||
|
* The delay in milliseconds of the position estimate from GPS.
|
||||||
|
*
|
||||||
|
* @min 0
|
||||||
|
* @max 1000
|
||||||
|
* @group Position Estimator
|
||||||
|
*/
|
||||||
|
PARAM_DEFINE_INT32(PE_POS_DELAY_MS, 210);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Height estimate delay
|
||||||
|
*
|
||||||
|
* The delay in milliseconds of the height estimate from the barometer.
|
||||||
|
*
|
||||||
|
* @min 0
|
||||||
|
* @max 1000
|
||||||
|
* @group Position Estimator
|
||||||
|
*/
|
||||||
|
PARAM_DEFINE_INT32(PE_HGT_DELAY_MS, 350);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mag estimate delay
|
||||||
|
*
|
||||||
|
* The delay in milliseconds of the magnetic field estimate from
|
||||||
|
* the magnetometer.
|
||||||
|
*
|
||||||
|
* @min 0
|
||||||
|
* @max 1000
|
||||||
|
* @group Position Estimator
|
||||||
|
*/
|
||||||
|
PARAM_DEFINE_INT32(PE_MAG_DELAY_MS, 30);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True airspeeed estimate delay
|
||||||
|
*
|
||||||
|
* The delay in milliseconds of the airspeed estimate.
|
||||||
|
*
|
||||||
|
* @min 0
|
||||||
|
* @max 1000
|
||||||
|
* @group Position Estimator
|
||||||
|
*/
|
||||||
|
PARAM_DEFINE_INT32(PE_TAS_DELAY_MS, 210);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GPS vs. barometric altitude update weight
|
||||||
|
*
|
||||||
|
* RE-CHECK this.
|
||||||
|
*
|
||||||
|
* @min 0.0
|
||||||
|
* @max 1.0
|
||||||
|
* @group Position Estimator
|
||||||
|
*/
|
||||||
|
PARAM_DEFINE_FLOAT(PE_GPS_ALT_WGT, 0.9f);
|
||||||
|
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
############################################################################
|
||||||
|
#
|
||||||
|
# Copyright (c) 2013, 2014 PX4 Development Team. All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in
|
||||||
|
# the documentation and/or other materials provided with the
|
||||||
|
# distribution.
|
||||||
|
# 3. Neither the name PX4 nor the names of its contributors may be
|
||||||
|
# used to endorse or promote products derived from this software
|
||||||
|
# without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
#
|
||||||
|
# Main Attitude and Position Estimator for Fixed Wing Aircraft
|
||||||
|
#
|
||||||
|
|
||||||
|
MODULE_COMMAND = fw_att_pos_estimator
|
||||||
|
|
||||||
|
SRCS = fw_att_pos_estimator_main.cpp \
|
||||||
|
fw_att_pos_estimator_params.c \
|
||||||
|
estimator.cpp
|
||||||
@@ -88,6 +88,7 @@ MavlinkOrbSubscription::update(const hrt_abstime t)
|
|||||||
|
|
||||||
if (_updated) {
|
if (_updated) {
|
||||||
orb_copy(_topic, _fd, _data);
|
orb_copy(_topic, _fd, _data);
|
||||||
|
_published = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,7 @@
|
|||||||
#include <uORB/topics/rc_channels.h>
|
#include <uORB/topics/rc_channels.h>
|
||||||
#include <uORB/topics/esc_status.h>
|
#include <uORB/topics/esc_status.h>
|
||||||
#include <uORB/topics/telemetry_status.h>
|
#include <uORB/topics/telemetry_status.h>
|
||||||
|
#include <uORB/topics/estimator_status.h>
|
||||||
|
|
||||||
#include <systemlib/systemlib.h>
|
#include <systemlib/systemlib.h>
|
||||||
#include <systemlib/param/param.h>
|
#include <systemlib/param/param.h>
|
||||||
@@ -794,6 +795,7 @@ int sdlog2_thread_main(int argc, char *argv[])
|
|||||||
struct battery_status_s battery;
|
struct battery_status_s battery;
|
||||||
struct telemetry_status_s telemetry;
|
struct telemetry_status_s telemetry;
|
||||||
struct range_finder_report range_finder;
|
struct range_finder_report range_finder;
|
||||||
|
struct estimator_status_report estimator_status;
|
||||||
} buf;
|
} buf;
|
||||||
|
|
||||||
memset(&buf, 0, sizeof(buf));
|
memset(&buf, 0, sizeof(buf));
|
||||||
@@ -825,6 +827,7 @@ int sdlog2_thread_main(int argc, char *argv[])
|
|||||||
struct log_BATT_s log_BATT;
|
struct log_BATT_s log_BATT;
|
||||||
struct log_DIST_s log_DIST;
|
struct log_DIST_s log_DIST;
|
||||||
struct log_TELE_s log_TELE;
|
struct log_TELE_s log_TELE;
|
||||||
|
struct log_ESTM_s log_ESTM;
|
||||||
} body;
|
} body;
|
||||||
} log_msg = {
|
} log_msg = {
|
||||||
LOG_PACKET_HEADER_INIT(0)
|
LOG_PACKET_HEADER_INIT(0)
|
||||||
@@ -855,6 +858,7 @@ int sdlog2_thread_main(int argc, char *argv[])
|
|||||||
int battery_sub;
|
int battery_sub;
|
||||||
int telemetry_sub;
|
int telemetry_sub;
|
||||||
int range_finder_sub;
|
int range_finder_sub;
|
||||||
|
int estimator_status_sub;
|
||||||
} subs;
|
} subs;
|
||||||
|
|
||||||
subs.cmd_sub = orb_subscribe(ORB_ID(vehicle_command));
|
subs.cmd_sub = orb_subscribe(ORB_ID(vehicle_command));
|
||||||
@@ -879,6 +883,7 @@ int sdlog2_thread_main(int argc, char *argv[])
|
|||||||
subs.battery_sub = orb_subscribe(ORB_ID(battery_status));
|
subs.battery_sub = orb_subscribe(ORB_ID(battery_status));
|
||||||
subs.telemetry_sub = orb_subscribe(ORB_ID(telemetry_status));
|
subs.telemetry_sub = orb_subscribe(ORB_ID(telemetry_status));
|
||||||
subs.range_finder_sub = orb_subscribe(ORB_ID(sensor_range_finder));
|
subs.range_finder_sub = orb_subscribe(ORB_ID(sensor_range_finder));
|
||||||
|
subs.estimator_status_sub = orb_subscribe(ORB_ID(estimator_status));
|
||||||
|
|
||||||
thread_running = true;
|
thread_running = true;
|
||||||
|
|
||||||
@@ -1243,6 +1248,19 @@ int sdlog2_thread_main(int argc, char *argv[])
|
|||||||
LOGBUFFER_WRITE_AND_COUNT(DIST);
|
LOGBUFFER_WRITE_AND_COUNT(DIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --- ESTIMATOR STATUS --- */
|
||||||
|
if (copy_if_updated(ORB_ID(estimator_status), subs.estimator_status_sub, &buf.estimator_status)) {
|
||||||
|
log_msg.msg_type = LOG_ESTM_MSG;
|
||||||
|
unsigned maxcopy = (sizeof(buf.estimator_status.states) < sizeof(log_msg.body.log_ESTM.s)) ? sizeof(buf.estimator_status.states) : sizeof(log_msg.body.log_ESTM.s);
|
||||||
|
memset(&(log_msg.body.log_ESTM.s), 0, sizeof(log_msg.body.log_ESTM.s));
|
||||||
|
memcpy(&(log_msg.body.log_ESTM.s), buf.estimator_status.states, maxcopy);
|
||||||
|
log_msg.body.log_ESTM.n_states = buf.estimator_status.n_states;
|
||||||
|
log_msg.body.log_ESTM.states_nan = buf.estimator_status.states_nan;
|
||||||
|
log_msg.body.log_ESTM.covariance_nan = buf.estimator_status.covariance_nan;
|
||||||
|
log_msg.body.log_ESTM.kalman_gain_nan = buf.estimator_status.kalman_gain_nan;
|
||||||
|
LOGBUFFER_WRITE_AND_COUNT(ESTM);
|
||||||
|
}
|
||||||
|
|
||||||
/* signal the other thread new data, but not yet unlock */
|
/* signal the other thread new data, but not yet unlock */
|
||||||
if (logbuffer_count(&lb) > MIN_BYTES_TO_WRITE) {
|
if (logbuffer_count(&lb) > MIN_BYTES_TO_WRITE) {
|
||||||
/* only request write if several packets can be written at once */
|
/* only request write if several packets can be written at once */
|
||||||
|
|||||||
@@ -299,6 +299,16 @@ struct log_PARM_s {
|
|||||||
float value;
|
float value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* --- ESTM - ESTIMATOR STATUS --- */
|
||||||
|
#define LOG_ESTM_MSG 132
|
||||||
|
struct log_ESTM_s {
|
||||||
|
float s[32];
|
||||||
|
uint8_t n_states;
|
||||||
|
uint8_t states_nan;
|
||||||
|
uint8_t covariance_nan;
|
||||||
|
uint8_t kalman_gain_nan;
|
||||||
|
};
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
/* construct list of all message formats */
|
/* construct list of all message formats */
|
||||||
@@ -331,6 +341,7 @@ static const struct log_format_s log_formats[] = {
|
|||||||
LOG_FORMAT(TIME, "Q", "StartTime"),
|
LOG_FORMAT(TIME, "Q", "StartTime"),
|
||||||
LOG_FORMAT(VER, "NZ", "Arch,FwGit"),
|
LOG_FORMAT(VER, "NZ", "Arch,FwGit"),
|
||||||
LOG_FORMAT(PARM, "Nf", "Name,Value"),
|
LOG_FORMAT(PARM, "Nf", "Name,Value"),
|
||||||
|
LOG_FORMAT(ESTM, "ffffffffffffffffffffffffffffffffBBBB", "s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s20,s21,s22,s23,s24,s25,s26,s27,s28,s29,s30,s31,n_states,states_nan,cov_nan,kgain_nan"),
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int log_formats_num = sizeof(log_formats) / sizeof(struct log_format_s);
|
static const int log_formats_num = sizeof(log_formats) / sizeof(struct log_format_s);
|
||||||
|
|||||||
@@ -36,6 +36,8 @@
|
|||||||
* Sensor readout process.
|
* Sensor readout process.
|
||||||
*
|
*
|
||||||
* @author Lorenz Meier <lm@inf.ethz.ch>
|
* @author Lorenz Meier <lm@inf.ethz.ch>
|
||||||
|
* @author Julian Oes <joes@student.ethz.ch>
|
||||||
|
* @author Thomas Gubler <thomasgubler@student.ethz.ch>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
@@ -1031,10 +1033,12 @@ Sensors::diff_pres_poll(struct sensor_combined_s &raw)
|
|||||||
raw.differential_pressure_timestamp = _diff_pres.timestamp;
|
raw.differential_pressure_timestamp = _diff_pres.timestamp;
|
||||||
raw.differential_pressure_filtered_pa = _diff_pres.differential_pressure_filtered_pa;
|
raw.differential_pressure_filtered_pa = _diff_pres.differential_pressure_filtered_pa;
|
||||||
|
|
||||||
|
float air_temperature_celcius = (_diff_pres.temperature > -300.0f) ? _diff_pres.temperature : (raw.baro_temp_celcius - PCB_TEMP_ESTIMATE_DEG);
|
||||||
|
|
||||||
_airspeed.timestamp = _diff_pres.timestamp;
|
_airspeed.timestamp = _diff_pres.timestamp;
|
||||||
_airspeed.indicated_airspeed_m_s = calc_indicated_airspeed(_diff_pres.differential_pressure_filtered_pa);
|
_airspeed.indicated_airspeed_m_s = calc_indicated_airspeed(_diff_pres.differential_pressure_filtered_pa);
|
||||||
_airspeed.true_airspeed_m_s = calc_true_airspeed(_diff_pres.differential_pressure_filtered_pa + raw.baro_pres_mbar * 1e2f,
|
_airspeed.true_airspeed_m_s = calc_true_airspeed(_diff_pres.differential_pressure_filtered_pa + raw.baro_pres_mbar * 1e2f,
|
||||||
raw.baro_pres_mbar * 1e2f, raw.baro_temp_celcius - PCB_TEMP_ESTIMATE_DEG);
|
raw.baro_pres_mbar * 1e2f, air_temperature_celcius);
|
||||||
|
|
||||||
/* announce the airspeed if needed, just publish else */
|
/* announce the airspeed if needed, just publish else */
|
||||||
if (_airspeed_pub > 0) {
|
if (_airspeed_pub > 0) {
|
||||||
@@ -1171,16 +1175,19 @@ Sensors::adc_poll(struct sensor_combined_s &raw)
|
|||||||
hrt_abstime t = hrt_absolute_time();
|
hrt_abstime t = hrt_absolute_time();
|
||||||
/* rate limit to 100 Hz */
|
/* rate limit to 100 Hz */
|
||||||
if (t - _last_adc >= 10000) {
|
if (t - _last_adc >= 10000) {
|
||||||
/* make space for a maximum of eight channels */
|
/* make space for a maximum of twelve channels (to ensure reading all channels at once) */
|
||||||
struct adc_msg_s buf_adc[8];
|
struct adc_msg_s buf_adc[12];
|
||||||
/* read all channels available */
|
/* read all channels available */
|
||||||
int ret = read(_fd_adc, &buf_adc, sizeof(buf_adc));
|
int ret = read(_fd_adc, &buf_adc, sizeof(buf_adc));
|
||||||
|
|
||||||
if (ret >= (int)sizeof(buf_adc[0])) {
|
if (ret >= (int)sizeof(buf_adc[0])) {
|
||||||
for (unsigned i = 0; i < sizeof(buf_adc) / sizeof(buf_adc[0]); i++) {
|
|
||||||
|
/* Read add channels we got */
|
||||||
|
for (unsigned i = 0; i < ret / sizeof(buf_adc[0]); i++) {
|
||||||
/* Save raw voltage values */
|
/* Save raw voltage values */
|
||||||
if (i < (sizeof(raw.adc_voltage_v)) / sizeof(raw.adc_voltage_v[0])) {
|
if (i < (sizeof(raw.adc_voltage_v) / sizeof(raw.adc_voltage_v[0]))) {
|
||||||
raw.adc_voltage_v[i] = buf_adc[i].am_data / (4096.0f / 3.3f);
|
raw.adc_voltage_v[i] = buf_adc[i].am_data / (4096.0f / 3.3f);
|
||||||
|
raw.adc_mapping[i] = buf_adc[i].am_channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* look for specific channels and process the raw voltage to measurement data */
|
/* look for specific channels and process the raw voltage to measurement data */
|
||||||
@@ -1239,6 +1246,8 @@ Sensors::adc_poll(struct sensor_combined_s &raw)
|
|||||||
|
|
||||||
_diff_pres.timestamp = t;
|
_diff_pres.timestamp = t;
|
||||||
_diff_pres.differential_pressure_pa = diff_pres_pa;
|
_diff_pres.differential_pressure_pa = diff_pres_pa;
|
||||||
|
_diff_pres.differential_pressure_filtered_pa = diff_pres_pa;
|
||||||
|
_diff_pres.temperature = -1000.0f;
|
||||||
_diff_pres.voltage = voltage;
|
_diff_pres.voltage = voltage;
|
||||||
|
|
||||||
/* announce the airspeed if needed, just publish else */
|
/* announce the airspeed if needed, just publish else */
|
||||||
|
|||||||
@@ -193,3 +193,6 @@ ORB_DEFINE(esc_status, struct esc_status_s);
|
|||||||
|
|
||||||
#include "topics/encoders.h"
|
#include "topics/encoders.h"
|
||||||
ORB_DEFINE(encoders, struct encoders_s);
|
ORB_DEFINE(encoders, struct encoders_s);
|
||||||
|
|
||||||
|
#include "topics/estimator_status.h"
|
||||||
|
ORB_DEFINE(estimator_status, struct estimator_status_report);
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ struct differential_pressure_s {
|
|||||||
float differential_pressure_filtered_pa; /**< Low pass filtered differential pressure reading */
|
float differential_pressure_filtered_pa; /**< Low pass filtered differential pressure reading */
|
||||||
float max_differential_pressure_pa; /**< Maximum differential pressure reading */
|
float max_differential_pressure_pa; /**< Maximum differential pressure reading */
|
||||||
float voltage; /**< Voltage from analog airspeed sensors (voltage divider already compensated) */
|
float voltage; /**< Voltage from analog airspeed sensors (voltage divider already compensated) */
|
||||||
float temperature; /**< Temperature provided by sensor */
|
float temperature; /**< Temperature provided by sensor, -1000.0f if unknown */
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -79,8 +79,7 @@ enum ESC_CONNECTION_TYPE {
|
|||||||
/**
|
/**
|
||||||
* Electronic speed controller status.
|
* Electronic speed controller status.
|
||||||
*/
|
*/
|
||||||
struct esc_status_s
|
struct esc_status_s {
|
||||||
{
|
|
||||||
/* use of a counter and timestamp recommended (but not necessary) */
|
/* use of a counter and timestamp recommended (but not necessary) */
|
||||||
|
|
||||||
uint16_t counter; /**< incremented by the writing thread everytime new data is stored */
|
uint16_t counter; /**< incremented by the writing thread everytime new data is stored */
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014 PX4 Development Team. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||||
|
* used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file estimator_status.h
|
||||||
|
* Definition of the estimator_status_report uORB topic.
|
||||||
|
*
|
||||||
|
* @author Lorenz Meier <lm@inf.ethz.ch>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ESTIMATOR_STATUS_H_
|
||||||
|
#define ESTIMATOR_STATUS_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "../uORB.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup topics
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Estimator status report.
|
||||||
|
*
|
||||||
|
* This is a generic status report struct which allows any of the onboard estimators
|
||||||
|
* to write the internal state to the system log.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct estimator_status_report {
|
||||||
|
|
||||||
|
/* NOTE: Ordering of fields optimized to align to 32 bit / 4 bytes - change with consideration only */
|
||||||
|
|
||||||
|
uint64_t timestamp; /**< Timestamp in microseconds since boot */
|
||||||
|
float states[32]; /**< Internal filter states */
|
||||||
|
float n_states; /**< Number of states effectively used */
|
||||||
|
bool states_nan; /**< If set to true, one of the states is NaN */
|
||||||
|
bool covariance_nan; /**< If set to true, the covariance matrix went NaN */
|
||||||
|
bool kalman_gain_nan; /**< If set to true, the Kalman gain matrix went NaN */
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* register this as object request broker structure */
|
||||||
|
ORB_DECLARE(estimator_status);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -53,8 +53,7 @@
|
|||||||
/**
|
/**
|
||||||
* Filtered bottom flow in bodyframe.
|
* Filtered bottom flow in bodyframe.
|
||||||
*/
|
*/
|
||||||
struct filtered_bottom_flow_s
|
struct filtered_bottom_flow_s {
|
||||||
{
|
|
||||||
uint64_t timestamp; /**< time of this estimate, in microseconds since system start */
|
uint64_t timestamp; /**< time of this estimate, in microseconds since system start */
|
||||||
|
|
||||||
float sumx; /**< Integrated bodyframe x flow in meters */
|
float sumx; /**< Integrated bodyframe x flow in meters */
|
||||||
|
|||||||
@@ -77,8 +77,7 @@ enum ORIGIN {
|
|||||||
* This is the position the MAV is heading towards. If it of type loiter,
|
* This is the position the MAV is heading towards. If it of type loiter,
|
||||||
* the MAV is circling around it with the given loiter radius in meters.
|
* the MAV is circling around it with the given loiter radius in meters.
|
||||||
*/
|
*/
|
||||||
struct mission_item_s
|
struct mission_item_s {
|
||||||
{
|
|
||||||
bool altitude_is_relative; /**< true if altitude is relative from start point */
|
bool altitude_is_relative; /**< true if altitude is relative from start point */
|
||||||
double lat; /**< latitude in degrees */
|
double lat; /**< latitude in degrees */
|
||||||
double lon; /**< longitude in degrees */
|
double lon; /**< longitude in degrees */
|
||||||
|
|||||||
@@ -49,8 +49,7 @@
|
|||||||
* Typically sent by a ground control station / joystick or by
|
* Typically sent by a ground control station / joystick or by
|
||||||
* some off-board controller via C or SIMULINK.
|
* some off-board controller via C or SIMULINK.
|
||||||
*/
|
*/
|
||||||
enum OFFBOARD_CONTROL_MODE
|
enum OFFBOARD_CONTROL_MODE {
|
||||||
{
|
|
||||||
OFFBOARD_CONTROL_MODE_DIRECT = 0,
|
OFFBOARD_CONTROL_MODE_DIRECT = 0,
|
||||||
OFFBOARD_CONTROL_MODE_DIRECT_RATES = 1,
|
OFFBOARD_CONTROL_MODE_DIRECT_RATES = 1,
|
||||||
OFFBOARD_CONTROL_MODE_DIRECT_ATTITUDE = 2,
|
OFFBOARD_CONTROL_MODE_DIRECT_ATTITUDE = 2,
|
||||||
|
|||||||
@@ -57,8 +57,7 @@
|
|||||||
* The value assigned to the specific function corresponds to the entry of
|
* The value assigned to the specific function corresponds to the entry of
|
||||||
* the channel array chan[].
|
* the channel array chan[].
|
||||||
*/
|
*/
|
||||||
enum RC_CHANNELS_FUNCTION
|
enum RC_CHANNELS_FUNCTION {
|
||||||
{
|
|
||||||
THROTTLE = 0,
|
THROTTLE = 0,
|
||||||
ROLL = 1,
|
ROLL = 1,
|
||||||
PITCH = 2,
|
PITCH = 2,
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ struct sensor_combined_s {
|
|||||||
float baro_pres_mbar; /**< Barometric pressure, already temp. comp. */
|
float baro_pres_mbar; /**< Barometric pressure, already temp. comp. */
|
||||||
float baro_alt_meter; /**< Altitude, already temp. comp. */
|
float baro_alt_meter; /**< Altitude, already temp. comp. */
|
||||||
float baro_temp_celcius; /**< Temperature in degrees celsius */
|
float baro_temp_celcius; /**< Temperature in degrees celsius */
|
||||||
float adc_voltage_v[4]; /**< ADC voltages of ADC Chan 10/11/12/13 or -1 */
|
float adc_voltage_v[10]; /**< ADC voltages of ADC Chan 10/11/12/13 or -1 */
|
||||||
|
unsigned adc_mapping[10]; /**< Channel indices of each of these values */
|
||||||
float mcu_temp_celcius; /**< Internal temperature measurement of MCU */
|
float mcu_temp_celcius; /**< Internal temperature measurement of MCU */
|
||||||
uint64_t baro_timestamp; /**< Barometer timestamp */
|
uint64_t baro_timestamp; /**< Barometer timestamp */
|
||||||
|
|
||||||
|
|||||||
@@ -50,8 +50,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "../uORB.h"
|
#include "../uORB.h"
|
||||||
|
|
||||||
enum SUBSYSTEM_TYPE
|
enum SUBSYSTEM_TYPE {
|
||||||
{
|
|
||||||
SUBSYSTEM_TYPE_GYRO = 1,
|
SUBSYSTEM_TYPE_GYRO = 1,
|
||||||
SUBSYSTEM_TYPE_ACC = 2,
|
SUBSYSTEM_TYPE_ACC = 2,
|
||||||
SUBSYSTEM_TYPE_MAG = 4,
|
SUBSYSTEM_TYPE_MAG = 4,
|
||||||
|
|||||||
@@ -52,8 +52,7 @@
|
|||||||
/**
|
/**
|
||||||
* vehicle attitude setpoint.
|
* vehicle attitude setpoint.
|
||||||
*/
|
*/
|
||||||
struct vehicle_attitude_setpoint_s
|
struct vehicle_attitude_setpoint_s {
|
||||||
{
|
|
||||||
uint64_t timestamp; /**< in microseconds since system start, is set whenever the writing thread stores new data */
|
uint64_t timestamp; /**< in microseconds since system start, is set whenever the writing thread stores new data */
|
||||||
|
|
||||||
float roll_body; /**< body angle in NED frame */
|
float roll_body; /**< body angle in NED frame */
|
||||||
|
|||||||
@@ -48,8 +48,7 @@
|
|||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct vehicle_bodyframe_speed_setpoint_s
|
struct vehicle_bodyframe_speed_setpoint_s {
|
||||||
{
|
|
||||||
uint64_t timestamp; /**< in microseconds since system start, is set whenever the writing thread stores new data */
|
uint64_t timestamp; /**< in microseconds since system start, is set whenever the writing thread stores new data */
|
||||||
|
|
||||||
float vx; /**< in m/s */
|
float vx; /**< in m/s */
|
||||||
|
|||||||
@@ -51,8 +51,7 @@
|
|||||||
* Should contain all commands from MAVLink's VEHICLE_CMD ENUM,
|
* Should contain all commands from MAVLink's VEHICLE_CMD ENUM,
|
||||||
* but can contain additional ones.
|
* but can contain additional ones.
|
||||||
*/
|
*/
|
||||||
enum VEHICLE_CMD
|
enum VEHICLE_CMD {
|
||||||
{
|
|
||||||
VEHICLE_CMD_NAV_WAYPOINT = 16, /* Navigate to MISSION. |Hold time in decimal seconds. (ignored by fixed wing, time to stay at MISSION for rotary wing)| Acceptance radius in meters (if the sphere with this radius is hit, the MISSION counts as reached)| 0 to pass through the WP, if > 0 radius in meters to pass by WP. Positive value for clockwise orbit, negative value for counter-clockwise orbit. Allows trajectory control.| Desired yaw angle at MISSION (rotary wing)| Latitude| Longitude| Altitude| */
|
VEHICLE_CMD_NAV_WAYPOINT = 16, /* Navigate to MISSION. |Hold time in decimal seconds. (ignored by fixed wing, time to stay at MISSION for rotary wing)| Acceptance radius in meters (if the sphere with this radius is hit, the MISSION counts as reached)| 0 to pass through the WP, if > 0 radius in meters to pass by WP. Positive value for clockwise orbit, negative value for counter-clockwise orbit. Allows trajectory control.| Desired yaw angle at MISSION (rotary wing)| Latitude| Longitude| Altitude| */
|
||||||
VEHICLE_CMD_NAV_LOITER_UNLIM = 17, /* Loiter around this MISSION an unlimited amount of time |Empty| Empty| Radius around MISSION, in meters. If positive loiter clockwise, else counter-clockwise| Desired yaw angle.| Latitude| Longitude| Altitude| */
|
VEHICLE_CMD_NAV_LOITER_UNLIM = 17, /* Loiter around this MISSION an unlimited amount of time |Empty| Empty| Radius around MISSION, in meters. If positive loiter clockwise, else counter-clockwise| Desired yaw angle.| Latitude| Longitude| Altitude| */
|
||||||
VEHICLE_CMD_NAV_LOITER_TURNS = 18, /* Loiter around this MISSION for X turns |Turns| Empty| Radius around MISSION, in meters. If positive loiter clockwise, else counter-clockwise| Desired yaw angle.| Latitude| Longitude| Altitude| */
|
VEHICLE_CMD_NAV_LOITER_TURNS = 18, /* Loiter around this MISSION for X turns |Turns| Empty| Radius around MISSION, in meters. If positive loiter clockwise, else counter-clockwise| Desired yaw angle.| Latitude| Longitude| Altitude| */
|
||||||
@@ -96,8 +95,7 @@ enum VEHICLE_CMD
|
|||||||
* Should contain all of MAVLink's VEHICLE_CMD_RESULT values
|
* Should contain all of MAVLink's VEHICLE_CMD_RESULT values
|
||||||
* but can contain additional ones.
|
* but can contain additional ones.
|
||||||
*/
|
*/
|
||||||
enum VEHICLE_CMD_RESULT
|
enum VEHICLE_CMD_RESULT {
|
||||||
{
|
|
||||||
VEHICLE_CMD_RESULT_ACCEPTED = 0, /* Command ACCEPTED and EXECUTED | */
|
VEHICLE_CMD_RESULT_ACCEPTED = 0, /* Command ACCEPTED and EXECUTED | */
|
||||||
VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED = 1, /* Command TEMPORARY REJECTED/DENIED | */
|
VEHICLE_CMD_RESULT_TEMPORARILY_REJECTED = 1, /* Command TEMPORARY REJECTED/DENIED | */
|
||||||
VEHICLE_CMD_RESULT_DENIED = 2, /* Command PERMANENTLY DENIED | */
|
VEHICLE_CMD_RESULT_DENIED = 2, /* Command PERMANENTLY DENIED | */
|
||||||
@@ -111,8 +109,7 @@ enum VEHICLE_CMD_RESULT
|
|||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct vehicle_command_s
|
struct vehicle_command_s {
|
||||||
{
|
|
||||||
float param1; /**< Parameter 1, as defined by MAVLink VEHICLE_CMD enum. */
|
float param1; /**< Parameter 1, as defined by MAVLink VEHICLE_CMD enum. */
|
||||||
float param2; /**< Parameter 2, as defined by MAVLink VEHICLE_CMD enum. */
|
float param2; /**< Parameter 2, as defined by MAVLink VEHICLE_CMD enum. */
|
||||||
float param3; /**< Parameter 3, as defined by MAVLink VEHICLE_CMD enum. */
|
float param3; /**< Parameter 3, as defined by MAVLink VEHICLE_CMD enum. */
|
||||||
|
|||||||
@@ -47,8 +47,7 @@
|
|||||||
* @addtogroup topics
|
* @addtogroup topics
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
struct vehicle_control_debug_s
|
struct vehicle_control_debug_s {
|
||||||
{
|
|
||||||
uint64_t timestamp; /**< in microseconds since system start */
|
uint64_t timestamp; /**< in microseconds since system start */
|
||||||
|
|
||||||
float roll_p; /**< roll P control part */
|
float roll_p; /**< roll P control part */
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 PX4 Development Team. All rights reserved.
|
* Copyright (c) 2012-2014 PX4 Development Team. All rights reserved.
|
||||||
* Author: @author Lorenz Meier <lm@inf.ethz.ch>
|
|
||||||
* @author Petri Tanskanen <petri.tanskanen@inf.ethz.ch>
|
|
||||||
* @author Thomas Gubler <thomasgubler@student.ethz.ch>
|
|
||||||
* @author Julian Oes <joes@student.ethz.ch>
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -40,6 +36,11 @@
|
|||||||
* Definition of the vehicle_control_mode uORB topic.
|
* Definition of the vehicle_control_mode uORB topic.
|
||||||
*
|
*
|
||||||
* All control apps should depend their actions based on the flags set here.
|
* All control apps should depend their actions based on the flags set here.
|
||||||
|
*
|
||||||
|
* @author Lorenz Meier <lm@inf.ethz.ch>
|
||||||
|
* @author Petri Tanskanen <petri.tanskanen@inf.ethz.ch>
|
||||||
|
* @author Thomas Gubler <thomasgubler@student.ethz.ch>
|
||||||
|
* @author Julian Oes <joes@student.ethz.ch>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef VEHICLE_CONTROL_MODE
|
#ifndef VEHICLE_CONTROL_MODE
|
||||||
@@ -61,8 +62,7 @@
|
|||||||
* Encodes the complete system state and is set by the commander app.
|
* Encodes the complete system state and is set by the commander app.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct vehicle_control_mode_s
|
struct vehicle_control_mode_s {
|
||||||
{
|
|
||||||
uint64_t timestamp; /**< in microseconds since system start, is set whenever the writing thread stores new data */
|
uint64_t timestamp; /**< in microseconds since system start, is set whenever the writing thread stores new data */
|
||||||
|
|
||||||
bool flag_armed;
|
bool flag_armed;
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 PX4 Development Team. All rights reserved.
|
* Copyright (c) 2012-2014 PX4 Development Team. All rights reserved.
|
||||||
* Author: @author Thomas Gubler <thomasgubler@student.ethz.ch>
|
|
||||||
* @author Julian Oes <joes@student.ethz.ch>
|
|
||||||
* @author Lorenz Meier <lm@inf.ethz.ch>
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -37,6 +34,10 @@
|
|||||||
/**
|
/**
|
||||||
* @file vehicle_global_position.h
|
* @file vehicle_global_position.h
|
||||||
* Definition of the global fused WGS84 position uORB topic.
|
* Definition of the global fused WGS84 position uORB topic.
|
||||||
|
*
|
||||||
|
* @author Thomas Gubler <thomasgubler@student.ethz.ch>
|
||||||
|
* @author Julian Oes <joes@student.ethz.ch>
|
||||||
|
* @author Lorenz Meier <lm@inf.ethz.ch>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef VEHICLE_GLOBAL_POSITION_T_H_
|
#ifndef VEHICLE_GLOBAL_POSITION_T_H_
|
||||||
@@ -59,8 +60,7 @@
|
|||||||
* estimator, which will take more sources of information into account than just GPS,
|
* estimator, which will take more sources of information into account than just GPS,
|
||||||
* e.g. control inputs of the vehicle in a Kalman-filter implementation.
|
* e.g. control inputs of the vehicle in a Kalman-filter implementation.
|
||||||
*/
|
*/
|
||||||
struct vehicle_global_position_s
|
struct vehicle_global_position_s {
|
||||||
{
|
|
||||||
uint64_t timestamp; /**< Time of this estimate, in microseconds since system start */
|
uint64_t timestamp; /**< Time of this estimate, in microseconds since system start */
|
||||||
|
|
||||||
uint64_t time_gps_usec; /**< GPS timestamp in microseconds */
|
uint64_t time_gps_usec; /**< GPS timestamp in microseconds */
|
||||||
|
|||||||
@@ -47,8 +47,7 @@
|
|||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct vehicle_global_velocity_setpoint_s
|
struct vehicle_global_velocity_setpoint_s {
|
||||||
{
|
|
||||||
float vx; /**< in m/s NED */
|
float vx; /**< in m/s NED */
|
||||||
float vy; /**< in m/s NED */
|
float vy; /**< in m/s NED */
|
||||||
float vz; /**< in m/s NED */
|
float vz; /**< in m/s NED */
|
||||||
|
|||||||
@@ -53,8 +53,7 @@
|
|||||||
/**
|
/**
|
||||||
* GPS position in WGS84 coordinates.
|
* GPS position in WGS84 coordinates.
|
||||||
*/
|
*/
|
||||||
struct vehicle_gps_position_s
|
struct vehicle_gps_position_s {
|
||||||
{
|
|
||||||
uint64_t timestamp_position; /**< Timestamp for position information */
|
uint64_t timestamp_position; /**< Timestamp for position information */
|
||||||
int32_t lat; /**< Latitude in 1E-7 degrees */
|
int32_t lat; /**< Latitude in 1E-7 degrees */
|
||||||
int32_t lon; /**< Longitude in 1E-7 degrees */
|
int32_t lon; /**< Longitude in 1E-7 degrees */
|
||||||
|
|||||||
@@ -54,8 +54,7 @@
|
|||||||
/**
|
/**
|
||||||
* Fused local position in NED.
|
* Fused local position in NED.
|
||||||
*/
|
*/
|
||||||
struct vehicle_local_position_s
|
struct vehicle_local_position_s {
|
||||||
{
|
|
||||||
uint64_t timestamp; /**< Time of this estimate, in microseconds since system start */
|
uint64_t timestamp; /**< Time of this estimate, in microseconds since system start */
|
||||||
bool xy_valid; /**< true if x and y are valid */
|
bool xy_valid; /**< true if x and y are valid */
|
||||||
bool z_valid; /**< true if z is valid */
|
bool z_valid; /**< true if z is valid */
|
||||||
|
|||||||
@@ -49,8 +49,7 @@
|
|||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct vehicle_local_position_setpoint_s
|
struct vehicle_local_position_setpoint_s {
|
||||||
{
|
|
||||||
float x; /**< in meters NED */
|
float x; /**< in meters NED */
|
||||||
float y; /**< in meters NED */
|
float y; /**< in meters NED */
|
||||||
float z; /**< in meters NED */
|
float z; /**< in meters NED */
|
||||||
|
|||||||
@@ -47,8 +47,7 @@
|
|||||||
* @addtogroup topics
|
* @addtogroup topics
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
struct vehicle_rates_setpoint_s
|
struct vehicle_rates_setpoint_s {
|
||||||
{
|
|
||||||
uint64_t timestamp; /**< in microseconds since system start */
|
uint64_t timestamp; /**< in microseconds since system start */
|
||||||
|
|
||||||
float roll; /**< body angular rates in NED frame */
|
float roll; /**< body angular rates in NED frame */
|
||||||
|
|||||||
@@ -168,8 +168,7 @@ enum VEHICLE_BATTERY_WARNING {
|
|||||||
*
|
*
|
||||||
* Encodes the complete system state and is set by the commander app.
|
* Encodes the complete system state and is set by the commander app.
|
||||||
*/
|
*/
|
||||||
struct vehicle_status_s
|
struct vehicle_status_s {
|
||||||
{
|
|
||||||
/* use of a counter and timestamp recommended (but not necessary) */
|
/* use of a counter and timestamp recommended (but not necessary) */
|
||||||
|
|
||||||
uint16_t counter; /**< incremented by the writing thread everytime new data is stored */
|
uint16_t counter; /**< incremented by the writing thread everytime new data is stored */
|
||||||
|
|||||||
@@ -52,8 +52,7 @@
|
|||||||
/**
|
/**
|
||||||
* Fused local position in NED.
|
* Fused local position in NED.
|
||||||
*/
|
*/
|
||||||
struct vehicle_vicon_position_s
|
struct vehicle_vicon_position_s {
|
||||||
{
|
|
||||||
uint64_t timestamp; /**< time of this estimate, in microseconds since system start */
|
uint64_t timestamp; /**< time of this estimate, in microseconds since system start */
|
||||||
bool valid; /**< true if position satisfies validity criteria of estimator */
|
bool valid; /**< true if position satisfies validity criteria of estimator */
|
||||||
|
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ int test_adc(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned i = 0; i < 5; i++) {
|
for (unsigned i = 0; i < 5; i++) {
|
||||||
/* make space for a maximum of eight channels */
|
/* make space for a maximum of twelve channels */
|
||||||
struct adc_msg_s data[8];
|
struct adc_msg_s data[12];
|
||||||
/* read all channels available */
|
/* read all channels available */
|
||||||
ssize_t count = read(fd, data, sizeof(data));
|
ssize_t count = read(fd, data, sizeof(data));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user