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 
mavros::std_plugins::NavControllerOutputPlugin::handle_nav_controller_output
void handle_nav_controller_output(const mavlink::mavlink_message_t *msg, mavlink::common::msg::NAV_CONTROLLER_OUTPUT &nav_controller_output)
Definition: nav_controller_output.cpp:55
mavros::plugin::PluginBase::Subscriptions
std::vector< HandlerInfo > Subscriptions
Subscriptions vector.
Definition: mavros_plugin.h:47
ros::Publisher
mavros::plugin::PluginBase::PluginBase
PluginBase()
Plugin constructor Should not do anything before initialize()
Definition: mavros_plugin.h:74
mavros::UAS
UAS for plugins.
Definition: mavros_uas.h:67
mavros::std_plugins::NavControllerOutputPlugin::nh
ros::NodeHandle nh
Definition: nav_controller_output.cpp:51
mavros::std_plugins::NavControllerOutputPlugin::initialize
void initialize(UAS &uas_)
Plugin initializer.
Definition: nav_controller_output.cpp:37
mavros::std_plugins::NavControllerOutputPlugin::nco_pub
ros::Publisher nco_pub
Definition: nav_controller_output.cpp:53
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
ros::NodeHandle::advertise
Publisher advertise(AdvertiseOptions &ops)
mavros::std_plugins::NavControllerOutputPlugin
nav controller output plugin.
Definition: nav_controller_output.cpp:29
PLUGINLIB_EXPORT_CLASS
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
mavros::std_plugins::NavControllerOutputPlugin::get_subscriptions
Subscriptions get_subscriptions()
Return vector of MAVLink message subscriptions (handlers)
Definition: nav_controller_output.cpp:43
mavros::std_plugins::NavControllerOutputPlugin::NavControllerOutputPlugin
NavControllerOutputPlugin()
Definition: nav_controller_output.cpp:32
mavros_plugin.h
MAVROS Plugin base.
mavros
Definition: frame_tf.h:34
mavros::plugin::PluginBase
MAVROS Plugin base class.
Definition: mavros_plugin.h:36
class_list_macros.hpp
mavros::plugin::PluginBase::make_handler
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
ros::NodeHandle
ros::Time::now
static Time now()


mavros
Author(s): Vladimir Ermakov
autogenerated on Tue May 6 2025 02:34:03