rangefinder.cpp
Go to the documentation of this file.
1 
9 /*
10  * Copyright 2016 Ardupilot.
11  *
12  * This file is part of the mavros package and subject to the license terms
13  * in the top-level LICENSE file of the mavros repository.
14  * https://github.com/mavlink/mavros/tree/master/LICENSE.md
15  */
16 
17 #include <mavros/mavros_plugin.h>
18 #include <sensor_msgs/Range.h>
19 
20 namespace mavros {
21 namespace extra_plugins {
29 public:
31  rangefinder_nh("~rangefinder")
32  { }
33 
34  void initialize(UAS &uas_) override
35  {
37 
38  rangefinder_pub = rangefinder_nh.advertise<sensor_msgs::Range>("rangefinder", 10);
39  }
40 
42  {
43  return {
45  };
46  }
47 
48 private:
50 
52 
53  void handle_rangefinder(const mavlink::mavlink_message_t *msg, mavlink::ardupilotmega::msg::RANGEFINDER &rangefinder) {
54  auto rangefinder_msg = boost::make_shared<sensor_msgs::Range>();
55  rangefinder_msg->header.stamp = ros::Time::now();
56  rangefinder_msg->header.frame_id = "/rangefinder";
57  rangefinder_msg->radiation_type = sensor_msgs::Range::INFRARED;
58  rangefinder_msg->field_of_view = 0;
59  rangefinder_msg->min_range = 0;
60  rangefinder_msg->max_range = 1000;
61  rangefinder_msg->range = rangefinder.distance;
62 
63  rangefinder_pub.publish(rangefinder_msg);
64  }
65 };
66 } // namespace extra_plugins
67 } // namespace mavros
68 
void handle_rangefinder(const mavlink::mavlink_message_t *msg, mavlink::ardupilotmega::msg::RANGEFINDER &rangefinder)
Definition: rangefinder.cpp:53
void publish(const boost::shared_ptr< M > &message) const
HandlerInfo make_handler(const mavlink::msgid_t id, void(_C::*fn)(const mavlink::mavlink_message_t *msg, const mavconn::Framing framing))
Subscriptions get_subscriptions() override
Definition: rangefinder.cpp:41
void initialize(UAS &uas_) override
Definition: rangefinder.cpp:34
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
std::vector< HandlerInfo > Subscriptions
Ardupilot Rangefinder plugin.
Definition: rangefinder.cpp:28
static Time now()
void initialize(UAS &uas_) override
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)


mavros_extras
Author(s): Vladimir Ermakov , Amilcar Lucas
autogenerated on Tue Jun 1 2021 02:36:36