onboard_computer_status.cpp
Go to the documentation of this file.
1 
9 /*
10  * Copyright 2019 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/OnboardComputerStatus.h>
20 
21 namespace mavros {
22 namespace extra_plugins {
30 public:
32  status_nh("~onboard_computer")
33  { }
34 
35  void initialize(UAS &uas_) override
36  {
38 
40  }
41 
43  {
44  return { /* Rx disabled */ };
45  }
46 
47 private:
50 
58  {
59  mavlink::common::msg::ONBOARD_COMPUTER_STATUS status {};
60  status.time_usec = req->header.stamp.toNSec() / 1000;
61  // [[[cog:
62  // for f in ('uptime',
63  // 'type',
64  // 'temperature_board',
65  // 'ram_usage',
66  // 'ram_total'):
67  // cog.outl("status.%s = req->%s;" % (f, f))
68  //
69  // for f in ('cpu_cores',
70  // 'cpu_combined',
71  // 'gpu_cores',
72  // 'gpu_combined',
73  // 'temperature_core',
74  // 'fan_speed',
75  // 'storage_type',
76  // 'storage_usage',
77  // 'storage_total',
78  // 'link_type',
79  // 'link_tx_rate',
80  // 'link_rx_rate',
81  // 'link_tx_max',
82  // 'link_rx_max'):
83  // cog.outl("std::copy(req->%s.cbegin(), req->%s.cend(), status.%s.begin());" % (f, f, f))
84  // ]]]
85  status.uptime = req->uptime;
86  status.type = req->type;
87  status.temperature_board = req->temperature_board;
88  status.ram_usage = req->ram_usage;
89  status.ram_total = req->ram_total;
90  std::copy(req->cpu_cores.cbegin(), req->cpu_cores.cend(), status.cpu_cores.begin());
91  std::copy(req->cpu_combined.cbegin(), req->cpu_combined.cend(), status.cpu_combined.begin());
92  std::copy(req->gpu_cores.cbegin(), req->gpu_cores.cend(), status.gpu_cores.begin());
93  std::copy(req->gpu_combined.cbegin(), req->gpu_combined.cend(), status.gpu_combined.begin());
94  std::copy(req->temperature_core.cbegin(), req->temperature_core.cend(), status.temperature_core.begin());
95  std::copy(req->fan_speed.cbegin(), req->fan_speed.cend(), status.fan_speed.begin());
96  std::copy(req->storage_type.cbegin(), req->storage_type.cend(), status.storage_type.begin());
97  std::copy(req->storage_usage.cbegin(), req->storage_usage.cend(), status.storage_usage.begin());
98  std::copy(req->storage_total.cbegin(), req->storage_total.cend(), status.storage_total.begin());
99  std::copy(req->link_type.cbegin(), req->link_type.cend(), status.link_type.begin());
100  std::copy(req->link_tx_rate.cbegin(), req->link_tx_rate.cend(), status.link_tx_rate.begin());
101  std::copy(req->link_rx_rate.cbegin(), req->link_rx_rate.cend(), status.link_rx_rate.begin());
102  std::copy(req->link_tx_max.cbegin(), req->link_tx_max.cend(), status.link_tx_max.begin());
103  std::copy(req->link_rx_max.cbegin(), req->link_rx_max.cend(), status.link_rx_max.begin());
104  // [[[end]]] (checksum: 98538293a5932dfb5952d4badd311b39)
105 
106  std::cout << "timestamp: " << status.time_usec << "\n";
107 
108  UAS_FCU(m_uas)->send_message_ignore_drop(status, req->component);
109  }
110 };
111 } // namespace extra_plugins
112 } // namespace mavros
113 
std::shared_ptr< MAVConnInterface const > ConstPtr
void status_cb(const mavros_msgs::OnboardComputerStatus::ConstPtr &req)
Send onboard computer status to FCU and groundstation.
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
#define UAS_FCU(uasobjptr)
std::vector< HandlerInfo > Subscriptions
void initialize(UAS &uas_) override
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)


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