mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 17:13:34 +08:00
df_trone_wrapper: don't advertise garbage
This commit is contained in:
@@ -117,10 +117,6 @@ DfTROneWrapper::~DfTROneWrapper()
|
|||||||
|
|
||||||
int DfTROneWrapper::start()
|
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;
|
int ret;
|
||||||
|
|
||||||
/* Init device and start sensor. */
|
/* Init device and start sensor. */
|
||||||
@@ -156,10 +152,6 @@ int DfTROneWrapper::stop()
|
|||||||
|
|
||||||
int DfTROneWrapper::_publish(struct range_sensor_data &data)
|
int DfTROneWrapper::_publish(struct range_sensor_data &data)
|
||||||
{
|
{
|
||||||
if (!_range_topic) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct distance_sensor_s d;
|
struct distance_sensor_s d;
|
||||||
|
|
||||||
memset(&d, 0, sizeof(d));
|
memset(&d, 0, sizeof(d));
|
||||||
@@ -180,7 +172,12 @@ int DfTROneWrapper::_publish(struct range_sensor_data &data)
|
|||||||
|
|
||||||
d.covariance = 0.0f;
|
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. */
|
/* Notify anyone waiting for data. */
|
||||||
DevMgr::updateNotify(*this);
|
DevMgr::updateNotify(*this);
|
||||||
|
|||||||
Reference in New Issue
Block a user