kvh_diagnostics_container.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (Apache 2.0)
3  *
4  * Copyright (c) 2019, The MITRE Corporation.
5  * All rights reserved.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * https://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * Sections of this project contains content developed by The MITRE Corporation.
20  * If this code is used in a deployment or embedded within another project,
21  * it is requested that you send an email to opensource@mitre.org in order to
22  * let us know where this software is being used.
23  *********************************************************************/
24 
32 
34 {
35 
36 } //end: DiagnosticsContainer()
37 
39 {
41  {
42  if( systemStatus_ == 0 )
43  {
44  stat.summary(diagnostic_msgs::DiagnosticStatus::OK, "System State OK");
45  stat.add("System", false);
46  stat.add("Accel", false);
47  stat.add("Gyro", false);
48  stat.add("Mag", false);
49  stat.add("Pressure", false);
50  stat.add("GNSS", false);
51  stat.add("Acc OOR", false);
52  stat.add("Gyro OOR", false);
53  stat.add("Mag OOR", false);
54  stat.add("Pressure OOR", false);
55  stat.add("Min Temp", false);
56  stat.add("Max Temp", false);
57  stat.add("Low V", false);
58  stat.add("High V", false);
59  stat.add("GNSS ANT DC", false);
60  stat.add("Data Overflow", false);
61  } //end: if( systemStatus_ == 0 )
62  else
63  {
64  stat.summary(diagnostic_msgs::DiagnosticStatus::ERROR, "System FAULT");
65  if( systemStatus_ & 0x1 )
66  {
67  stat.add("System", true);
68  }
69  else
70  {
71  stat.add("System", false);
72  }
73  if( systemStatus_ & 0x2 )
74  {
75  stat.add("Accel", true);
76  }
77  else
78  {
79  stat.add("Accel", false);
80  }
81  if( systemStatus_ & 0x4 )
82  {
83  stat.add("Gyro", true);
84  }
85  else
86  {
87  stat.add("Gyro", false);
88  }
89  if( systemStatus_ & 0x8 )
90  {
91  stat.add("Mag", true);
92  }
93  else
94  {
95  stat.add("Mag", false);
96  }
97  if( systemStatus_ & 0x10 )
98  {
99  stat.add("Pressure", true);
100  }
101  else
102  {
103  stat.add("Pressure", false);
104  }
105  if( systemStatus_ & 0x20 )
106  {
107  stat.add("GNSS", true);
108  }
109  else
110  {
111  stat.add("GNSS", false);
112  }
113  if( systemStatus_ & 0x40 )
114  {
115  stat.add("Acc OOR", true);
116  }
117  else
118  {
119  stat.add("Acc OOR", false);
120  }
121  if( systemStatus_ & 0x80 )
122  {
123  stat.add("Gyro OOR", true);
124  }
125  else
126  {
127  stat.add("Gyro OOR", false);
128  }
129  if( systemStatus_ & 0x100 )
130  {
131  stat.add("Mag OOR", true);
132  }
133  else
134  {
135  stat.add("Mag OOR", false);
136  }
137  if( systemStatus_ & 0x200 )
138  {
139  stat.add("Pressure OOR", true);
140  }
141  else
142  {
143  stat.add("Pressure OOR", false);
144  }
145  if( systemStatus_ & 0x400 )
146  {
147  stat.add("Min Temp", true);
148  }
149  else
150  {
151  stat.add("Min Temp", false);
152  }
153  if( systemStatus_ & 0x800 )
154  {
155  stat.add("Max Temp", true);
156  }
157  else
158  {
159  stat.add("Max Temp", false);
160  }
161  if( systemStatus_ & 0x1000 )
162  {
163  stat.add("Low V", true);
164  }
165  else
166  {
167  stat.add("Low V", false);
168  }
169  if( systemStatus_ & 0x2000 )
170  {
171  stat.add("High V", true);
172  }
173  else
174  {
175  stat.add("High V", false);
176  }
177  if( systemStatus_ & 0x4000 )
178  {
179  stat.add("GNSS ANT DC", true);
180  }
181  else
182  {
183  stat.add("GNSS ANT DC", false);
184  }
185  if( systemStatus_ & 0x8000 )
186  {
187  stat.add("Data Overflow", true);
188  }
189  else
190  {
191  stat.add("Data Overflow", false);
192  }
193  } //end: else
194  } //end: if( receivedSystemStatus )
195  else
196  {
197  stat.summary(diagnostic_msgs::DiagnosticStatus::STALE, "Waiting on initial SystemState packet");
198  } //end: else
199 } //end: UpdateSystemStatus()
200 
202 {
203  uint8_t level = diagnostic_msgs::DiagnosticStatus::OK;
205  {
207  //For each filter, check to see if they're initialized.
208  //If they are not, set the level to WARN
209  bool currentValue = filterStatus_ & 0x1;
210  if( currentValue == false )
211  {
212  level = diagnostic_msgs::DiagnosticStatus::WARN;
213  }
214  stat.add("Orient INIT", currentValue);
215 
216  currentValue = filterStatus_ & 0x2;
217  if( currentValue == false )
218  {
219  level = diagnostic_msgs::DiagnosticStatus::WARN;
220  }
221  stat.add("Nav INIT", currentValue);
222 
223  currentValue = filterStatus_ & 0x4;
224  if( currentValue == false )
225  {
226  level = diagnostic_msgs::DiagnosticStatus::WARN;
227  }
228  stat.add("Heading INIT", currentValue);
229 
230  currentValue = filterStatus_ & 0x8;
231  if( currentValue == false )
232  {
233  level = diagnostic_msgs::DiagnosticStatus::WARN;
234  }
235  stat.add("Time INIT", currentValue);
237 
239  // Check GNSS Fix status
240  // No fix is warn, everything else is OK
241  // These 3 bits are 0x10, 0x20, and 0x40 (so 0x70 for all 3) then shift right to remove zeros
242  std::string currentStatusStr("");
243  switch(static_cast<int>((filterStatus_ & 0x70) >> 4))
244  {
245  case 0:
246  {
247  level = diagnostic_msgs::DiagnosticStatus::WARN;
248  currentStatusStr = std::string("No Fix");
249  break;
250  }
251  case 1:
252  {
253  currentStatusStr = std::string("2D Fix");
254  break;
255  }
256  case 2:
257  {
258  currentStatusStr = std::string("3D Fix");
259  break;
260  }
261  case 3:
262  {
263  currentStatusStr = std::string("SBAS");
264  break;
265  }
266  case 4:
267  {
268  currentStatusStr = std::string("Diff");
269  break;
270  }
271  case 5:
272  {
273  currentStatusStr = std::string("Omni/Star");
274  break;
275  }
276  case 6:
277  {
278  currentStatusStr = std::string("RTK Float");
279  break;
280  }
281  case 7:
282  {
283  currentStatusStr = std::string("RTK Fixed");
284  break;
285  }
286  default:
287  {
288  currentStatusStr = std::string("CODING ERROR: YOU CAN'T GET HERE!!!");
289  break;
290  }
291  } //end: switch(static_cast<int>(filterStatus_ & 0x70))
292  stat.add("Fix Status", currentStatusStr);
294 
296  // These all don't effect status, but we will report them
297  bool event1 = filterStatus_ & 0x80;
298  bool event2 = filterStatus_ & 0x100;
299  bool internalGNSSEnabled = filterStatus_ & 0x200;
300  bool dualAntennaHeadingActive = filterStatus_ & 0x400;
301  bool velocityHeadingEnabled = filterStatus_ & 0x800;
302  bool atmosphericAltitudeEnabled = filterStatus_ & 0x1000;
303  bool extPositionActive = filterStatus_ & 0x2000;
304  bool extVelocityActive = filterStatus_ & 0x4000;
305  bool extHeadingActive = filterStatus_ & 0x8000;
306  stat.add("Event1", event1);
307  stat.add("Event2", event2);
308  stat.add("Internal GNSS Enabled", internalGNSSEnabled);
309  stat.add("Dual ANT Heading Active", dualAntennaHeadingActive);
310  stat.add("Vel Heading Enabled", velocityHeadingEnabled);
311  stat.add("Atm Alt Enabled", atmosphericAltitudeEnabled);
312  stat.add("EXT Pos Active", extPositionActive);
313  stat.add("EXT Vel Active", extVelocityActive);
314  stat.add("EXT Heading Active", extHeadingActive);
316 
317  if( level == diagnostic_msgs::DiagnosticStatus::OK )
318  {
319  stat.summary(level, "Filters OK");
320  }
321  else
322  {
323  stat.summary(level, "Filters have issues");
324  }
325  } //end: if( receivedFilterStatus_ )
326  else
327  {
328  level = diagnostic_msgs::DiagnosticStatus::STALE;
329  stat.summary(level, "Waiting on initial FilterStatus packet");
330  } //end: else
331 } //end: UpdateFilterStatus()
void UpdateSystemStatus(diagnostic_updater::DiagnosticStatusWrapper &stat)
void summary(unsigned char lvl, const std::string s)
Contains diagnostic information published out the ROS diagnostics topic.
void add(const std::string &key, const T &val)
void UpdateFilterStatus(diagnostic_updater::DiagnosticStatusWrapper &stat)


kvh_geo_fog_3d_driver
Author(s): Trevor Bostic , Zach LaCelle
autogenerated on Fri Jan 24 2020 03:18:17