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::minimal::MAV_COMPONENT;
30 using utils::enum_value;
31 
39 public:
41  status_nh("~companion_process")
42  { }
43 
44  void initialize(UAS &uas_) override
45  {
47 
49  }
50 
52  {
53  return { /* Rx disabled */ };
54  }
55 
56 private:
59 
67  {
68  mavlink::minimal::msg::HEARTBEAT heartbeat {};
69 
70  heartbeat.type = enum_value(MAV_TYPE::ONBOARD_CONTROLLER);
71  heartbeat.autopilot = enum_value(MAV_AUTOPILOT::PX4);
72  heartbeat.base_mode = enum_value(MAV_MODE_FLAG::CUSTOM_MODE_ENABLED);
73  heartbeat.system_status = req->state; //enum="MAV_STATE" System status flag
74 
75  ROS_DEBUG_STREAM_NAMED("companion_process_status", "companion process component id: " <<
76  utils::to_string_enum<MAV_COMPONENT>(req->component) << " companion process status: " <<
77  utils::to_string_enum<MAV_STATE>(heartbeat.system_status) << std::endl << heartbeat.to_yaml());
78 
79  UAS_FCU(m_uas)->send_message_ignore_drop(heartbeat, req->component);
80  }
81 };
82 } // namespace extra_plugins
83 } // namespace mavros
84 
std::shared_ptr< MAVConnInterface const > ConstPtr
mavlink::minimal::MAV_TYPE MAV_TYPE
#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::minimal::MAV_STATE MAV_STATE
#define UAS_FCU(uasobjptr)
mavlink::minimal::MAV_MODE_FLAG MAV_MODE_FLAG
void status_cb(const mavros_msgs::CompanionProcessStatus::ConstPtr &req)
Send companion process status to FCU over a heartbeat message.
std::vector< HandlerInfo > Subscriptions
mavlink::minimal::MAV_AUTOPILOT MAV_AUTOPILOT
void initialize(UAS &uas_) override
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
constexpr std::underlying_type< _T >::type enum_value(_T e)


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