kvh_geo_fog_3d_node.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 
33 // STD
34 #include "unistd.h"
35 #include <map>
36 #include <cmath>
37 
38 // KVH GEO FOG
41 #include "spatial_packets.h"
43 #include "packet_publisher.hpp"
44 
45 // ROS
46 #include "ros/ros.h"
49 #include <geometry_msgs/TransformStamped.h>
51 
52 // Custom ROS msgs
53 #include <kvh_geo_fog_3d_msgs/KvhGeoFog3DSystemState.h>
54 #include <kvh_geo_fog_3d_msgs/KvhGeoFog3DSatellites.h>
55 #include <kvh_geo_fog_3d_msgs/KvhGeoFog3DDetailSatellites.h>
56 #include <kvh_geo_fog_3d_msgs/KvhGeoFog3DLocalMagneticField.h>
57 #include <kvh_geo_fog_3d_msgs/KvhGeoFog3DUTMPosition.h>
58 #include <kvh_geo_fog_3d_msgs/KvhGeoFog3DECEFPos.h>
59 #include <kvh_geo_fog_3d_msgs/KvhGeoFog3DNorthSeekingInitStatus.h>
60 #include <kvh_geo_fog_3d_msgs/KvhGeoFog3DOdometerState.h>
61 #include <kvh_geo_fog_3d_msgs/KvhGeoFog3DRawGNSS.h>
62 #include <kvh_geo_fog_3d_msgs/KvhGeoFog3DRawSensors.h>
63 
64 // Standard ROS msgs
65 #include "sensor_msgs/Imu.h"
66 #include "sensor_msgs/NavSatFix.h"
67 #include "sensor_msgs/NavSatStatus.h"
68 #include "sensor_msgs/MagneticField.h"
69 #include "nav_msgs/Odometry.h"
70 #include "geometry_msgs/Quaternion.h"
71 #include "geometry_msgs/Vector3.h"
72 #include "geometry_msgs/Vector3Stamped.h"
73 #include "geometry_msgs/TwistWithCovarianceStamped.h"
74 
75 // // Bounds on [-pi, pi)
76 // inline double BoundFromNegPiToPi(const double &_value)
77 // {
78 // double num = std::fmod(_value, (2*M_PI));
79 // if (num > M_PI)
80 // {
81 // num = num - (2*M_PI);
82 // }
83 // return num;
84 // } //end: BoundFromNegPiToPi(double* _value)
85 
86 // inline double BoundFromNegPiToPi(const float &_value)
87 // {
88 // double num = std::fmod(_value, (2*M_PI));
89 // if (num > M_PI)
90 // {
91 // num = num - (2*M_PI);
92 // }
93 // return num;
94 // } //end: BoundFromNegPiToPi(const float& _value)
95 
96 // // Bounds on [-pi, pi)
97 // inline double BoundFromZeroTo2Pi(const double &_value)
98 // {
99 // return std::fmod(_value, (2 * M_PI));
100 // } //end: BoundFromZeroTo2Pi(double* _value)
101 
102 // inline double BoundFromZeroTo2Pi(const float &_value)
103 // {
104 // return std::fmod(_value, (2 * M_PI));
105 // } //end: BoundFromZeroTo2Pi(const float& _value)
106 
108 {
109  _diagnostics->setHardwareID("KVH GEO FOG 3D");
110 
113  _diagnostics->add("KVH System", _diagContainer, &mitre::KVH::DiagnosticsContainer::UpdateSystemStatus);
114  _diagnostics->add("KVH Filters", _diagContainer, &mitre::KVH::DiagnosticsContainer::UpdateFilterStatus);
115 }
116 
118 {
119 
120  // Check if the port has been set on the ros param server
121  _node.getParam("port", _initOptions.port);
122  _node.getParam("baud", _initOptions.baudRate);
123  _node.getParam("debug", _initOptions.debugOn);
124 
125  int filterVehicleType;
126  if (_node.getParam("filterVehicleType", filterVehicleType))
127  {
128  // node.getParam doesn't have an overload for uint8_t
129  _initOptions.filterVehicleType = filterVehicleType;
130  }
131 
132  _node.getParam("atmosphericAltitudeEnabled", _initOptions.atmosphericAltitudeEnabled);
133  _node.getParam("velocityHeadingEnabled", _initOptions.velocityHeadingEnabled);
134  _node.getParam("reversingDetectionEnabled", _initOptions.reversingDetectionEnabled);
135  _node.getParam("motionAnalysisEnabled", _initOptions.motionAnalysisEnabled);
136  _node.getParam("odomPulseToMeters", _initOptions.odomPulseToMeters);
137  _node.getParam("trackWidth", _initOptions.trackWidth);
138  _node.getParam("odometerVelocityCovariance", _initOptions.odometerVelocityCovariance);
139  _node.getParam("encoderOnLeft", _initOptions.encoderOnLeft);
140 
141  ROS_INFO_STREAM("Port: " << _initOptions.port);
142  ROS_INFO_STREAM("Baud: " << _initOptions.baudRate);
143  ROS_INFO_STREAM("Debug: " << _initOptions.debugOn);
144  ROS_INFO_STREAM("Filter Vehicle Type: " << (int)_initOptions.filterVehicleType);
145  ROS_INFO_STREAM("Atmospheric Altitude Enabled: " << _initOptions.atmosphericAltitudeEnabled);
146  ROS_INFO_STREAM("Velocity Heading Enabled: " << _initOptions.velocityHeadingEnabled);
147  ROS_INFO_STREAM("Reversing Detection Enabled: " << _initOptions.reversingDetectionEnabled);
148  ROS_INFO_STREAM("Motion Analysis Enabled: " << _initOptions.motionAnalysisEnabled);
149  ROS_INFO_STREAM("Odometer Pulses to Meters: " << _initOptions.odomPulseToMeters);
150  ROS_INFO_STREAM("Vehicle track width: " << _initOptions.trackWidth);
151  ROS_INFO_STREAM("Odometer velocity covariance: " << _initOptions.odometerVelocityCovariance);
152  ROS_INFO_STREAM("Encoder on left: " << _initOptions.encoderOnLeft);
153 
154  return 0;
155 }
156 
157 int main(int argc, char **argv)
158 {
159  ros::init(argc, argv, "kvh_geo_fog_3d_driver");
160 
161  ros::NodeHandle node("~");
162  ros::Rate rate(50); // 50hz by default, may eventually make settable parameter
163 
164  diagnostic_updater::Updater diagnostics;
165  mitre::KVH::DiagnosticsContainer diagContainer;
166  SetupUpdater(&diagnostics, &diagContainer);
167 
168  // Custom msg publishers
169  std::map<packet_id_e, ros::Publisher> kvhPubMap{
170  {packet_id_system_state, node.advertise<kvh_geo_fog_3d_msgs::KvhGeoFog3DSystemState>("kvh_system_state", 1)},
171  {packet_id_satellites, node.advertise<kvh_geo_fog_3d_msgs::KvhGeoFog3DSatellites>("kvh_satellites", 1)},
172  {packet_id_satellites_detailed, node.advertise<kvh_geo_fog_3d_msgs::KvhGeoFog3DDetailSatellites>("kvh_detailed_satellites", 1)},
173  {packet_id_local_magnetics, node.advertise<kvh_geo_fog_3d_msgs::KvhGeoFog3DLocalMagneticField>("kvh_local_magnetics", 1)},
174  {packet_id_utm_position, node.advertise<kvh_geo_fog_3d_msgs::KvhGeoFog3DUTMPosition>("kvh_utm_position", 1)},
175  {packet_id_ecef_position, node.advertise<kvh_geo_fog_3d_msgs::KvhGeoFog3DECEFPos>("kvh_ecef_pos", 1)},
176  {packet_id_north_seeking_status, node.advertise<kvh_geo_fog_3d_msgs::KvhGeoFog3DNorthSeekingInitStatus>("kvh_north_seeking_status", 1)},
177  {packet_id_odometer_state, node.advertise<kvh_geo_fog_3d_msgs::KvhGeoFog3DOdometerState>("kvh_odometer_state", 1)},
178  {packet_id_raw_sensors, node.advertise<kvh_geo_fog_3d_msgs::KvhGeoFog3DRawSensors>("kvh_raw_sensors", 1)},
179  {packet_id_raw_gnss, node.advertise<kvh_geo_fog_3d_msgs::KvhGeoFog3DRawGNSS>("kvh_raw_gnss", 1)}};
180 
181  // Publishers for standard ros messages
182  ros::Publisher imuRawPub = node.advertise<sensor_msgs::Imu>("imu/data_raw_frd", 1);
183  ros::Publisher imuRawFLUPub = node.advertise<sensor_msgs::Imu>("imu/data_raw_flu", 1);
184  ros::Publisher imuNEDPub = node.advertise<sensor_msgs::Imu>("imu/data_ned", 1);
185  ros::Publisher imuENUPub = node.advertise<sensor_msgs::Imu>("imu/data_enu", 1);
186  ros::Publisher imuRpyNEDPub = node.advertise<geometry_msgs::Vector3Stamped>("imu/rpy_ned", 1);
187  ros::Publisher imuRpyNEDDegPub = node.advertise<geometry_msgs::Vector3Stamped>("imu/rpy_ned_deg", 1);
188  ros::Publisher imuRpyENUPub = node.advertise<geometry_msgs::Vector3Stamped>("imu/rpy_enu", 1);
189  ros::Publisher imuRpyENUDegPub = node.advertise<geometry_msgs::Vector3Stamped>("imu/rpy_enu_deg", 1);
190  ros::Publisher navSatFixPub = node.advertise<sensor_msgs::NavSatFix>("gps/fix", 1);
191  ros::Publisher rawNavSatFixPub = node.advertise<sensor_msgs::NavSatFix>("gps/raw_fix", 1);
192  ros::Publisher magFieldPub = node.advertise<sensor_msgs::MagneticField>("mag", 1);
193  ros::Publisher odomPubNED = node.advertise<nav_msgs::Odometry>("gps/utm_ned", 1);
194  ros::Publisher odomPubENU = node.advertise<nav_msgs::Odometry>("gps/utm_enu", 1);
195  ros::Publisher odomStatePub = node.advertise<nav_msgs::Odometry>("odom/wheel_encoder", 1);
196  ros::Publisher odomSpeedPub = node.advertise<geometry_msgs::TwistWithCovarianceStamped>("odom/encoder_vehicle_velocity", 1);
197  ros::Publisher rawSensorImuPub = node.advertise<sensor_msgs::Imu>("imu/raw_sensor_frd", 1);
198  ros::Publisher rawSensorImuFluPub = node.advertise<sensor_msgs::Imu>("imu/raw_sensor_flu", 1);
199  ros::Publisher velNEDTwistPub = node.advertise<geometry_msgs::TwistWithCovarianceStamped>("gps/vel_ned", 1);
200  ros::Publisher velENUTwistPub = node.advertise<geometry_msgs::TwistWithCovarianceStamped>("gps/vel_enu", 1);
201  ros::Publisher velBodyTwistFLUPub = node.advertise<geometry_msgs::TwistWithCovarianceStamped>("imu/vel_flu", 1);
202  ros::Publisher velBodyTwistFRDPub = node.advertise<geometry_msgs::TwistWithCovarianceStamped>("imu/vel_frd", 1);
203 
205  // KVH Setup
207 
208  // To get packets from the driver, we first create a vector
209  // that holds a pair containing the packet id and the desired frequency for it to be published
210  // See documentation for all id's.
211  typedef std::pair<packet_id_e, int> freqPair;
212 
213  kvh::KvhPacketRequest packetRequest{
215  freqPair(packet_id_system_state, 50),
216  freqPair(packet_id_satellites, 10),
217  freqPair(packet_id_satellites_detailed, 1),
218  freqPair(packet_id_local_magnetics, 50),
219  freqPair(packet_id_utm_position, 50),
220  freqPair(packet_id_ecef_position, 50),
221  freqPair(packet_id_north_seeking_status, 50),
222  freqPair(packet_id_odometer_state, 50),
223  freqPair(packet_id_raw_sensors, 50),
224  freqPair(packet_id_raw_gnss, 50),
225  freqPair(packet_id_body_velocity, 50),
227  };
228 
229  kvh::Driver kvhDriver;
230  kvh::KvhInitOptions initOptions;
231 
232  if (GetInitOptions(node, initOptions) < 0)
233  {
234  ROS_ERROR("Unable to get init options. Exiting.");
235  exit(1);
236  }
237 
238  int errorCode;
239  if ((errorCode = kvhDriver.Init(initOptions.port, packetRequest, initOptions)) < 0)
240  {
241  ROS_ERROR("Unable to initialize driver. Error Code %d", errorCode);
242  exit(1);
243  };
244 
245  // Request odom configuration packet to get the pulse length
246  // \todo Refactor! We have to do the below due to some poor design decisions
247  // on my part. The odometer configuration packet cannot be added to the
248  // packet request above since adding it to there will cause it to be added
249  // to the packet periods packet, which in turn throws an error.
252 
253  // Declare these for reuse
254  system_state_packet_t systemStatePacket;
255  satellites_packet_t satellitesPacket;
256  detailed_satellites_packet_t detailSatellitesPacket;
257  local_magnetics_packet_t localMagPacket;
258  kvh::utm_fix utmPosPacket;
259  ecef_position_packet_t ecefPosPacket;
260  north_seeking_status_packet_t northSeekingStatPacket;
262  odometer_state_packet_t odomStatePacket;
263  raw_sensors_packet_t rawSensorsPacket;
264  raw_gnss_packet_t rawGnssPacket;
265  body_velocity_packet_t bodyVelocityPacket;
266  velocity_standard_deviation_packet_t velocityStdDevPack;
267  odometer_configuration_packet_t odomConfigPacket;
268 
269  // Default value for pulse to meters in case it is not updated from kvh
270  double odomPulseToMeters = initOptions.odomPulseToMeters;
271 
272  while (ros::ok())
273  {
274  // Collect packet data
275  kvhDriver.Once();
276 
277  // If packets were updated, record the data, we will use the same instance
278  // of the packets for the remainder of this loop
279 
281  {
282  ROS_DEBUG_THROTTLE(1, "System state packet has been updated.");
283  kvhDriver.GetPacket(packet_id_system_state, systemStatePacket);
284  }
285 
286  if (kvhDriver.PacketIsUpdated(packet_id_satellites))
287  {
288  ROS_DEBUG_THROTTLE(1, "Satellites packet has been updated.");
289  kvhDriver.GetPacket(packet_id_satellites, satellitesPacket);
290  }
291 
293  {
294  ROS_DEBUG_THROTTLE(1, "Detailed satellites packet has been updated.");
295  kvhDriver.GetPacket(packet_id_satellites_detailed, detailSatellitesPacket);
296  }
297 
299  {
300  ROS_DEBUG_THROTTLE(1, "Local Mag packet has been updated.");
301  kvhDriver.GetPacket(packet_id_local_magnetics, localMagPacket);
302  }
303 
305  {
306  ROS_DEBUG_THROTTLE(1, "Utm position packet has been updated.");
307  kvhDriver.GetPacket(packet_id_utm_position, utmPosPacket);
308  }
309 
311  {
312  ROS_DEBUG_THROTTLE(1, "Ecef packet has been updated.");
313  kvhDriver.GetPacket(packet_id_ecef_position, ecefPosPacket);
314  }
316  {
317  ROS_DEBUG_THROTTLE(1, "North Seeking Status packet has been updated.");
318  kvhDriver.GetPacket(packet_id_north_seeking_status, northSeekingStatPacket);
319  }
320 
322  {
323  ROS_DEBUG_THROTTLE(1, "Euler Std Dev packet has been updated.");
325  }
326 
328  {
329  ROS_DEBUG_THROTTLE(1, "Odom State packet has been updated.");
330  kvhDriver.GetPacket(packet_id_odometer_state, odomStatePacket);
331  }
332 
333  if (kvhDriver.PacketIsUpdated(packet_id_raw_sensors))
334  {
335  ROS_DEBUG_THROTTLE(1, "Raw Sensors packet has been updated.");
336  kvhDriver.GetPacket(packet_id_raw_sensors, rawSensorsPacket);
337  }
338 
339  if (kvhDriver.PacketIsUpdated(packet_id_raw_gnss))
340  {
341  ROS_DEBUG_THROTTLE(1, "Raw Gnss packet has been updated.");
342  kvhDriver.GetPacket(packet_id_raw_gnss, rawGnssPacket);
343  }
344 
346  {
347  ROS_DEBUG_THROTTLE(1, "Body Velocity packet has been updated.");
348  kvhDriver.GetPacket(packet_id_body_velocity, bodyVelocityPacket);
349  }
350 
352  {
353  ROS_DEBUG_THROTTLE(1, "Odometer configuration packet has been updated.");
354  kvhDriver.GetPacket(packet_id_odometer_configuration, odomConfigPacket);
355  }
356 
358  // OUTPUT ROS MESSAGES AND DIAGNOSTICS
360 
361  // SYSTEM STATE PACKET
363  {
364  // Messages that are dependent ONLY on the system state packet
365  PublishSystemState(kvhPubMap[packet_id_system_state], systemStatePacket);
366  PublishIMURaw(imuRawPub, systemStatePacket);
367  PublishIMURawFLU(imuRawFLUPub, systemStatePacket);
368  PublishIMU_RPY_NED(imuRpyNEDPub, systemStatePacket);
369  PublishIMU_RPY_NED_DEG(imuRpyNEDDegPub, systemStatePacket);
370  PublishIMU_RPY_ENU(imuRpyENUPub, systemStatePacket);
371  PublishIMU_RPY_ENU_DEG(imuRpyENUDegPub, systemStatePacket);
372  PublishNavSatFix(navSatFixPub, systemStatePacket);
373 
374  //Update diagnostics container from this message
375  diagContainer.SetSystemStatus(systemStatePacket.system_status.r);
376  diagContainer.SetFilterStatus(systemStatePacket.filter_status.r);
377 
378  // Messages dependent on system state AND euler std dev
380  {
381 
382  // CAREFUL!!! Sometimes this packet will return NANs for some reason
383  if (std::isnan(eulStdDevPack.standard_deviation[0]))
384  {
385  eulStdDevPack.standard_deviation[0] = 0;
386  ROS_INFO("NAN Found");
387  }
388 
389  if (std::isnan(eulStdDevPack.standard_deviation[1]))
390  {
391  eulStdDevPack.standard_deviation[1] = 0;
392  ROS_INFO("NAN Found");
393  }
394 
395  if (std::isnan(eulStdDevPack.standard_deviation[2]))
396  {
397  eulStdDevPack.standard_deviation[2] = 0;
398  ROS_INFO("NAN Found");
399  }
400 
401  PublishIMU_NED(imuNEDPub, systemStatePacket, eulStdDevPack);
402  PublishIMU_ENU(imuENUPub, systemStatePacket, eulStdDevPack);
403 
404  // System state, eul std dev, utm, and body velocity
405  if (kvhDriver.PacketIsUpdated(packet_id_utm_position) &&
407  {
408  PublishOdomNED(odomPubNED, systemStatePacket, utmPosPacket, eulStdDevPack, bodyVelocityPacket);
409  PublishOdomENU(odomPubENU, systemStatePacket, utmPosPacket, eulStdDevPack, bodyVelocityPacket);
410  }
411  }
412 
413  // System State AND Raw Gnss
414  if (kvhDriver.PacketIsUpdated(packet_id_raw_gnss))
415  {
416  PublishRawNavSatFix(rawNavSatFixPub, systemStatePacket, rawGnssPacket);
417  }
418 
419  // System State AND Odometer State
421  {
422  PublishOdomSpeed(odomSpeedPub, systemStatePacket, odomStatePacket, initOptions.trackWidth,
423  initOptions.odometerVelocityCovariance, initOptions.encoderOnLeft);
424  }
425 
426  // System State and Velocity Std Dev
428  {
429  PublishVelNEDTwist(velNEDTwistPub, systemStatePacket, velocityStdDevPack);
430  PublishVelENUTwist(velENUTwistPub, systemStatePacket, velocityStdDevPack);
431  }
432 
433  // System state, body velocity AND Velocity Std Dev
434  if (kvhDriver.PacketIsUpdated(packet_id_body_velocity) &&
436  {
437  PublishVelBodyTwistFLU(velBodyTwistFLUPub, systemStatePacket, bodyVelocityPacket, velocityStdDevPack);
438  PublishVelBodyTwistFRD(velBodyTwistFRDPub, systemStatePacket, bodyVelocityPacket, velocityStdDevPack);
439  }
440  }
441 
442  // SATELLITES PACKET
443  if (kvhDriver.PacketIsUpdated(packet_id_satellites))
444  {
445  ROS_DEBUG_THROTTLE(3, "Satellites packet updated. Publishing...");
446  kvhDriver.GetPacket(packet_id_satellites, satellitesPacket);
447 
448  PublishSatellites(kvhPubMap[packet_id_satellites], satellitesPacket);
449  }
450 
451  // SATELLITES DETAILED
453  {
454  ROS_DEBUG_THROTTLE(3, "Detailed satellites packet updated. Publishing...");
455  kvhDriver.GetPacket(packet_id_satellites_detailed, detailSatellitesPacket);
456 
457  PublishSatellitesDetailed(kvhPubMap[packet_id_satellites_detailed], detailSatellitesPacket);
458  }
459 
460  // LOCAL MAGNETICS PACKET
462  {
463  ROS_DEBUG_THROTTLE(3, "Local magnetics packet updated. Publishing...");
464  kvhDriver.GetPacket(packet_id_local_magnetics, localMagPacket);
465 
466  PublishLocalMagnetics(kvhPubMap[packet_id_local_magnetics], localMagPacket);
467  }
468 
469  // UTM POSITION PACKET
471  {
472  ROS_DEBUG_THROTTLE(3, "UTM Position packet updated. Publishing...");
473  kvhDriver.GetPacket(packet_id_utm_position, utmPosPacket);
474 
475  PublishUtmPosition(kvhPubMap[packet_id_utm_position], utmPosPacket);
476  }
477 
478  // ECEF POSITION PACKET
480  {
481  ROS_DEBUG_THROTTLE(3, "ECEF position packet updated. Publishing...");
482  kvhDriver.GetPacket(packet_id_ecef_position, ecefPosPacket);
483 
484  PublishEcefPosition(kvhPubMap[packet_id_ecef_position], ecefPosPacket);
485  }
486 
487  // NORTH SEEKING STATUS PACKET
489  {
490  ROS_DEBUG_THROTTLE(3, "North seeking status packet updated. Publishing...");
491  kvhDriver.GetPacket(packet_id_north_seeking_status, northSeekingStatPacket);
492 
493  PublishNorthSeekingStatus(kvhPubMap[packet_id_north_seeking_status], northSeekingStatPacket);
494  }
495 
497  {
498  ROS_DEBUG_THROTTLE(3, "Odometer state updated. Publishing...");
499  kvhDriver.GetPacket(packet_id_odometer_state, odomStatePacket);
500 
501  PublishKvhOdometerState(kvhPubMap[packet_id_odometer_state], odomStatePacket);
502  PublishOdomState(odomStatePub, odomStatePacket, odomPulseToMeters);
503  }
504 
505  if (kvhDriver.PacketIsUpdated(packet_id_raw_sensors))
506  {
507  ROS_DEBUG_THROTTLE(3, "Raw sensors packet updated. Publishing...");
508  kvhDriver.GetPacket(packet_id_raw_sensors, rawSensorsPacket);
509 
510  PublishRawSensors(kvhPubMap[packet_id_raw_sensors], rawSensorsPacket);
511  PublishMagField(magFieldPub, rawSensorsPacket);
512  PublishIMUSensorRaw(rawSensorImuPub, rawSensorsPacket);
513  PublishIMUSensorRawFLU(rawSensorImuFluPub, rawSensorsPacket);
514  }
515 
522  if (kvhDriver.PacketIsUpdated(packet_id_raw_gnss))
523  {
524  ROS_DEBUG_THROTTLE(3, "Raw GNSS packet updated. Publishing...");
525  kvhDriver.GetPacket(packet_id_raw_gnss, rawGnssPacket);
526 
527  PublishRawGnss(kvhPubMap[packet_id_raw_gnss], rawGnssPacket);
528  }
529 
530  // Get the kvh setting for pulse length to use below in the distance travelled calculation
532  {
533  ROS_DEBUG_THROTTLE(3, "Obtaining pulse length from odometer config.");
534  kvhDriver.GetPacket(packet_id_odometer_configuration, odomConfigPacket);
535  // Assume if it is not 0 then it has been calibrated
536  if (odomConfigPacket.pulse_length != 0)
537  {
538  odomPulseToMeters = odomConfigPacket.pulse_length;
539  }
540  }
541 
542  // Set that we have read the latest versions of all packets. There is a small possibility we miss one packet
543  // between using it above and setting it here.
544  kvhDriver.SetPacketUpdated(packet_id_system_state, false);
545  kvhDriver.SetPacketUpdated(packet_id_satellites, false);
547  kvhDriver.SetPacketUpdated(packet_id_utm_position, false);
548  kvhDriver.SetPacketUpdated(packet_id_ecef_position, false);
552  kvhDriver.SetPacketUpdated(packet_id_odometer_state, false);
553  kvhDriver.SetPacketUpdated(packet_id_raw_gnss, false);
554  kvhDriver.SetPacketUpdated(packet_id_raw_sensors, false);
555  kvhDriver.SetPacketUpdated(packet_id_body_velocity, false);
558 
559  diagnostics.update();
560 
561  ros::spinOnce();
562  rate.sleep();
563  ROS_DEBUG_THROTTLE(3, "----------------------------------------");
564  }
565 
566  diagnostics.broadcast(diagnostic_msgs::DiagnosticStatus::WARN, "Shutting down the KVH driver");
567  kvhDriver.Cleanup();
568 }
system_state_packet_t::r
uint16_t r
Definition: spatial_packets.h:250
system_state_packet_t::system_status
union system_state_packet_t::@0 system_status
PublishUtmPosition
void PublishUtmPosition(ros::Publisher &, utm_position_packet_t)
Definition: packet_publisher.cpp:144
system_state_packet_t::filter_status
union system_state_packet_t::@1 filter_status
PublishRawSensors
void PublishRawSensors(ros::Publisher &, raw_sensors_packet_t)
Definition: packet_publisher.cpp:201
velocity_standard_deviation_packet_t
Definition: spatial_packets.h:377
kvh::KvhInitOptions::debugOn
bool debugOn
Definition: kvh_geo_fog_3d_driver.hpp:63
ros::Publisher
kvh::KvhInitOptions::reversingDetectionEnabled
bool reversingDetectionEnabled
Definition: kvh_geo_fog_3d_driver.hpp:67
PublishIMUSensorRawFLU
void PublishIMUSensorRawFLU(ros::Publisher &, raw_sensors_packet_t)
Definition: packet_publisher.cpp:756
euler_orientation_standard_deviation_packet_t::standard_deviation
float standard_deviation[3]
Definition: spatial_packets.h:384
kvh::Driver::RequestPacket
int RequestPacket(packet_id_e)
This function is used to request packets that you only want once or that cannot be requested through ...
Definition: driver_main.cpp:376
satellites_packet_t
Definition: spatial_packets.h:428
north_seeking_status_packet_t
Definition: spatial_packets.h:744
PublishOdomSpeed
void PublishOdomSpeed(ros::Publisher &, system_state_packet_t, odometer_state_packet_t, double, double, bool)
Definition: packet_publisher.cpp:702
PublishNavSatFix
void PublishNavSatFix(ros::Publisher &, system_state_packet_t)
Definition: packet_publisher.cpp:483
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
mitre::KVH::DiagnosticsContainer::UpdateFilterStatus
void UpdateFilterStatus(diagnostic_updater::DiagnosticStatusWrapper &stat)
Definition: kvh_diagnostics_container.cpp:201
ros::NodeHandle::getParam
bool getParam(const std::string &key, bool &b) const
ros.h
PublishIMU_RPY_ENU
void PublishIMU_RPY_ENU(ros::Publisher &, system_state_packet_t)
Definition: packet_publisher.cpp:442
packet_id_satellites_detailed
@ packet_id_satellites_detailed
Definition: spatial_packets.h:71
kvh::KvhPacketRequest
std::vector< std::pair< packet_id_e, uint16_t > > KvhPacketRequest
Definition: kvh_geo_fog_3d_packet_storage.hpp:65
detailed_satellites_packet_t
Definition: spatial_packets.h:476
kvh::KvhInitOptions
Definition: kvh_geo_fog_3d_driver.hpp:58
mitre::KVH::DiagnosticsContainer
Definition: kvh_diagnostics_container.hpp:39
kvh::KvhInitOptions::atmosphericAltitudeEnabled
bool atmosphericAltitudeEnabled
Definition: kvh_geo_fog_3d_driver.hpp:65
ros::spinOnce
ROSCPP_DECL void spinOnce()
PublishVelENUTwist
void PublishVelENUTwist(ros::Publisher &, system_state_packet_t, velocity_standard_deviation_packet_t)
Definition: packet_publisher.cpp:791
diagnostic_updater::Updater
PublishMagField
void PublishMagField(ros::Publisher &, raw_sensors_packet_t)
Definition: packet_publisher.cpp:562
PublishEcefPosition
void PublishEcefPosition(ros::Publisher &, ecef_position_packet_t)
Definition: packet_publisher.cpp:156
mitre::KVH::DiagnosticsContainer::SetFilterStatus
void SetFilterStatus(uint16_t _status)
Definition: kvh_diagnostics_container.hpp:49
mitre::KVH::DiagnosticsContainer::SetSystemStatus
void SetSystemStatus(uint16_t _status)
Definition: kvh_diagnostics_container.hpp:48
PublishSatellites
void PublishSatellites(ros::Publisher &, satellites_packet_t)
Definition: packet_publisher.cpp:88
raw_gnss_packet_t
Definition: spatial_packets.h:402
kvh::KvhInitOptions::port
std::string port
Definition: kvh_geo_fog_3d_driver.hpp:62
PublishRawGnss
void PublishRawGnss(ros::Publisher &, raw_gnss_packet_t)
Definition: packet_publisher.cpp:226
diagnostic_updater::Updater::broadcast
void broadcast(int lvl, const std::string msg)
ros::NodeHandle::advertise
Publisher advertise(AdvertiseOptions &ops)
ros::ok
ROSCPP_DECL bool ok()
packet_id_north_seeking_status
@ packet_id_north_seeking_status
Definition: spatial_packets.h:111
SetupUpdater
void SetupUpdater(diagnostic_updater::Updater *_diagnostics, mitre::KVH::DiagnosticsContainer *_diagContainer)
Definition: kvh_geo_fog_3d_node.cpp:107
transform_broadcaster.h
kvh::KvhInitOptions::velocityHeadingEnabled
bool velocityHeadingEnabled
Definition: kvh_geo_fog_3d_driver.hpp:66
diagnostic_updater.h
PublishSystemState
void PublishSystemState(ros::Publisher &, system_state_packet_t)
Definition: packet_publisher.cpp:48
kvh::KvhInitOptions::odomPulseToMeters
double odomPulseToMeters
Definition: kvh_geo_fog_3d_driver.hpp:69
kvh_diagnostics_container.hpp
Contains diagnostic information published out the ROS diagnostics topic.
kvh::Driver
Driver worker class for the KVH Geo Fog 3D.
Definition: kvh_geo_fog_3d_driver.hpp:83
mitre::KVH::DiagnosticsContainer::UpdateSystemStatus
void UpdateSystemStatus(diagnostic_updater::DiagnosticStatusWrapper &stat)
Definition: kvh_diagnostics_container.cpp:38
PublishRawNavSatFix
void PublishRawNavSatFix(ros::Publisher &, system_state_packet_t, raw_gnss_packet_t)
Definition: packet_publisher.cpp:522
kvh_geo_fog_3d_global_vars.hpp
global variables used to store packet information.
odometer_state_packet_t
Definition: spatial_packets.h:586
PublishOdomNED
void PublishOdomNED(ros::Publisher &, system_state_packet_t, utm_position_packet_t, euler_orientation_standard_deviation_packet_t, body_velocity_packet_t)
Definition: packet_publisher.cpp:575
body_velocity_packet_t
Definition: spatial_packets.h:502
euler_orientation_standard_deviation_packet_t
Definition: spatial_packets.h:382
packet_id_utm_position
@ packet_id_utm_position
Definition: spatial_packets.h:74
kvh::KvhInitOptions::trackWidth
double trackWidth
Definition: kvh_geo_fog_3d_driver.hpp:70
packet_publisher.hpp
odometer_configuration_packet_t::pulse_length
float pulse_length
Definition: spatial_packets.h:893
packet_id_euler_orientation_standard_deviation
@ packet_id_euler_orientation_standard_deviation
Definition: spatial_packets.h:66
packet_id_satellites
@ packet_id_satellites
Definition: spatial_packets.h:70
kvh::utm_fix
Definition: kvh_geo_fog_3d_global_vars.hpp:51
Quaternion.h
packet_id_odometer_state
@ packet_id_odometer_state
Definition: spatial_packets.h:91
kvh::Driver::AddPacket
int AddPacket(packet_id_e)
Definition: driver_main.cpp:358
PublishIMU_RPY_NED_DEG
void PublishIMU_RPY_NED_DEG(ros::Publisher &, system_state_packet_t)
Definition: packet_publisher.cpp:424
packet_id_raw_gnss
@ packet_id_raw_gnss
Definition: spatial_packets.h:69
packet_id_ecef_position
@ packet_id_ecef_position
Definition: spatial_packets.h:73
ecef_position_packet_t
Definition: spatial_packets.h:486
packet_id_system_state
@ packet_id_system_state
Definition: spatial_packets.h:60
ROS_INFO_STREAM
#define ROS_INFO_STREAM(args)
PublishIMURawFLU
void PublishIMURawFLU(ros::Publisher &, system_state_packet_t)
Definition: packet_publisher.cpp:292
kvh::KvhInitOptions::odometerVelocityCovariance
double odometerVelocityCovariance
Definition: kvh_geo_fog_3d_driver.hpp:71
diagnostic_updater::Updater::setHardwareID
void setHardwareID(const std::string &hwid)
local_magnetics_packet_t
Definition: spatial_packets.h:581
ros::Rate::sleep
bool sleep()
kvh::KvhInitOptions::filterVehicleType
uint8_t filterVehicleType
Definition: kvh_geo_fog_3d_driver.hpp:64
packet_id_local_magnetics
@ packet_id_local_magnetics
Definition: spatial_packets.h:90
PublishIMU_ENU
void PublishIMU_ENU(ros::Publisher &, system_state_packet_t, euler_orientation_standard_deviation_packet_t)
Definition: packet_publisher.cpp:366
diagnostic_updater::Updater::update
void update()
kvh::Driver::PacketIsUpdated
bool PacketIsUpdated(packet_id_e)
Use this function to determine if new packet data has arrived since the last time you checked.
Definition: driver_main.cpp:334
packet_id_odometer_configuration
@ packet_id_odometer_configuration
Definition: spatial_packets.h:126
kvh::KvhInitOptions::baudRate
int baudRate
Definition: kvh_geo_fog_3d_driver.hpp:61
kvh::KvhInitOptions::encoderOnLeft
bool encoderOnLeft
Definition: kvh_geo_fog_3d_driver.hpp:72
GetInitOptions
int GetInitOptions(ros::NodeHandle &_node, kvh::KvhInitOptions &_initOptions)
Definition: kvh_geo_fog_3d_node.cpp:117
PublishIMU_NED
void PublishIMU_NED(ros::Publisher &, system_state_packet_t, euler_orientation_standard_deviation_packet_t)
Definition: packet_publisher.cpp:324
PublishIMU_RPY_NED
void PublishIMU_RPY_NED(ros::Publisher &, system_state_packet_t)
Definition: packet_publisher.cpp:407
ROS_ERROR
#define ROS_ERROR(...)
PublishKvhOdometerState
void PublishKvhOdometerState(ros::Publisher &, odometer_state_packet_t)
Definition: packet_publisher.cpp:188
odometer_configuration_packet_t
Definition: spatial_packets.h:889
PublishSatellitesDetailed
void PublishSatellitesDetailed(ros::Publisher &, detailed_satellites_packet_t)
Definition: packet_publisher.cpp:102
kvh::Driver::GetPacket
int GetPacket(packet_id_e _packetId, T &_packet)
Retrieves the requested packets that are currently stored. Use PacketIsUpdated and SetPacketUpdated t...
Definition: kvh_geo_fog_3d_driver.hpp:190
packet_id_body_velocity
@ packet_id_body_velocity
Definition: spatial_packets.h:76
PublishVelBodyTwistFLU
void PublishVelBodyTwistFLU(ros::Publisher &, system_state_packet_t, body_velocity_packet_t, velocity_standard_deviation_packet_t)
Definition: packet_publisher.cpp:807
PublishIMU_RPY_ENU_DEG
void PublishIMU_RPY_ENU_DEG(ros::Publisher &, system_state_packet_t)
Definition: packet_publisher.cpp:462
PublishNorthSeekingStatus
void PublishNorthSeekingStatus(ros::Publisher &, north_seeking_status_packet_t)
Definition: packet_publisher.cpp:167
ros::Rate
kvh::Driver::Once
int Once()
Do a single data read from the device.
Definition: driver_main.cpp:276
PublishLocalMagnetics
void PublishLocalMagnetics(ros::Publisher &, local_magnetics_packet_t)
Definition: packet_publisher.cpp:133
kvh_geo_fog_3d_driver.hpp
KVH Geo Fog 3D driver class header.
kvh::Driver::Cleanup
int Cleanup()
Cleanup and close our connections.
Definition: driver_main.cpp:394
ROS_INFO
#define ROS_INFO(...)
diagnostic_updater::DiagnosticTaskVector::add
void add(const std::string &name, TaskFunction f)
PublishOdomENU
void PublishOdomENU(ros::Publisher &, system_state_packet_t, utm_position_packet_t, euler_orientation_standard_deviation_packet_t, body_velocity_packet_t)
Definition: packet_publisher.cpp:623
PublishVelNEDTwist
void PublishVelNEDTwist(ros::Publisher &, system_state_packet_t, velocity_standard_deviation_packet_t)
Definition: packet_publisher.cpp:775
packet_id_velocity_standard_deviation
@ packet_id_velocity_standard_deviation
Definition: spatial_packets.h:65
kvh::Driver::SetPacketUpdated
int SetPacketUpdated(packet_id_e, bool)
Use this function to set that the packet has been updated (though the driver will usually do that its...
Definition: driver_main.cpp:348
PublishVelBodyTwistFRD
void PublishVelBodyTwistFRD(ros::Publisher &, system_state_packet_t, body_velocity_packet_t, velocity_standard_deviation_packet_t)
Definition: packet_publisher.cpp:827
kvh::KvhInitOptions::motionAnalysisEnabled
bool motionAnalysisEnabled
Definition: kvh_geo_fog_3d_driver.hpp:68
PublishOdomState
void PublishOdomState(ros::Publisher &, odometer_state_packet_t, double)
Definition: packet_publisher.cpp:679
kvh::Driver::Init
int Init(const std::string &_port, KvhPacketRequest &_packetsRequested)
Definition: driver_main.cpp:115
system_state_packet_t
Definition: spatial_packets.h:246
PublishIMURaw
void PublishIMURaw(ros::Publisher &, system_state_packet_t)
Definition: packet_publisher.cpp:262
ROS_DEBUG_THROTTLE
#define ROS_DEBUG_THROTTLE(period,...)
ros::NodeHandle
spatial_packets.h
main
int main(int argc, char **argv)
Definition: kvh_geo_fog_3d_node.cpp:157
raw_sensors_packet_t
Definition: spatial_packets.h:392
packet_id_raw_sensors
@ packet_id_raw_sensors
Definition: spatial_packets.h:68
PublishIMUSensorRaw
void PublishIMUSensorRaw(ros::Publisher &, raw_sensors_packet_t)
Definition: packet_publisher.cpp:734


kvh_geo_fog_3d_driver
Author(s): Trevor Bostic , Zach LaCelle
autogenerated on Wed Mar 2 2022 00:28:57