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 {
26 using mavlink::minimal::MAV_COMPONENT;
29 using utils::enum_value;
30 
38 public:
40  status_nh("~companion_process")
41  { }
42 
43  void initialize(UAS &uas_) override
44  {
46 
48  }
49 
51  {
52  return { /* Rx disabled */ };
53  }
54 
55 private:
58 
66  {
67  mavlink::minimal::msg::HEARTBEAT heartbeat {};
68 
69  heartbeat.type = enum_value(MAV_TYPE::ONBOARD_CONTROLLER);
70  heartbeat.autopilot = enum_value(MAV_AUTOPILOT::PX4);
71  heartbeat.base_mode = enum_value(MAV_MODE_FLAG::CUSTOM_MODE_ENABLED);
72  heartbeat.system_status = req->state; //enum="MAV_STATE" System status flag
73 
74  ROS_DEBUG_STREAM_NAMED("companion_process_status", "companion process component id: " <<
75  utils::to_string_enum<MAV_COMPONENT>(req->component) << " companion process status: " <<
76  utils::to_string_enum<MAV_STATE>(heartbeat.system_status) << std::endl << heartbeat.to_yaml());
77 
78  UAS_FCU(m_uas)->send_message_ignore_drop(heartbeat, req->component);
79  }
80 };
81 } // namespace extra_plugins
82 } // namespace mavros
83 
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 13 2023 02:17:59