37 #include <QHBoxLayout> 38 #include <QVBoxLayout> 43 #include "diagnostic_msgs/DiagnosticArray.h" 60 QFont h1_font(
"Times", 18);
61 QFont h2_font(
"Times", 14);
66 QHBoxLayout* system_status_header =
new QHBoxLayout;
67 QLabel* sys_stat_title =
new QLabel(
"System Status");
68 sys_stat_title->setAlignment(Qt::AlignCenter);
69 sys_stat_title->setFont(h1_font);
70 system_status_header->addWidget(sys_stat_title);
72 QHBoxLayout* system_status =
new QHBoxLayout;
73 QVBoxLayout* failures =
new QVBoxLayout;
74 QLabel* failure_label =
new QLabel(
"Failures");
75 failure_label->setAlignment(Qt::AlignCenter);
76 failure_label->setFont(h2_font);
77 failures->addWidget(failure_label);
84 system_status->addLayout(failures);
86 QVBoxLayout* overrange =
new QVBoxLayout;
87 QLabel* overrange_label =
new QLabel(
"Overrange");
88 overrange_label->setAlignment(Qt::AlignCenter);
89 overrange_label->setFont(h2_font);
90 overrange->addWidget(overrange_label);
95 overrange->addWidget(
new QLabel());
96 overrange->addWidget(
new QLabel());
97 system_status->addLayout(overrange);
99 QHBoxLayout* system_status_2 =
new QHBoxLayout;
100 QVBoxLayout* alarms =
new QVBoxLayout;
101 QLabel* alarms_label =
new QLabel(
"Alarms");
102 alarms_label->setAlignment(Qt::AlignCenter);
103 alarms_label->setFont(h2_font);
104 alarms->addWidget(alarms_label);
111 system_status_2->addLayout(alarms);
116 QHBoxLayout* filter_status_header =
new QHBoxLayout;
117 QLabel* filter_stat_title =
new QLabel(
"Filter Status");
118 filter_stat_title->setAlignment(Qt::AlignCenter);
119 filter_stat_title->setFont(h1_font);
120 filter_status_header->addWidget(filter_stat_title);
122 QHBoxLayout* filter_status =
new QHBoxLayout;
123 QVBoxLayout* initialization =
new QVBoxLayout;
124 QLabel* initialization_label =
new QLabel(
"Initialization");
125 initialization_label->setAlignment(Qt::AlignCenter);
126 initialization_label->setFont(h2_font);
127 initialization->addWidget(initialization_label);
132 initialization->addWidget(
new QLabel(
""));
133 initialization->addWidget(
new QLabel(
""));
134 initialization->addWidget(
new QLabel(
""));
135 filter_status->addLayout(initialization);
137 QVBoxLayout* gnss_fix =
new QVBoxLayout;
138 QLabel* gnss_label =
new QLabel(
"GNSS");
139 gnss_label->setAlignment(Qt::AlignCenter);
140 gnss_label->setFont(h2_font);
141 gnss_fix->addWidget(gnss_label);
149 filter_status->addLayout(gnss_fix);
151 QHBoxLayout* filter_status_2 =
new QHBoxLayout;
152 QVBoxLayout* filter_sources =
new QVBoxLayout;
153 QLabel* filter_sources_label =
new QLabel(
"Filter Sources");
154 filter_sources_label->setAlignment(Qt::AlignCenter);
155 filter_sources_label->setFont(h2_font);
156 filter_sources->addWidget(filter_sources_label);
164 filter_status_2->addLayout(filter_sources);
166 QVBoxLayout* layout =
new QVBoxLayout;
167 layout->addLayout(system_status_header);
168 layout->addLayout(system_status);
169 layout->addLayout(system_status_2);
170 layout->addLayout(filter_status_header);
171 layout->addLayout(filter_status);
172 layout->addLayout(filter_status_2);
189 QHBoxLayout* layout =
new QHBoxLayout;
191 painter->setEnabled(_enabled);
195 layout->addWidget(
new QLabel(_label.c_str()));
196 layout->addWidget(painter);
211 ROS_DEBUG(
"Recieved diagnostic message.");
212 int kvh_filters_index{0};
213 bool kvh_filters_found{
false};
215 int kvh_system_index{0};
216 bool kvh_system_found{
false};
219 for(diagnostic_msgs::DiagnosticStatus status : _diagArray->status)
221 if(status.name ==
"kvh_geo_fog_3d_driver_node: KVH Filters" && status.hardware_id ==
"KVH GEO FOG 3D")
223 kvh_filters_found =
true;
224 kvh_filters_index = loopCount;
226 else if(status.name ==
"kvh_geo_fog_3d_driver_node: KVH System" && status.hardware_id ==
"KVH GEO FOG 3D")
228 kvh_system_found =
true;
229 kvh_system_index = loopCount;
234 if (kvh_filters_found)
236 diagnostic_msgs::DiagnosticStatus kvh_status = _diagArray->status[kvh_filters_index];
238 for (diagnostic_msgs::KeyValue pair : kvh_status.values)
240 ROS_DEBUG(
"%s, %s", pair.key.c_str(), pair.value.c_str());
241 if(pair.key ==
"Orient INIT")
243 painter_map_[
"orientation_init"]->setEnabled(pair.value ==
"True");
245 else if(pair.key ==
"Nav INIT")
247 painter_map_[
"nav_init"]->setEnabled(pair.value ==
"True");
249 else if(pair.key ==
"Heading INIT")
251 painter_map_[
"heading_init"]->setEnabled(pair.value ==
"True");
253 else if(pair.key ==
"Time INIT")
255 painter_map_[
"time_init"]->setEnabled(pair.value ==
"True");
257 else if(pair.key ==
"Internal GNSS Enabled")
259 painter_map_[
"internal_gnss"]->setEnabled(pair.value ==
"True");
261 else if(pair.key ==
"Dual ANT Heading Active")
263 painter_map_[
"dual_antenna_head"]->setEnabled(pair.value ==
"True");
265 else if(pair.key ==
"Vel Heading Enabled")
267 painter_map_[
"vel_heading"]->setEnabled(pair.value ==
"True");
269 else if(pair.key ==
"Atm Alt Enabled")
271 painter_map_[
"atm_alt"]->setEnabled(pair.value ==
"True");
273 else if(pair.key ==
"EXT Pos Active")
275 painter_map_[
"ext_pos"]->setEnabled(pair.value ==
"True");
277 else if(pair.key ==
"EXT Vel Active")
279 painter_map_[
"ext_vel"]->setEnabled(pair.value ==
"True");
281 else if(pair.key ==
"EXT Heading Active")
283 painter_map_[
"ext_heading"]->setEnabled(pair.value ==
"True");
285 else if(pair.key ==
"Fix Status")
287 painter_map_[
"gnss_2D"]->setEnabled(pair.value ==
"2D Fix");
288 painter_map_[
"gnss_3D"]->setEnabled(pair.value ==
"3D Fix");
289 painter_map_[
"gnss_sbas"]->setEnabled(pair.value ==
"SBAS");
290 painter_map_[
"gnss_diff"]->setEnabled(pair.value ==
"Diff");
291 painter_map_[
"gnss_omni"]->setEnabled(pair.value ==
"Omni/Star");
292 painter_map_[
"gnss_rtk_float"]->setEnabled(pair.value ==
"RTK Float");
293 painter_map_[
"gnss_rtk"]->setEnabled(pair.value ==
"RTK Fixed");
295 else if(pair.key ==
"Event1")
299 else if(pair.key ==
"Event2")
305 ROS_ERROR(
"CODING ERROR! You shouldn't be able to get here.");
310 if (kvh_system_found)
312 diagnostic_msgs::DiagnosticStatus kvh_system_status = _diagArray->status[kvh_system_index];
314 for (diagnostic_msgs::KeyValue pair : kvh_system_status.values)
316 if (pair.key ==
"System")
318 painter_map_[
"system"]->setEnabled(pair.value ==
"False");
320 else if (pair.key ==
"Accel")
322 painter_map_[
"accelerometers_failure"]->setEnabled(pair.value ==
"False");
324 else if (pair.key ==
"Gyro")
326 painter_map_[
"gyroscopes_failure"]->setEnabled(pair.value ==
"False");
328 else if (pair.key ==
"Mag")
330 painter_map_[
"magnetometers_failure"]->setEnabled(pair.value ==
"False");
332 else if (pair.key ==
"Pressure")
334 painter_map_[
"pressure_failure"]->setEnabled(pair.value ==
"False");
336 else if (pair.key ==
"GNSS")
338 painter_map_[
"gnss"]->setEnabled(pair.value ==
"False");
340 else if (pair.key ==
"Acc OOR")
342 painter_map_[
"accelerometers_overrange"]->setEnabled(pair.value ==
"False");
344 else if (pair.key ==
"Gyro OOR")
346 painter_map_[
"gyroscopes_overrange"]->setEnabled(pair.value ==
"False");
348 else if (pair.key ==
"Mag OOR")
350 painter_map_[
"magnetometers_overrange"]->setEnabled(pair.value ==
"False");
352 else if (pair.key ==
"Pressure OOR")
354 painter_map_[
"pressure_overrange"]->setEnabled(pair.value ==
"False");
356 else if (pair.key ==
"Min Temp")
358 painter_map_[
"minimum_temp"]->setEnabled(pair.value ==
"False");
360 else if (pair.key ==
"Max Temp")
362 painter_map_[
"maximum_temp"]->setEnabled(pair.value ==
"False");
364 else if (pair.key ==
"Low V")
366 painter_map_[
"low_volt"]->setEnabled(pair.value ==
"False");
368 else if (pair.key ==
"High V")
370 painter_map_[
"high_volt"]->setEnabled(pair.value ==
"False");
372 else if (pair.key ==
"GNSS ANT DC")
374 painter_map_[
"gps_antenna"]->setEnabled(pair.value ==
"False");
376 else if (pair.key ==
"Data Overflow")
378 painter_map_[
"serial_port_over"]->setEnabled(pair.value ==
"False");
void DiagnosticsCallback(const diagnostic_msgs::DiagnosticArray::ConstPtr &)
Function to receive diagnostics information and calculate statuses.
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ros::Subscriber diag_sub_
ROS subscriber for diagnostics information.
RVIZ panel for displaying KVH sensor status.
PLUGINLIB_EXPORT_CLASS(kvh::StatusPanel, rviz::Panel)
KVH Geo Fog 3D RVIZ plugin status panel.
StatusPainter which lets us draw red/green circles for device status.
ros::NodeHandle nh_
Our ROS nodehandle object.
QHBoxLayout * StatusIndicatorFactory(bool, std::string, std::string)
Create mappings from our diagnostics strings to painters.
StatusPanel(QWidget *parent=0)
Constructor for our RVIZ panel.
std::unordered_map< std::string, StatusPainter * > painter_map_
Holds our key/value set of diagnostics message strings to painter objects.