mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 00:03:33 +08:00
stop ignoring Wmissing-field-initializers and fix (#9912)
This commit is contained in:
@@ -211,20 +211,20 @@ protected:
|
||||
Device *_interface;
|
||||
|
||||
private:
|
||||
work_s _work;
|
||||
unsigned _measure_ticks;
|
||||
work_s _work{};
|
||||
unsigned _measure_ticks{0};
|
||||
|
||||
ringbuffer::RingBuffer *_reports;
|
||||
bool _collect_phase;
|
||||
ringbuffer::RingBuffer *_reports{nullptr};
|
||||
bool _collect_phase{false};
|
||||
|
||||
orb_advert_t _baro_topic;
|
||||
int _orb_class_instance;
|
||||
int _class_instance;
|
||||
orb_advert_t _baro_topic{nullptr};
|
||||
int _orb_class_instance{-1};
|
||||
int _class_instance{-1};
|
||||
|
||||
perf_counter_t _sample_perf;
|
||||
perf_counter_t _comms_errors;
|
||||
|
||||
struct baro_report _last_report; /**< used for info() */
|
||||
sensor_baro_s _last_report{}; /**< used for info() */
|
||||
|
||||
/**
|
||||
* Initialise the automatic measurement state machine and start it.
|
||||
@@ -311,28 +311,14 @@ extern "C" __EXPORT int lps25h_main(int argc, char *argv[]);
|
||||
LPS25H::LPS25H(device::Device *interface, const char *path) :
|
||||
CDev("LPS25H", path),
|
||||
_interface(interface),
|
||||
_work{},
|
||||
_measure_ticks(0),
|
||||
_reports(nullptr),
|
||||
_collect_phase(false),
|
||||
_baro_topic(nullptr),
|
||||
_orb_class_instance(-1),
|
||||
_class_instance(-1),
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, "lps25h_read")),
|
||||
_comms_errors(perf_alloc(PC_COUNT, "lps25h_comms_errors")),
|
||||
_last_report{0}
|
||||
_comms_errors(perf_alloc(PC_COUNT, "lps25h_comms_errors"))
|
||||
{
|
||||
// set the device type from the interface
|
||||
_device_id.devid_s.bus_type = _interface->get_device_bus_type();
|
||||
_device_id.devid_s.bus = _interface->get_device_bus();
|
||||
_device_id.devid_s.address = _interface->get_device_address();
|
||||
_device_id.devid_s.devtype = DRV_BARO_DEVTYPE_LPS25H;
|
||||
|
||||
// enable debug() calls
|
||||
_debug_enabled = false;
|
||||
|
||||
// work_cancel in the dtor will explode if we don't do this...
|
||||
memset(&_work, 0, sizeof(_work));
|
||||
}
|
||||
|
||||
LPS25H::~LPS25H()
|
||||
|
||||
@@ -483,20 +483,12 @@ CameraTrigger::stop()
|
||||
void
|
||||
CameraTrigger::test()
|
||||
{
|
||||
struct vehicle_command_s cmd = {
|
||||
.timestamp = hrt_absolute_time(),
|
||||
.param5 = 1.0,
|
||||
.param6 = 0.0,
|
||||
.param1 = 0.0f,
|
||||
.param2 = 0.0f,
|
||||
.param3 = 0.0f,
|
||||
.param4 = 0.0f,
|
||||
.param7 = 0.0f,
|
||||
.command = vehicle_command_s::VEHICLE_CMD_DO_DIGICAM_CONTROL
|
||||
};
|
||||
vehicle_command_s vcmd = {};
|
||||
vcmd.timestamp = hrt_absolute_time();
|
||||
vcmd.param5 = 1.0;
|
||||
vcmd.command = vehicle_command_s::VEHICLE_CMD_DO_DIGICAM_CONTROL;
|
||||
|
||||
orb_advert_t pub = orb_advertise_queue(ORB_ID(vehicle_command), &cmd, vehicle_command_s::ORB_QUEUE_LENGTH);
|
||||
(void)orb_unadvertise(pub);
|
||||
orb_advertise_queue(ORB_ID(vehicle_command), &vcmd, vehicle_command_s::ORB_QUEUE_LENGTH);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -722,16 +714,12 @@ CameraTrigger::cycle_trampoline(void *arg)
|
||||
|
||||
// Command ACK handling
|
||||
if (updated && need_ack) {
|
||||
vehicle_command_ack_s command_ack = {
|
||||
.timestamp = 0,
|
||||
.result_param2 = 0,
|
||||
.command = cmd.command,
|
||||
.result = (uint8_t)cmd_result,
|
||||
.from_external = false,
|
||||
.result_param1 = 0,
|
||||
.target_system = cmd.source_system,
|
||||
.target_component = cmd.source_component
|
||||
};
|
||||
vehicle_command_ack_s command_ack = {};
|
||||
command_ack.timestamp = hrt_absolute_time();
|
||||
command_ack.command = cmd.command;
|
||||
command_ack.result = (uint8_t)cmd_result;
|
||||
command_ack.target_system = cmd.source_system;
|
||||
command_ack.target_component = cmd.source_component;
|
||||
|
||||
if (trig->_cmd_ack_pub == nullptr) {
|
||||
trig->_cmd_ack_pub = orb_advertise_queue(ORB_ID(vehicle_command_ack), &command_ack,
|
||||
@@ -739,7 +727,6 @@ CameraTrigger::cycle_trampoline(void *arg)
|
||||
|
||||
} else {
|
||||
orb_publish(ORB_ID(vehicle_command_ack), trig->_cmd_ack_pub, &command_ack);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -898,4 +885,3 @@ int camera_trigger_main(int argc, char *argv[])
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -207,17 +207,19 @@ protected:
|
||||
virtual int probe();
|
||||
|
||||
private:
|
||||
work_s _work;
|
||||
unsigned _measure_ticks;
|
||||
work_s _work{};
|
||||
unsigned _measure_ticks{0};
|
||||
|
||||
ringbuffer::RingBuffer *_reports;
|
||||
struct mag_calibration_s _scale;
|
||||
float _range_scale;
|
||||
bool _collect_phase;
|
||||
int _class_instance;
|
||||
int _orb_class_instance;
|
||||
ringbuffer::RingBuffer *_reports{nullptr};
|
||||
|
||||
orb_advert_t _mag_topic;
|
||||
struct mag_calibration_s _scale {};
|
||||
float _range_scale{0.003f}; /* default range scale from counts to gauss */
|
||||
|
||||
bool _collect_phase{false};
|
||||
int _class_instance{-1};
|
||||
int _orb_class_instance{-1};
|
||||
|
||||
orb_advert_t _mag_topic{nullptr};
|
||||
|
||||
perf_counter_t _sample_perf;
|
||||
perf_counter_t _comms_errors;
|
||||
@@ -225,16 +227,16 @@ private:
|
||||
perf_counter_t _conf_errors;
|
||||
|
||||
/* status reporting */
|
||||
bool _sensor_ok; /**< sensor was found and reports ok */
|
||||
bool _calibrated; /**< the calibration is valid */
|
||||
bool _ctl_reg_mismatch; /**< control register value mismatch after checking */
|
||||
bool _sensor_ok{false}; /**< sensor was found and reports ok */
|
||||
bool _calibrated{false}; /**< the calibration is valid */
|
||||
bool _ctl_reg_mismatch{false}; /**< control register value mismatch after checking */
|
||||
|
||||
enum Rotation _rotation;
|
||||
|
||||
struct mag_report _last_report; /**< used for info() */
|
||||
sensor_mag_s _last_report{}; /**< used for info() */
|
||||
|
||||
uint8_t _ctl3_reg;
|
||||
uint8_t _ctl4_reg;
|
||||
uint8_t _ctl3_reg{0};
|
||||
uint8_t _ctl4_reg{0};
|
||||
|
||||
/**
|
||||
* Initialise the automatic measurement state machine and start it.
|
||||
@@ -396,32 +398,14 @@ extern "C" __EXPORT int ist8310_main(int argc, char *argv[]);
|
||||
|
||||
IST8310::IST8310(int bus_number, int address, const char *path, enum Rotation rotation) :
|
||||
I2C("IST8310", path, bus_number, address, IST8310_DEFAULT_BUS_SPEED),
|
||||
_work{},
|
||||
_measure_ticks(0),
|
||||
_reports(nullptr),
|
||||
_scale{},
|
||||
_range_scale(0.003), /* default range scale from counts to gauss */
|
||||
_collect_phase(false),
|
||||
_class_instance(-1),
|
||||
_orb_class_instance(-1),
|
||||
_mag_topic(nullptr),
|
||||
_sample_perf(perf_alloc(PC_ELAPSED, "ist8310_read")),
|
||||
_comms_errors(perf_alloc(PC_COUNT, "ist8310_com_err")),
|
||||
_range_errors(perf_alloc(PC_COUNT, "ist8310_rng_err")),
|
||||
_conf_errors(perf_alloc(PC_COUNT, "ist8310_conf_err")),
|
||||
_sensor_ok(false),
|
||||
_calibrated(false),
|
||||
_ctl_reg_mismatch(false),
|
||||
_rotation(rotation),
|
||||
_last_report{0},
|
||||
_ctl3_reg(0),
|
||||
_ctl4_reg(0)
|
||||
_rotation(rotation)
|
||||
{
|
||||
_device_id.devid_s.devtype = DRV_MAG_DEVTYPE_IST8310;
|
||||
|
||||
// enable debug() calls
|
||||
_debug_enabled = false;
|
||||
|
||||
// default scaling
|
||||
_scale.x_offset = 0;
|
||||
_scale.x_scale = 1.0f;
|
||||
@@ -429,9 +413,6 @@ IST8310::IST8310(int bus_number, int address, const char *path, enum Rotation ro
|
||||
_scale.y_scale = 1.0f;
|
||||
_scale.z_offset = 0;
|
||||
_scale.z_scale = 1.0f;
|
||||
|
||||
// work_cancel in the dtor will explode if we don't do this...
|
||||
memset(&_work, 0, sizeof(_work));
|
||||
}
|
||||
|
||||
IST8310::~IST8310()
|
||||
@@ -1018,7 +999,7 @@ out:
|
||||
|
||||
int IST8310::calibrate(struct file *filp, unsigned enable)
|
||||
{
|
||||
struct mag_report report;
|
||||
struct mag_report report {};
|
||||
ssize_t sz;
|
||||
int ret = 1;
|
||||
float total_x = 0.0f;
|
||||
@@ -1387,7 +1368,7 @@ void
|
||||
test(enum IST8310_BUS busid)
|
||||
{
|
||||
struct ist8310_bus_option &bus = find_bus(busid);
|
||||
struct mag_report report;
|
||||
struct mag_report report {};
|
||||
ssize_t sz;
|
||||
int ret;
|
||||
const char *path = bus.devpath;
|
||||
|
||||
+11
-20
@@ -733,27 +733,18 @@ PX4IO::init()
|
||||
}
|
||||
|
||||
/* send command to arm system via command API */
|
||||
struct vehicle_command_s cmd = {
|
||||
.timestamp = hrt_absolute_time(),
|
||||
.param5 = 0.0f,
|
||||
.param6 = 0.0f,
|
||||
/* request arming */
|
||||
.param1 = 1.0f,
|
||||
.param2 = 0.0f,
|
||||
.param3 = 0.0f,
|
||||
.param4 = 0.0f,
|
||||
.param7 = 0.0f,
|
||||
.command = vehicle_command_s::VEHICLE_CMD_COMPONENT_ARM_DISARM,
|
||||
.target_system = (uint8_t)sys_id,
|
||||
.target_component = (uint8_t)comp_id,
|
||||
.source_system = (uint8_t)sys_id,
|
||||
.source_component = (uint8_t)comp_id,
|
||||
/* ask to confirm command */
|
||||
.confirmation = 1
|
||||
};
|
||||
vehicle_command_s vcmd = {};
|
||||
vcmd.timestamp = hrt_absolute_time();
|
||||
vcmd.param1 = 1.0f; /* request arming */
|
||||
vcmd.command = vehicle_command_s::VEHICLE_CMD_COMPONENT_ARM_DISARM;
|
||||
vcmd.target_system = (uint8_t)sys_id;
|
||||
vcmd.target_component = (uint8_t)comp_id;
|
||||
vcmd.source_system = (uint8_t)sys_id;
|
||||
vcmd.source_component = (uint8_t)comp_id;
|
||||
vcmd.confirmation = true; /* ask to confirm command */
|
||||
|
||||
/* send command once */
|
||||
orb_advert_t pub = orb_advertise_queue(ORB_ID(vehicle_command), &cmd, vehicle_command_s::ORB_QUEUE_LENGTH);
|
||||
orb_advert_t pub = orb_advertise_queue(ORB_ID(vehicle_command), &vcmd, vehicle_command_s::ORB_QUEUE_LENGTH);
|
||||
|
||||
/* spin here until IO's state has propagated into the system */
|
||||
do {
|
||||
@@ -774,7 +765,7 @@ PX4IO::init()
|
||||
|
||||
/* re-send if necessary */
|
||||
if (!safety.armed) {
|
||||
orb_publish(ORB_ID(vehicle_command), pub, &cmd);
|
||||
orb_publish(ORB_ID(vehicle_command), pub, &vcmd);
|
||||
DEVICE_LOG("re-sending arm cmd");
|
||||
}
|
||||
|
||||
|
||||
@@ -332,16 +332,13 @@ int InputMavlinkCmdMount::update_impl(unsigned int timeout_ms, ControlData **con
|
||||
|
||||
void InputMavlinkCmdMount::_ack_vehicle_command(vehicle_command_s *cmd)
|
||||
{
|
||||
vehicle_command_ack_s vehicle_command_ack = {
|
||||
.timestamp = hrt_absolute_time(),
|
||||
.result_param2 = 0,
|
||||
.command = cmd->command,
|
||||
.result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED,
|
||||
.from_external = false,
|
||||
.result_param1 = 0,
|
||||
.target_system = cmd->source_system,
|
||||
.target_component = cmd->source_component
|
||||
};
|
||||
vehicle_command_ack_s vehicle_command_ack = {};
|
||||
|
||||
vehicle_command_ack.timestamp = hrt_absolute_time();
|
||||
vehicle_command_ack.command = cmd->command;
|
||||
vehicle_command_ack.result = vehicle_command_s::VEHICLE_CMD_RESULT_ACCEPTED;
|
||||
vehicle_command_ack.target_system = cmd->source_system;
|
||||
vehicle_command_ack.target_component = cmd->source_component;
|
||||
|
||||
if (_vehicle_command_ack_pub == nullptr) {
|
||||
_vehicle_command_ack_pub = orb_advertise_queue(ORB_ID(vehicle_command_ack), &vehicle_command_ack,
|
||||
@@ -350,7 +347,6 @@ void InputMavlinkCmdMount::_ack_vehicle_command(vehicle_command_s *cmd)
|
||||
} else {
|
||||
orb_publish(ORB_ID(vehicle_command_ack), _vehicle_command_ack_pub, &vehicle_command_ack);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void InputMavlinkCmdMount::print_status()
|
||||
|
||||
@@ -61,19 +61,10 @@ OutputMavlink::~OutputMavlink()
|
||||
|
||||
int OutputMavlink::update(const ControlData *control_data)
|
||||
{
|
||||
vehicle_command_s vehicle_command = {
|
||||
.timestamp = 0,
|
||||
.param5 = 0.0,
|
||||
.param6 = 0.0,
|
||||
.param1 = 0.0f,
|
||||
.param2 = 0.0f,
|
||||
.param3 = 0.0f,
|
||||
.param4 = 0.0f,
|
||||
.param7 = 0.0f,
|
||||
.command = 0,
|
||||
.target_system = (uint8_t)_config.mavlink_sys_id,
|
||||
.target_component = (uint8_t)_config.mavlink_comp_id,
|
||||
};
|
||||
vehicle_command_s vehicle_command = {};
|
||||
vehicle_command.timestamp = hrt_absolute_time();
|
||||
vehicle_command.target_system = (uint8_t)_config.mavlink_sys_id;
|
||||
vehicle_command.target_component = (uint8_t)_config.mavlink_comp_id;
|
||||
|
||||
if (control_data) {
|
||||
//got new command
|
||||
|
||||
Reference in New Issue
Block a user