diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-05-06 12:55:39 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-05-06 12:55:39 +0200 |
commit | df6a0d5a1a4f528e5ba22747d7a4587b7a2263c4 (patch) | |
tree | 99a1fc2ccf7089bb0aaa58426e7289c560ff7c3d | |
parent | 5bc7295145204f7b5a349d9e1b04fe00fe896ed5 (diff) | |
download | px4-firmware-df6a0d5a1a4f528e5ba22747d7a4587b7a2263c4.tar.gz px4-firmware-df6a0d5a1a4f528e5ba22747d7a4587b7a2263c4.tar.bz2 px4-firmware-df6a0d5a1a4f528e5ba22747d7a4587b7a2263c4.zip |
mavlink: Only send the distance sensor message if the topic actually updates
-rw-r--r-- | src/modules/mavlink/mavlink_messages.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/modules/mavlink/mavlink_messages.cpp b/src/modules/mavlink/mavlink_messages.cpp index bef8a5a55..9c552515d 100644 --- a/src/modules/mavlink/mavlink_messages.cpp +++ b/src/modules/mavlink/mavlink_messages.cpp @@ -1339,22 +1339,23 @@ protected: void send(const hrt_abstime t) { - (void)range_sub->update(t); + if (range_sub->update(t)) { - uint8_t type; + uint8_t type; - switch (range->type) { - case RANGE_FINDER_TYPE_LASER: - type = MAV_DISTANCE_SENSOR_LASER; - break; - } + switch (range->type) { + case RANGE_FINDER_TYPE_LASER: + type = MAV_DISTANCE_SENSOR_LASER; + break; + } - uint8_t id = 0; - uint8_t orientation = 0; - uint8_t covariance = 20; + uint8_t id = 0; + uint8_t orientation = 0; + uint8_t covariance = 20; - mavlink_msg_distance_sensor_send(_channel, range->timestamp / 1000, type, id, orientation, - range->minimum_distance*100, range->maximum_distance*100, range->distance*100, covariance); + mavlink_msg_distance_sensor_send(_channel, range->timestamp / 1000, type, id, orientation, + range->minimum_distance*100, range->maximum_distance*100, range->distance*100, covariance); + } } }; |