terrain.cpp
Go to the documentation of this file.
1 
9 /*
10  * Copyright 2021 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 <mavros_msgs/TerrainReport.h>
19 
20 namespace mavros {
21 namespace extra_plugins {
29 public:
31  terrain_nh("~terrain")
32  { }
33 
34  void initialize(UAS &uas_) override
35  {
37 
38  terrain_report_pub = terrain_nh.advertise<mavros_msgs::TerrainReport>("report", 10);
39  }
40 
42  {
43  return {
45  };
46  }
47 
48 private:
50 
52 
53  void handle_terrain_report(const mavlink::mavlink_message_t *msg, mavlink::common::msg::TERRAIN_REPORT &report) {
54  auto terrain_report_msg = boost::make_shared<mavros_msgs::TerrainReport>();
55 
56  terrain_report_msg->header.stamp = ros::Time::now();
57  terrain_report_msg->header.frame_id = "terrain";
58 
59  terrain_report_msg->latitude = (double) report.lat / 1e7;
60  terrain_report_msg->longitude = (double) report.lon / 1e7;
61  terrain_report_msg->spacing = report.spacing;
62  terrain_report_msg->terrain_height = report.terrain_height;
63  terrain_report_msg->current_height = report.current_height;
64  terrain_report_msg->pending = report.pending;
65  terrain_report_msg->loaded = report.loaded;
66 
67  terrain_report_pub.publish(terrain_report_msg);
68  }
69 };
70 } // namespace extra_plugins
71 } // namespace mavros
72 
void handle_terrain_report(const mavlink::mavlink_message_t *msg, mavlink::common::msg::TERRAIN_REPORT &report)
Definition: terrain.cpp:53
HandlerInfo make_handler(const mavlink::msgid_t id, void(_C::*fn)(const mavlink::mavlink_message_t *msg, const mavconn::Framing framing))
void publish(const boost::shared_ptr< M > &message) const
void initialize(UAS &uas_) override
Definition: terrain.cpp:34
Subscriptions get_subscriptions() override
Definition: terrain.cpp:41
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
std::vector< HandlerInfo > Subscriptions
static Time now()
void initialize(UAS &uas_) override
Terrain height plugin.
Definition: terrain.cpp:28
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)


mavros_extras
Author(s): Vladimir Ermakov , Amilcar Lucas
autogenerated on Tue Jun 13 2023 02:17:59