mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
df_trone_wrapper: don't advertise garbage
This commit is contained in:
parent
40d6a4e5fc
commit
44207a3a5c
@ -117,10 +117,6 @@ DfTROneWrapper::~DfTROneWrapper()
|
||||
|
||||
int DfTROneWrapper::start()
|
||||
{
|
||||
struct distance_sensor_s d;
|
||||
_range_topic = orb_advertise_multi(ORB_ID(distance_sensor), &d,
|
||||
&_orb_class_instance, ORB_PRIO_DEFAULT);
|
||||
|
||||
int ret;
|
||||
|
||||
/* Init device and start sensor. */
|
||||
@ -156,10 +152,6 @@ int DfTROneWrapper::stop()
|
||||
|
||||
int DfTROneWrapper::_publish(struct range_sensor_data &data)
|
||||
{
|
||||
if (!_range_topic) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct distance_sensor_s d;
|
||||
|
||||
memset(&d, 0, sizeof(d));
|
||||
@ -180,7 +172,12 @@ int DfTROneWrapper::_publish(struct range_sensor_data &data)
|
||||
|
||||
d.covariance = 0.0f;
|
||||
|
||||
orb_publish(ORB_ID(distance_sensor), _range_topic, &d);
|
||||
if (_range_topic == nullptr) {
|
||||
_range_topic = orb_advertise_multi(ORB_ID(distance_sensor), &d,
|
||||
&_orb_class_instance, ORB_PRIO_DEFAULT);
|
||||
} else {
|
||||
orb_publish(ORB_ID(distance_sensor), _range_topic, &d);
|
||||
}
|
||||
|
||||
/* Notify anyone waiting for data. */
|
||||
DevMgr::updateNotify(*this);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user