nav_controller_output.cpp
Go to the documentation of this file.
1 
9 /*
10  * Copyright 2019 Karthik Desai
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/NavControllerOutput.h"
19 
20 namespace mavros
21 {
22 namespace std_plugins
23 {
30 {
31 public:
33  nh("~")
34  {
35  }
36 
37  void initialize(UAS &uas_)
38  {
39  PluginBase::initialize(uas_);
40  nco_pub = nh.advertise<mavros_msgs::NavControllerOutput>("nav_controller_output", 10);
41  }
42 
44  {
45  return {
47  };
48  }
49 
50 private:
52 
54 
55  void handle_nav_controller_output(const mavlink::mavlink_message_t *msg, mavlink::common::msg::NAV_CONTROLLER_OUTPUT &nav_controller_output)
56  {
57  auto nco_msg = boost::make_shared<mavros_msgs::NavControllerOutput>();
58  nco_msg->header.stamp = ros::Time::now();
59  nco_msg->nav_roll = nav_controller_output.nav_roll;
60  nco_msg->nav_pitch = nav_controller_output.nav_pitch;
61  nco_msg->nav_bearing = nav_controller_output.nav_bearing;
62  nco_msg->target_bearing = nav_controller_output.target_bearing;
63  nco_msg->wp_dist = nav_controller_output.wp_dist;
64  nco_msg->alt_error = nav_controller_output.alt_error;
65  nco_msg->aspd_error = nav_controller_output.aspd_error;
66  nco_msg->xtrack_error = nav_controller_output.xtrack_error;
67 
68  nco_pub.publish(nco_msg);
69  }
70 };
71 } // namespace std_plugins
72 } // namespace mavros
73 
Subscriptions get_subscriptions()
Return vector of MAVLink message subscriptions (handlers)
MAVROS Plugin base class.
Definition: mavros_plugin.h:36
MAVROS Plugin base.
HandlerInfo make_handler(const mavlink::msgid_t id, void(_C::*fn)(const mavlink::mavlink_message_t *msg, const mavconn::Framing framing))
Definition: mavros_plugin.h:87
PluginBase()
Plugin constructor Should not do anything before initialize()
Definition: mavros_plugin.h:74
void publish(const boost::shared_ptr< M > &message) const
UAS for plugins.
Definition: mavros_uas.h:67
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void handle_nav_controller_output(const mavlink::mavlink_message_t *msg, mavlink::common::msg::NAV_CONTROLLER_OUTPUT &nav_controller_output)
std::vector< HandlerInfo > Subscriptions
Subscriptions vector.
Definition: mavros_plugin.h:47
void initialize(UAS &uas_)
Plugin initializer.
static Time now()
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)


mavros
Author(s): Vladimir Ermakov
autogenerated on Tue Jun 13 2023 02:17:50