companion_process_status.cpp
Go to the documentation of this file.
1 
9 /*
10  * Copyright 2018 Tanja Baumann.
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 
19 #include <mavros_msgs/CompanionProcessStatus.h>
20 
21 namespace mavros {
22 namespace extra_plugins {
23 
27 using mavlink::common::MAV_COMPONENT;
28 using utils::enum_value;
29 
37 public:
39  status_nh("~companion_process")
40  { }
41 
42  void initialize(UAS &uas_)
43  {
45 
47  }
48 
50  {
51  return { /* Rx disabled */ };
52  }
53 
54 private:
57 
65  {
66  mavlink::common::msg::HEARTBEAT heartbeat {};
67 
68  heartbeat.type = enum_value(mavlink::common::MAV_TYPE::ONBOARD_CONTROLLER);
69  heartbeat.autopilot = enum_value(mavlink::common::MAV_AUTOPILOT::PX4);
70  heartbeat.base_mode = enum_value(mavlink::common::MAV_MODE_FLAG::CUSTOM_MODE_ENABLED);
71  heartbeat.system_status = req->state; //enum="MAV_STATE" System status flag
72 
73  ROS_DEBUG_STREAM_NAMED("companion_process_status", "companion process component id: " <<
74  utils::to_string_enum<MAV_COMPONENT>(req->component) << " companion process status: " <<
75  utils::to_string_enum<MAV_STATE>(heartbeat.system_status) << std::endl << heartbeat.to_yaml());
76 
77  UAS_FCU(m_uas)->send_message_ignore_drop(heartbeat, req->component);
78  }
79 };
80 } // namespace extra_plugins
81 } // namespace mavros
82 
std::shared_ptr< MAVConnInterface const > ConstPtr
#define ROS_DEBUG_STREAM_NAMED(name, args)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
mavlink::common::MAV_TYPE MAV_TYPE
#define UAS_FCU(uasobjptr)
void status_cb(const mavros_msgs::CompanionProcessStatus::ConstPtr &req)
Send companion process status to FCU over a heartbeat message.
std::vector< HandlerInfo > Subscriptions
void initialize(UAS &uas_)
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
mavlink::common::MAV_STATE MAV_STATE
constexpr std::underlying_type< _T >::type enum_value(_T e)


mavros_extras
Author(s): Vladimir Ermakov
autogenerated on Mon Jul 8 2019 03:20:18