mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-05 19:20:35 +08:00
Cleanup variable names and such
This commit is contained in:
+15
-15
@@ -797,8 +797,8 @@ void do_airspeed_calibration(int status_pub, struct vehicle_status_s *status)
|
||||
|
||||
const int calibration_count = 2500;
|
||||
|
||||
int sub_differential_pressure = orb_subscribe(ORB_ID(differential_pressure));
|
||||
struct differential_pressure_s differential_pressure;
|
||||
int diff_pres_sub = orb_subscribe(ORB_ID(differential_pressure));
|
||||
struct differential_pressure_s diff_pres;
|
||||
|
||||
int calibration_counter = 0;
|
||||
float diff_pres_offset = 0.0f;
|
||||
@@ -806,13 +806,13 @@ void do_airspeed_calibration(int status_pub, struct vehicle_status_s *status)
|
||||
while (calibration_counter < calibration_count) {
|
||||
|
||||
/* wait blocking for new data */
|
||||
struct pollfd fds[1] = { { .fd = sub_differential_pressure, .events = POLLIN } };
|
||||
struct pollfd fds[1] = { { .fd = diff_pres_sub, .events = POLLIN } };
|
||||
|
||||
int poll_ret = poll(fds, 1, 1000);
|
||||
|
||||
if (poll_ret) {
|
||||
orb_copy(ORB_ID(differential_pressure), sub_differential_pressure, &differential_pressure);
|
||||
diff_pres_offset += differential_pressure.differential_pressure_pa;
|
||||
orb_copy(ORB_ID(differential_pressure), diff_pres_sub, &diff_pres);
|
||||
diff_pres_offset += diff_pres.differential_pressure_pa;
|
||||
calibration_counter++;
|
||||
|
||||
} else if (poll_ret == 0) {
|
||||
@@ -826,7 +826,7 @@ void do_airspeed_calibration(int status_pub, struct vehicle_status_s *status)
|
||||
|
||||
if (isfinite(diff_pres_offset)) {
|
||||
|
||||
if (param_set(param_find("SENS_VAIR_OFF"), &(diff_pres_offset))) {
|
||||
if (param_set(param_find("SENS_DPRES_OFF"), &(diff_pres_offset))) {
|
||||
mavlink_log_critical(mavlink_fd, "Setting offs failed!");
|
||||
}
|
||||
|
||||
@@ -856,7 +856,7 @@ void do_airspeed_calibration(int status_pub, struct vehicle_status_s *status)
|
||||
status->flag_preflight_airspeed_calibration = false;
|
||||
state_machine_publish(status_pub, status, mavlink_fd);
|
||||
|
||||
close(sub_differential_pressure);
|
||||
close(diff_pres_sub);
|
||||
}
|
||||
|
||||
|
||||
@@ -1477,10 +1477,10 @@ int commander_thread_main(int argc, char *argv[])
|
||||
struct sensor_combined_s sensors;
|
||||
memset(&sensors, 0, sizeof(sensors));
|
||||
|
||||
int differential_pressure_sub = orb_subscribe(ORB_ID(differential_pressure));
|
||||
struct differential_pressure_s differential_pressure;
|
||||
memset(&differential_pressure, 0, sizeof(differential_pressure));
|
||||
uint64_t last_differential_pressure_time = 0;
|
||||
int diff_pres_sub = orb_subscribe(ORB_ID(differential_pressure));
|
||||
struct differential_pressure_s diff_pres;
|
||||
memset(&diff_pres, 0, sizeof(diff_pres));
|
||||
uint64_t last_diff_pres_time = 0;
|
||||
|
||||
/* Subscribe to command topic */
|
||||
int cmd_sub = orb_subscribe(ORB_ID(vehicle_command));
|
||||
@@ -1535,11 +1535,11 @@ int commander_thread_main(int argc, char *argv[])
|
||||
orb_copy(ORB_ID(sensor_combined), sensor_sub, &sensors);
|
||||
}
|
||||
|
||||
orb_check(differential_pressure_sub, &new_data);
|
||||
orb_check(diff_pres_sub, &new_data);
|
||||
|
||||
if (new_data) {
|
||||
orb_copy(ORB_ID(differential_pressure), differential_pressure_sub, &differential_pressure);
|
||||
last_differential_pressure_time = differential_pressure.timestamp;
|
||||
orb_copy(ORB_ID(differential_pressure), diff_pres_sub, &diff_pres);
|
||||
last_diff_pres_time = diff_pres.timestamp;
|
||||
}
|
||||
|
||||
orb_check(cmd_sub, &new_data);
|
||||
@@ -1754,7 +1754,7 @@ int commander_thread_main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Check for valid airspeed/differential pressure measurements */
|
||||
if (hrt_absolute_time() - last_differential_pressure_time < 2000000) {
|
||||
if (hrt_absolute_time() - last_diff_pres_time < 2000000) {
|
||||
current_status.flag_airspeed_valid = true;
|
||||
|
||||
} else {
|
||||
|
||||
@@ -121,7 +121,7 @@ private:
|
||||
bool _sensor_ok;
|
||||
int _measure_ticks;
|
||||
bool _collect_phase;
|
||||
int _differential_pressure_offset;
|
||||
int _diff_pres_offset;
|
||||
|
||||
orb_advert_t _airspeed_pub;
|
||||
|
||||
@@ -191,7 +191,7 @@ ETS_AIRSPEED::ETS_AIRSPEED(int bus, int address) :
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, "ETS_AIRSPEED_read")),
|
||||
_comms_errors(perf_alloc(PC_COUNT, "ETS_AIRSPEED_comms_errors")),
|
||||
_buffer_overflows(perf_alloc(PC_COUNT, "ETS_AIRSPEED_buffer_overflows")),
|
||||
_differential_pressure_offset(0)
|
||||
_diff_pres_offset(0)
|
||||
{
|
||||
// enable debug() calls
|
||||
_debug_enabled = true;
|
||||
@@ -235,7 +235,7 @@ ETS_AIRSPEED::init()
|
||||
if (_airspeed_pub < 0)
|
||||
debug("failed to create airspeed sensor object. Did you start uOrb?");
|
||||
|
||||
param_get(param_find("SENS_VAIR_OFF"), &_differential_pressure_offset);
|
||||
param_get(param_find("SENS_DPRES_OFF"), &_diff_pres_offset);
|
||||
|
||||
ret = OK;
|
||||
/* sensor is ok, but we don't really know if it is within range */
|
||||
@@ -455,7 +455,7 @@ ETS_AIRSPEED::collect()
|
||||
uint16_t diff_pres_pa = val[1] << 8 | val[0];
|
||||
|
||||
/* adjust if necessary */
|
||||
diff_pres_pa -= _differential_pressure_offset;
|
||||
diff_pres_pa -= _diff_pres_offset;
|
||||
//log("measurement: %0.2f m/s", calc_indicated_airspeed((float)_reports[_next_report].diff_pressure));
|
||||
|
||||
_reports[_next_report].timestamp = hrt_absolute_time();
|
||||
|
||||
+6
-6
@@ -444,7 +444,7 @@ int sdlog_thread_main(int argc, char *argv[])
|
||||
struct vehicle_vicon_position_s vicon_pos;
|
||||
struct optical_flow_s flow;
|
||||
struct battery_status_s batt;
|
||||
struct differential_pressure_s diff_pressure;
|
||||
struct differential_pressure_s diff_pres;
|
||||
struct airspeed_s airspeed;
|
||||
} buf;
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
@@ -463,7 +463,7 @@ int sdlog_thread_main(int argc, char *argv[])
|
||||
int vicon_pos_sub;
|
||||
int flow_sub;
|
||||
int batt_sub;
|
||||
int diff_pressure_sub;
|
||||
int diff_pres_sub;
|
||||
int airspeed_sub;
|
||||
} subs;
|
||||
|
||||
@@ -561,8 +561,8 @@ int sdlog_thread_main(int argc, char *argv[])
|
||||
|
||||
/* --- DIFFERENTIAL PRESSURE --- */
|
||||
/* subscribe to ORB for flow measurements */
|
||||
subs.diff_pressure_sub = orb_subscribe(ORB_ID(differential_pressure));
|
||||
fds[fdsc_count].fd = subs.diff_pressure_sub;
|
||||
subs.diff_pres_sub = orb_subscribe(ORB_ID(differential_pressure));
|
||||
fds[fdsc_count].fd = subs.diff_pres_sub;
|
||||
fds[fdsc_count].events = POLLIN;
|
||||
fdsc_count++;
|
||||
|
||||
@@ -664,7 +664,7 @@ int sdlog_thread_main(int argc, char *argv[])
|
||||
orb_copy(ORB_ID(vehicle_attitude), subs.att_sub, &buf.att);
|
||||
orb_copy(ORB_ID(vehicle_vicon_position), subs.vicon_pos_sub, &buf.vicon_pos);
|
||||
orb_copy(ORB_ID(optical_flow), subs.flow_sub, &buf.flow);
|
||||
orb_copy(ORB_ID(differential_pressure), subs.diff_pressure_sub, &buf.diff_pressure);
|
||||
orb_copy(ORB_ID(differential_pressure), subs.diff_pres_sub, &buf.diff_pres);
|
||||
orb_copy(ORB_ID(airspeed), subs.airspeed_sub, &buf.airspeed);
|
||||
orb_copy(ORB_ID(battery_status), subs.batt_sub, &buf.batt);
|
||||
|
||||
@@ -702,7 +702,7 @@ int sdlog_thread_main(int argc, char *argv[])
|
||||
.vicon = {buf.vicon_pos.x, buf.vicon_pos.y, buf.vicon_pos.z, buf.vicon_pos.roll, buf.vicon_pos.pitch, buf.vicon_pos.yaw},
|
||||
.control_effective = {buf.act_controls_effective.control_effective[0], buf.act_controls_effective.control_effective[1], buf.act_controls_effective.control_effective[2], buf.act_controls_effective.control_effective[3]},
|
||||
.flow = {buf.flow.flow_raw_x, buf.flow.flow_raw_y, buf.flow.flow_comp_x_m, buf.flow.flow_comp_y_m, buf.flow.ground_distance_m, buf.flow.quality},
|
||||
.diff_pressure = buf.diff_pressure.differential_pressure_pa,
|
||||
.diff_pressure = buf.diff_pres.differential_pressure_pa,
|
||||
.ind_airspeed = buf.airspeed.indicated_airspeed_m_s,
|
||||
.true_airspeed = buf.airspeed.true_airspeed_m_s
|
||||
};
|
||||
|
||||
@@ -64,7 +64,7 @@ PARAM_DEFINE_FLOAT(SENS_ACC_XSCALE, 1.0f);
|
||||
PARAM_DEFINE_FLOAT(SENS_ACC_YSCALE, 1.0f);
|
||||
PARAM_DEFINE_FLOAT(SENS_ACC_ZSCALE, 1.0f);
|
||||
|
||||
PARAM_DEFINE_FLOAT(SENS_VAIR_OFF, 2.5f);
|
||||
PARAM_DEFINE_FLOAT(SENS_DPRES_OFF, 2.5f);
|
||||
|
||||
PARAM_DEFINE_FLOAT(RC1_MIN, 1000.0f);
|
||||
PARAM_DEFINE_FLOAT(RC1_TRIM, 1500.0f);
|
||||
|
||||
+20
-20
@@ -158,7 +158,7 @@ private:
|
||||
int _rc_sub; /**< raw rc channels data subscription */
|
||||
int _baro_sub; /**< raw baro data subscription */
|
||||
int _airspeed_sub; /**< airspeed subscription */
|
||||
int _differential_pressure_sub; /**< raw differential pressure subscription */
|
||||
int _diff_pres_sub; /**< raw differential pressure subscription */
|
||||
int _vstatus_sub; /**< vehicle status subscription */
|
||||
int _params_sub; /**< notification of parameter updates */
|
||||
int _manual_control_sub; /**< notification of manual control updates */
|
||||
@@ -168,14 +168,14 @@ private:
|
||||
orb_advert_t _rc_pub; /**< raw r/c control topic */
|
||||
orb_advert_t _battery_pub; /**< battery status */
|
||||
orb_advert_t _airspeed_pub; /**< airspeed */
|
||||
orb_advert_t _differential_pressure_pub; /**< differential_pressure */
|
||||
orb_advert_t _diff_pres_pub; /**< differential_pressure */
|
||||
|
||||
perf_counter_t _loop_perf; /**< loop performance counter */
|
||||
|
||||
struct rc_channels_s _rc; /**< r/c channel data */
|
||||
struct battery_status_s _battery_status; /**< battery status */
|
||||
struct baro_report _barometer; /**< barometer data */
|
||||
struct differential_pressure_s _differential_pressure;
|
||||
struct differential_pressure_s _diff_pres;
|
||||
struct airspeed_s _airspeed;
|
||||
|
||||
struct {
|
||||
@@ -341,7 +341,7 @@ private:
|
||||
* @param raw Combined sensor data structure into which
|
||||
* data should be returned.
|
||||
*/
|
||||
void differential_pressure_poll(struct sensor_combined_s &raw);
|
||||
void diff_pres_poll(struct sensor_combined_s &raw);
|
||||
|
||||
/**
|
||||
* Check for changes in vehicle status.
|
||||
@@ -411,7 +411,7 @@ Sensors::Sensors() :
|
||||
_rc_pub(-1),
|
||||
_battery_pub(-1),
|
||||
_airspeed_pub(-1),
|
||||
_differential_pressure_pub(-1),
|
||||
_diff_pres_pub(-1),
|
||||
|
||||
/* performance counters */
|
||||
_loop_perf(perf_alloc(PC_ELAPSED, "sensor task update"))
|
||||
@@ -496,8 +496,8 @@ Sensors::Sensors() :
|
||||
_parameter_handles.mag_scale[1] = param_find("SENS_MAG_YSCALE");
|
||||
_parameter_handles.mag_scale[2] = param_find("SENS_MAG_ZSCALE");
|
||||
|
||||
/*Airspeed offset */
|
||||
_parameter_handles.airspeed_offset = param_find("SENS_VAIR_OFF");
|
||||
/* Differential pressure offset */
|
||||
_parameter_handles.airspeed_offset = param_find("SENS_DPRES_OFF");
|
||||
|
||||
_parameter_handles.battery_voltage_scaling = param_find("BAT_V_SCALING");
|
||||
|
||||
@@ -902,22 +902,22 @@ Sensors::baro_poll(struct sensor_combined_s &raw)
|
||||
}
|
||||
|
||||
void
|
||||
Sensors::differential_pressure_poll(struct sensor_combined_s &raw)
|
||||
Sensors::diff_pres_poll(struct sensor_combined_s &raw)
|
||||
{
|
||||
bool updated;
|
||||
orb_check(_differential_pressure_sub, &updated);
|
||||
orb_check(_diff_pres_sub, &updated);
|
||||
|
||||
if (updated) {
|
||||
orb_copy(ORB_ID(differential_pressure), _differential_pressure_sub, &_differential_pressure);
|
||||
orb_copy(ORB_ID(differential_pressure), _diff_pres_sub, &_diff_pres);
|
||||
|
||||
float airspeed_true = calc_true_airspeed(_differential_pressure.differential_pressure_pa + raw.baro_pres_mbar*1e2f,
|
||||
float airspeed_true = calc_true_airspeed(_diff_pres.differential_pressure_pa + raw.baro_pres_mbar*1e2f,
|
||||
raw.baro_pres_mbar*1e2f, raw.baro_temp_celcius - 5.0f); //factor 1e2 for conversion from mBar to Pa
|
||||
// XXX HACK - true temperature is much less than indicated temperature in baro,
|
||||
// subtract 5 degrees in an attempt to account for the electrical upheating of the PCB
|
||||
|
||||
float airspeed_indicated = calc_indicated_airspeed(_differential_pressure.differential_pressure_pa);
|
||||
float airspeed_indicated = calc_indicated_airspeed(_diff_pres.differential_pressure_pa);
|
||||
|
||||
raw.differential_pressure_pa = _differential_pressure.differential_pressure_pa;
|
||||
raw.differential_pressure_pa = _diff_pres.differential_pressure_pa;
|
||||
raw.differential_pressure_counter++;
|
||||
}
|
||||
}
|
||||
@@ -1082,16 +1082,16 @@ Sensors::adc_poll(struct sensor_combined_s &raw)
|
||||
|
||||
float diff_pres_pa = voltage * 1000.0f - _parameters.airspeed_offset; //for MPXV7002DP sensor
|
||||
|
||||
_differential_pressure.timestamp = hrt_absolute_time();
|
||||
_differential_pressure.differential_pressure_pa = diff_pres_pa;
|
||||
_differential_pressure.voltage = voltage;
|
||||
_diff_pres.timestamp = hrt_absolute_time();
|
||||
_diff_pres.differential_pressure_pa = diff_pres_pa;
|
||||
_diff_pres.voltage = voltage;
|
||||
|
||||
/* announce the airspeed if needed, just publish else */
|
||||
if (_differential_pressure_pub > 0) {
|
||||
orb_publish(ORB_ID(differential_pressure), _differential_pressure_pub, &_differential_pressure);
|
||||
if (_diff_pres_pub > 0) {
|
||||
orb_publish(ORB_ID(differential_pressure), _diff_pres_pub, &_diff_pres);
|
||||
|
||||
} else {
|
||||
_differential_pressure_pub = orb_advertise(ORB_ID(differential_pressure), &_differential_pressure);
|
||||
_diff_pres_pub = orb_advertise(ORB_ID(differential_pressure), &_diff_pres);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1356,7 +1356,7 @@ Sensors::task_main()
|
||||
gyro_poll(raw);
|
||||
mag_poll(raw);
|
||||
baro_poll(raw);
|
||||
differential_pressure_poll(raw);
|
||||
diff_pres_poll(raw);
|
||||
|
||||
parameter_update_poll(true /* forced */);
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ struct sensor_combined_s {
|
||||
float mcu_temp_celcius; /**< Internal temperature measurement of MCU */
|
||||
uint32_t baro_counter; /**< Number of raw baro measurements taken */
|
||||
|
||||
float differential_pressure_pa; /**< Airspeed sensor differential pressure */
|
||||
float differential_pressure_pa; /**< Airspeed sensor differential pressure */
|
||||
uint32_t differential_pressure_counter; /**< Number of raw differential pressure measurements taken */
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user