mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 05:13:34 +08:00
Sensor sim: Initialize sensor data to zero
This commit is contained in:
@@ -448,6 +448,9 @@ ACCELSIM::init()
|
||||
{
|
||||
int ret = ERROR;
|
||||
|
||||
struct mag_report mrp = {};
|
||||
struct accel_report arp = {};
|
||||
|
||||
/* do SIM init first */
|
||||
if (VDev::init() != OK) {
|
||||
PX4_WARN("SIM init failed");
|
||||
@@ -478,7 +481,6 @@ ACCELSIM::init()
|
||||
measure();
|
||||
|
||||
/* advertise sensor topic, measure manually to initialize valid report */
|
||||
struct mag_report mrp;
|
||||
_mag_reports->get(&mrp);
|
||||
|
||||
/* measurement will have generated a report, publish */
|
||||
@@ -493,7 +495,6 @@ ACCELSIM::init()
|
||||
_accel_class_instance = register_class_devname(ACCEL_BASE_DEVICE_PATH);
|
||||
|
||||
/* advertise sensor topic, measure manually to initialize valid report */
|
||||
struct accel_report arp = {};
|
||||
_accel_reports->get(&arp);
|
||||
|
||||
/* measurement will have generated a report, publish */
|
||||
@@ -1014,7 +1015,7 @@ ACCELSIM::measure()
|
||||
} raw_accel_report;
|
||||
#pragma pack(pop)
|
||||
|
||||
accel_report accel_report;
|
||||
accel_report accel_report = {};
|
||||
|
||||
/* start the performance counter */
|
||||
perf_begin(_accel_sample_perf);
|
||||
@@ -1023,7 +1024,7 @@ ACCELSIM::measure()
|
||||
memset(&raw_accel_report, 0, sizeof(raw_accel_report));
|
||||
raw_accel_report.cmd = DIR_READ | ACC_READ;
|
||||
|
||||
if(OK != transfer((uint8_t *)&raw_accel_report, (uint8_t *)&raw_accel_report, sizeof(raw_accel_report))) {
|
||||
if (OK != transfer((uint8_t *)&raw_accel_report, (uint8_t *)&raw_accel_report, sizeof(raw_accel_report))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user