sbg_device.cpp
Go to the documentation of this file.
1 // File header
2 #include "sbg_device.h"
3 
4 // Standard headers
5 #include <iomanip>
6 #include <fstream>
7 #include <ctime>
8 
9 // Boost headers
10 #include <boost/lexical_cast.hpp>
11 #include <boost/regex.hpp>
12 #include <boost/thread/xtime.hpp>
13 #include <boost/date_time/local_time/local_time.hpp>
14 
15 // SbgECom headers
16 #include <version/sbgVersion.h>
17 
18 using namespace std;
19 using sbg::SbgDevice;
20 
21 // From ros_com/recorder
22 std::string timeToStr(ros::WallTime ros_t)
23 {
24  (void)ros_t;
25  std::stringstream msg;
26  const boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
27  boost::posix_time::time_facet *const f = new boost::posix_time::time_facet("%Y-%m-%d-%H-%M-%S");
28  msg.imbue(std::locale(msg.getloc(),f));
29  msg << now;
30 
31  return msg.str();
32 }
33 
34 //
35 // Static magnetometers maps definition.
36 //
37 std::map<SbgEComMagCalibQuality, std::string> SbgDevice::g_mag_calib_quality_ = { {SBG_ECOM_MAG_CALIB_QUAL_OPTIMAL, "Quality: optimal"},
38  {SBG_ECOM_MAG_CALIB_QUAL_GOOD, "Quality: good"},
39  {SBG_ECOM_MAG_CALIB_QUAL_POOR, "Quality: poor"},
40  {SBG_ECOM_MAG_CALIB_QUAL_INVALID, "Quality: invalid"}};
41 
42 std::map<SbgEComMagCalibConfidence, std::string> SbgDevice::g_mag_calib_confidence_ = { {SBG_ECOM_MAG_CALIB_TRUST_HIGH, "Confidence: high"},
43  {SBG_ECOM_MAG_CALIB_TRUST_MEDIUM, "Confidence: medium"},
44  {SBG_ECOM_MAG_CALIB_TRUST_LOW, "Confidence: low"}};
45 
46 std::map<SbgEComMagCalibMode, std::string> SbgDevice::g_mag_calib_mode_ = { {SBG_ECOM_MAG_CALIB_MODE_2D, "Mode 2D"},
47  {SBG_ECOM_MAG_CALIB_MODE_3D, "Mode 3D"}};
48 
49 std::map<SbgEComMagCalibBandwidth, std::string> SbgDevice::g_mag_calib_bandwidth_ = {{SBG_ECOM_MAG_CALIB_HIGH_BW, "High Bandwidth"},
50  {SBG_ECOM_MAG_CALIB_MEDIUM_BW, "Medium Bandwidth"},
51  {SBG_ECOM_MAG_CALIB_LOW_BW, "Low Bandwidth"}};
52 
56 //---------------------------------------------------------------------//
57 //- Constructor -//
58 //---------------------------------------------------------------------//
59 
60 SbgDevice::SbgDevice(ros::NodeHandle& ref_node_handle):
61 ref_node_(ref_node_handle),
62 mag_calibration_ongoing_(false),
63 mag_calibration_done_(false)
64 {
66  connect();
67 }
68 
70 {
71  SbgErrorCode error_code;
72 
73  error_code = sbgEComClose(&com_handle_);
74 
75  if (error_code != SBG_NO_ERROR)
76  {
77  ROS_ERROR("Unable to close the SBG communication handle - %s.", sbgErrorCodeToString(error_code));
78  }
79 
81  {
83  }
84  else if (config_store_.isInterfaceUdp())
85  {
87  }
88 
89  if (error_code != SBG_NO_ERROR)
90  {
91  ROS_ERROR("SBG DRIVER - Unable to close the communication interface.");
92  }
93 }
94 
95 //---------------------------------------------------------------------//
96 //- Private methods -//
97 //---------------------------------------------------------------------//
98 
99 SbgErrorCode SbgDevice::onLogReceivedCallback(SbgEComHandle* p_handle, SbgEComClass msg_class, SbgEComMsgId msg, const SbgBinaryLogData* p_log_data, void* p_user_arg)
100 {
101  assert(p_user_arg);
102 
103  SBG_UNUSED_PARAMETER(p_handle);
104 
105  SbgDevice *p_sbg_device;
106  p_sbg_device = (SbgDevice*)(p_user_arg);
107 
108  p_sbg_device->onLogReceived(msg_class, msg, *p_log_data);
109 
110  return SBG_NO_ERROR;
111 }
112 
113 void SbgDevice::onLogReceived(SbgEComClass msg_class, SbgEComMsgId msg, const SbgBinaryLogData& ref_sbg_data)
114 {
115  //
116  // Publish the received SBG log.
117  //
118  message_publisher_.publish(msg_class, msg, ref_sbg_data);
119 }
120 
122 {
123  //
124  // Get the ROS private nodeHandle, where the parameters are loaded from the launch file.
125  //
126  ros::NodeHandle n_private("~");
128 }
129 
131 {
132  SbgErrorCode error_code;
133  error_code = SBG_NO_ERROR;
134 
135  //
136  // Initialize the communication interface from the config store, then initialize the sbgECom protocol to communicate with the device.
137  //
139  {
140  ROS_INFO("SBG_DRIVER - serial interface %s at %d bps", config_store_.getUartPortName().c_str(), config_store_.getBaudRate());
142  }
143  else if (config_store_.isInterfaceUdp())
144  {
145  char ip[16];
147  ROS_INFO("SBG_DRIVER - UDP interface %s %d->%d", ip, config_store_.getInputPortAddress(), config_store_.getOutputPortAddress());
149  }
150  else
151  {
152  throw ros::Exception("Invalid interface type for the SBG device.");
153  }
154 
155  if (error_code != SBG_NO_ERROR)
156  {
157  throw ros::Exception("SBG_DRIVER - [Init] Unable to initialize the interface - " + std::string(sbgErrorCodeToString(error_code)));
158  }
159 
160  error_code = sbgEComInit(&com_handle_, &sbg_interface_);
161 
162  if (error_code != SBG_NO_ERROR)
163  {
164  throw ros::Exception("SBG_DRIVER - [Init] Unable to initialize the SbgECom protocol - " + std::string(sbgErrorCodeToString(error_code)));
165  }
166 
167  readDeviceInfo();
168 }
169 
171 {
172  SbgEComDeviceInfo device_info;
173  SbgErrorCode error_code;
174 
175  error_code = sbgEComCmdGetInfo(&com_handle_, &device_info);
176 
177  if (error_code == SBG_NO_ERROR)
178  {
179  ROS_INFO("SBG_DRIVER - productCode = %s", device_info.productCode);
180  ROS_INFO("SBG_DRIVER - serialNumber = %u", device_info.serialNumber);
181 
182  ROS_INFO("SBG_DRIVER - calibationRev = %s", getVersionAsString(device_info.calibationRev).c_str());
183  ROS_INFO("SBG_DRIVER - calibrationDate = %u / %u / %u", device_info.calibrationDay, device_info.calibrationMonth, device_info.calibrationYear);
184 
185  ROS_INFO("SBG_DRIVER - hardwareRev = %s", getVersionAsString(device_info.hardwareRev).c_str());
186  ROS_INFO("SBG_DRIVER - firmwareRev = %s", getVersionAsString(device_info.firmwareRev).c_str());
187  }
188  else
189  {
190  ROS_ERROR("Unable to get the device Info : %s", sbgErrorCodeToString(error_code));
191  }
192 }
193 
194 std::string SbgDevice::getVersionAsString(uint32 sbg_version_enc) const
195 {
196  char version[32];
197  sbgVersionToStringEncoded(sbg_version_enc, version, 32);
198 
199  return std::string(version);
200 }
201 
203 {
205 
207 }
208 
210 {
212  {
213  auto rtcm_cb = [&](const rtcm_msgs::Message::ConstPtr& msg) -> void {
214  this->writeRtcmMessageToDevice(msg);
215  };
216 
217  rtcm_sub_ = ref_node_.subscribe<rtcm_msgs::Message>(config_store_.getRtcmFullTopic(), 10, rtcm_cb);
218  }
219 }
220 
222 {
224  {
225  ConfigApplier configApplier(com_handle_);
226  configApplier.applyConfiguration(config_store_);
227  }
228 }
229 
230 bool SbgDevice::processMagCalibration(std_srvs::Trigger::Request& ref_ros_request, std_srvs::Trigger::Response& ref_ros_response)
231 {
232  SBG_UNUSED_PARAMETER(ref_ros_request);
233 
235  {
236  if (endMagCalibration())
237  {
238  ref_ros_response.success = true;
239  ref_ros_response.message = "Magnetometer calibration is finished. See the output console to get calibration informations.";
240  }
241  else
242  {
243  ref_ros_response.success = false;
244  ref_ros_response.message = "Unable to end the calibration.";
245  }
246 
247  mag_calibration_ongoing_ = false;
248  mag_calibration_done_ = true;
249  }
250  else
251  {
252  if (startMagCalibration())
253  {
254  ref_ros_response.success = true;
255  ref_ros_response.message = "Magnetometer calibration process started.";
256  }
257  else
258  {
259  ref_ros_response.success = false;
260  ref_ros_response.message = "Unable to start magnetometers calibration.";
261  }
262 
264  }
265 
266  return ref_ros_response.success;
267 }
268 
269 bool SbgDevice::saveMagCalibration(std_srvs::Trigger::Request& ref_ros_request, std_srvs::Trigger::Response& ref_ros_response)
270 {
271  SBG_UNUSED_PARAMETER(ref_ros_request);
272 
274  {
275  ref_ros_response.success = false;
276  ref_ros_response.message = "Magnetometer calibration process is still ongoing, finish it before trying to save it.";
277  }
278  else if (mag_calibration_done_)
279  {
281  {
282  ref_ros_response.success = true;
283  ref_ros_response.message = "Magnetometer calibration has been uploaded to the device.";
284  }
285  else
286  {
287  ref_ros_response.success = false;
288  ref_ros_response.message = "Magnetometer calibration has not been uploaded to the device.";
289  }
290  }
291  else
292  {
293  ref_ros_response.success = false;
294  ref_ros_response.message = "No magnetometer calibration has been done.";
295  }
296 
297  return ref_ros_response.success;
298 }
299 
301 {
302  SbgErrorCode error_code;
303  SbgEComMagCalibMode mag_calib_mode;
304  SbgEComMagCalibBandwidth mag_calib_bandwidth;
305 
306  mag_calib_mode = config_store_.getMagnetometerCalibMode();
307  mag_calib_bandwidth = config_store_.getMagnetometerCalibBandwidth();
308 
309  error_code = sbgEComCmdMagStartCalib(&com_handle_, mag_calib_mode, mag_calib_bandwidth);
310 
311  if (error_code != SBG_NO_ERROR)
312  {
313  ROS_WARN("SBG DRIVER [Mag Calib] - Unable to start the magnetometer calibration : %s", sbgErrorCodeToString(error_code));
314  return false;
315  }
316  else
317  {
318  ROS_INFO("SBG DRIVER [Mag Calib] - Start calibration");
319  ROS_INFO("SBG DRIVER [Mag Calib] - Mode : %s", g_mag_calib_mode_[mag_calib_mode].c_str());
320  ROS_INFO("SBG DRIVER [Mag Calib] - Bandwidth : %s", g_mag_calib_bandwidth_[mag_calib_bandwidth].c_str());
321  return true;
322  }
323 }
324 
326 {
327  SbgErrorCode error_code;
328 
330 
331  if (error_code != SBG_NO_ERROR)
332  {
333  ROS_WARN("SBG DRIVER [Mag Calib] - Unable to compute the magnetometer calibration results : %s", sbgErrorCodeToString(error_code));
334  return false;
335  }
336  else
337  {
340 
341  return true;
342  }
343 }
344 
346 {
347  SbgErrorCode error_code;
348 
350  {
352 
353  if (error_code != SBG_NO_ERROR)
354  {
355  ROS_WARN("SBG DRIVER [Mag Calib] - Unable to set the magnetometers calibration data to the device : %s", sbgErrorCodeToString(error_code));
356  return false;
357  }
358  else
359  {
360  ROS_INFO("SBG DRIVER [Mag Calib] - Saving data to the device");
361  ConfigApplier configApplier(com_handle_);
362  configApplier.saveConfiguration();
363  return true;
364  }
365  }
366  else
367  {
368  ROS_ERROR("SBG DRIVER [Mag Calib] - The calibration was invalid, it can't be uploaded on the device.");
369  return false;
370  }
371 }
372 
374 {
375  ROS_INFO("SBG DRIVER [Mag Calib] - Quality of the calibration %s", g_mag_calib_quality_[mag_calib_results_.quality].c_str());
376  ROS_INFO("SBG DRIVER [Mag Calib] - Calibration results confidence %s", g_mag_calib_confidence_[mag_calib_results_.confidence].c_str());
377 
378  SbgEComMagCalibMode mag_calib_mode;
379 
380  mag_calib_mode = config_store_.getMagnetometerCalibMode();
381 
382  //
383  // Check the magnetometers calibration status and display the warnings.
384  //
386  {
387  ROS_WARN("SBG DRIVER [Mag Calib] - Not enough valid points. Maybe you are moving too fast");
388  }
390  {
391  ROS_WARN("SBG DRIVER [Mag Calib] - Unable to find a calibration solution. Maybe there are too much non static distortions");
392  }
394  {
395  ROS_WARN("SBG DRIVER [Mag Calib] - The magnetic calibration has troubles to correct the magnetometers and inertial frame alignment");
396  }
397  if (mag_calib_mode == SBG_ECOM_MAG_CALIB_MODE_2D)
398  {
400  {
401  ROS_WARN("SBG DRIVER [Mag Calib] - Too much roll motion for a 2D magnetic calibration");
402  }
404  {
405  ROS_WARN("SBG DRIVER [Mag Calib] - Too much pitch motion for a 2D magnetic calibration");
406  }
407  }
408  else
409  {
411  {
412  ROS_WARN("SBG DRIVER [Mag Calib] - Not enough roll motion for a 3D magnetic calibration");
413  }
415  {
416  ROS_WARN("SBG DRIVER [Mag Calib] - Not enough pitch motion for a 3D magnetic calibration.");
417  }
418  }
420  {
421  ROS_WARN("SBG DRIVER [Mag Calib] - Not enough yaw motion to compute a valid magnetic calibration");
422  }
423 }
424 
426 {
427  SbgEComMagCalibMode mag_calib_mode;
428  SbgEComMagCalibBandwidth mag_calib_bandwidth;
429  ostringstream mag_results_stream;
430  string output_filename;
431 
432  mag_calib_mode = config_store_.getMagnetometerCalibMode();
433  mag_calib_bandwidth = config_store_.getMagnetometerCalibBandwidth();
434 
435  mag_results_stream << "SBG DRIVER [Mag Calib]" << endl;
436  mag_results_stream << "======= Parameters =======" << endl;
437  mag_results_stream << "* CALIB_MODE = " << g_mag_calib_mode_[mag_calib_mode] << endl;
438  mag_results_stream << "* CALIB_BW = " << g_mag_calib_bandwidth_[mag_calib_bandwidth] << endl;
439 
440  mag_results_stream << "======= Results =======" << endl;
441  mag_results_stream << g_mag_calib_quality_[mag_calib_results_.quality] << endl;
442  mag_results_stream << g_mag_calib_confidence_[mag_calib_results_.confidence] << endl;
443  mag_results_stream << "======= Infos =======" << endl;
444  mag_results_stream << "* Used points : " << mag_calib_results_.numPoints << "/" << mag_calib_results_.maxNumPoints << endl;
445  mag_results_stream << "* Mean, Std, Max" << endl;
446  mag_results_stream << "[Before]\t" << mag_calib_results_.beforeMeanError << "\t" << mag_calib_results_.beforeStdError << "\t" << mag_calib_results_.beforeMaxError << endl;
447  mag_results_stream << "[After]\t" << mag_calib_results_.afterMeanError << "\t" << mag_calib_results_.afterStdError << "\t" << mag_calib_results_.afterMaxError << endl;
448  mag_results_stream << "[Accuracy]\t" << sbgRadToDegF(mag_calib_results_.meanAccuracy) << "\t" << sbgRadToDegF(mag_calib_results_.stdAccuracy) << "\t" << sbgRadToDegF(mag_calib_results_.maxAccuracy) << endl;
449  mag_results_stream << "* Offset\t" << mag_calib_results_.offset[0] << "\t" << mag_calib_results_.offset[1] << "\t" << mag_calib_results_.offset[2] << endl;
450 
451  mag_results_stream << "* Matrix" << endl;
452  mag_results_stream << mag_calib_results_.matrix[0] << "\t" << mag_calib_results_.matrix[1] << "\t" << mag_calib_results_.matrix[2] << endl;
453  mag_results_stream << mag_calib_results_.matrix[3] << "\t" << mag_calib_results_.matrix[4] << "\t" << mag_calib_results_.matrix[5] << endl;
454  mag_results_stream << mag_calib_results_.matrix[6] << "\t" << mag_calib_results_.matrix[7] << "\t" << mag_calib_results_.matrix[8] << endl;
455 
456  output_filename = "mag_calib_" + timeToStr(ros::WallTime::now()) + ".txt";
457  ofstream output_file(output_filename);
458  output_file << mag_results_stream.str();
459  output_file.close();
460 
461  ROS_INFO("%s", mag_results_stream.str().c_str());
462  ROS_INFO("SBG DRIVER [Mag Calib] - Magnetometers calibration results saved to file %s", output_filename.c_str());
463 }
464 
465 void SbgDevice::writeRtcmMessageToDevice(const rtcm_msgs::Message::ConstPtr& msg)
466 {
467  auto rtcm_data = msg->message;
468  auto error_code = sbgInterfaceWrite(&sbg_interface_, rtcm_data.data(), rtcm_data.size());
469 
470  if (error_code != SBG_NO_ERROR)
471  {
472  char error_str[256];
473 
474  sbgEComErrorToString(error_code, error_str);
475  SBG_LOG_ERROR(SBG_ERROR, "Failed to sent RTCM data to device: %s", error_str);
476  }
477 }
478 
479 //---------------------------------------------------------------------//
480 //- Parameters -//
481 //---------------------------------------------------------------------//
482 
484 {
485  return rate_frequency_;
486 }
487 
488 //---------------------------------------------------------------------//
489 //- Public methods -//
490 //---------------------------------------------------------------------//
491 
493 {
494  SbgErrorCode error_code;
495  initPublishers();
496  configure();
497 
499 
500  if (error_code != SBG_NO_ERROR)
501  {
502  throw ros::Exception("SBG_DRIVER - [Init] Unable to set the callback function - " + std::string(sbgErrorCodeToString(error_code)));
503  }
504 
505  initSubscribers();
506 }
507 
509 {
511  calib_save_service_ = ref_node_.advertiseService("sbg/mag_calibration_save", &SbgDevice::saveMagCalibration, this);
512 
513  ROS_INFO("SBG DRIVER [Init] - SBG device is initialized for magnetometers calibration.");
514 }
515 
517 {
519 }
_SbgEComMagCalibResults::maxNumPoints
uint16_t maxNumPoints
Definition: sbgEComCmdMag.h:129
SBG_ECOM_MAG_CALIB_HIGH_BW
@ SBG_ECOM_MAG_CALIB_HIGH_BW
Definition: sbgEComCmdMag.h:49
_SbgEComDeviceInfo::hardwareRev
uint32_t hardwareRev
Definition: sbgEComCmdInfo.h:47
SBG_ECOM_MAG_CALIB_NOT_ENOUGH_POINTS
#define SBG_ECOM_MAG_CALIB_NOT_ENOUGH_POINTS
Definition: sbgEComCmdMag.h:78
SBG_ECOM_MAG_CALIB_TRUST_LOW
@ SBG_ECOM_MAG_CALIB_TRUST_LOW
Definition: sbgEComCmdMag.h:70
sbg::SbgDevice::initPublishers
void initPublishers()
Definition: sbg_device.cpp:202
sbg::SbgDevice::sbg_interface_
SbgInterface sbg_interface_
Definition: sbg_device.h:73
SBG_ECOM_MAG_CALIB_Z_MOTION_ISSUE
#define SBG_ECOM_MAG_CALIB_Z_MOTION_ISSUE
Definition: sbgEComCmdMag.h:82
_SbgEComMagCalibResults::stdAccuracy
float stdAccuracy
Definition: sbgEComCmdMag.h:125
sbg::ConfigStore::getIpAddress
sbgIpAddress getIpAddress() const
Definition: config_store.cpp:254
sbgErrorCodeToString
static const char * sbgErrorCodeToString(SbgErrorCode errorCode)
Definition: sbgErrorCodes.h:72
sbg::SbgDevice::ref_node_
ros::NodeHandle & ref_node_
Definition: sbg_device.h:74
_SbgEComMagCalibResults::afterMeanError
float afterMeanError
Definition: sbgEComCmdMag.h:120
SBG_ECOM_MAG_CALIB_QUAL_GOOD
@ SBG_ECOM_MAG_CALIB_QUAL_GOOD
Definition: sbgEComCmdMag.h:58
sbg::SbgDevice::exportMagCalibrationResults
void exportMagCalibrationResults() const
Definition: sbg_device.cpp:425
sbgEComInit
SbgErrorCode sbgEComInit(SbgEComHandle *pHandle, SbgInterface *pInterface)
Definition: sbgECom.c:19
SBG_ECOM_MAG_CALIB_MODE_3D
@ SBG_ECOM_MAG_CALIB_MODE_3D
Definition: sbgEComCmdMag.h:37
sbgEComCmdMagStartCalib
SbgErrorCode sbgEComCmdMagStartCalib(SbgEComHandle *pHandle, SbgEComMagCalibMode mode, SbgEComMagCalibBandwidth bandwidth)
Definition: sbgEComCmdMag.c:274
SBG_ECOM_MAG_CALIB_QUAL_OPTIMAL
@ SBG_ECOM_MAG_CALIB_QUAL_OPTIMAL
Definition: sbgEComCmdMag.h:57
_SbgEComMagCalibResults::matrix
float matrix[9]
Definition: sbgEComCmdMag.h:131
sbg::SbgDevice::onLogReceivedCallback
static SbgErrorCode onLogReceivedCallback(SbgEComHandle *p_handle, SbgEComClass msg_class, SbgEComMsgId msg, const SbgBinaryLogData *p_log_data, void *p_user_arg)
Definition: sbg_device.cpp:99
sbgInterfaceSerialDestroy
SBG_COMMON_LIB_API SbgErrorCode sbgInterfaceSerialDestroy(SbgInterface *pHandle)
Definition: sbgInterfaceSerialUnix.c:228
sbg::SbgDevice::initDeviceForReceivingData
void initDeviceForReceivingData()
Definition: sbg_device.cpp:492
sbg::ConfigApplier::saveConfiguration
void saveConfiguration()
Definition: config_applier.cpp:442
timeToStr
std::string timeToStr(ros::WallTime ros_t)
Definition: sbg_device.cpp:22
SBG_ECOM_MAG_CALIB_LOW_BW
@ SBG_ECOM_MAG_CALIB_LOW_BW
Definition: sbgEComCmdMag.h:47
SBG_ECOM_MAG_CALIB_ALIGNMENT_ISSUE
#define SBG_ECOM_MAG_CALIB_ALIGNMENT_ISSUE
Definition: sbgEComCmdMag.h:83
sbgInterfaceUdpDestroy
SbgErrorCode sbgInterfaceUdpDestroy(SbgInterface *pHandle)
Definition: sbgInterfaceUdp.c:315
_SbgEComMagCalibResults::afterStdError
float afterStdError
Definition: sbgEComCmdMag.h:121
sbg::SbgDevice::g_mag_calib_quality_
static std::map< SbgEComMagCalibQuality, std::string > g_mag_calib_quality_
Definition: sbg_device.h:63
sbg::SbgDevice::displayMagCalibrationStatusResult
void displayMagCalibrationStatusResult() const
Definition: sbg_device.cpp:373
sbgEComSetReceiveLogCallback
SbgErrorCode sbgEComSetReceiveLogCallback(SbgEComHandle *pHandle, SbgEComReceiveLogFunc pReceiveLogCallback, void *pUserArg)
Definition: sbgECom.c:195
sbg::SbgDevice::mag_calib_results_
SbgEComMagCalibResults mag_calib_results_
Definition: sbg_device.h:82
_SbgEComMagCalibResults::offset
float offset[3]
Definition: sbgEComCmdMag.h:130
ros::NodeHandle::advertiseService
ServiceServer advertiseService(AdvertiseServiceOptions &ops)
sbgInterfaceWrite
SBG_INLINE SbgErrorCode sbgInterfaceWrite(SbgInterface *pHandle, const void *pBuffer, size_t bytesToWrite)
Definition: sbgInterface.h:165
sbg::ConfigStore::getReadingRateFrequency
uint32_t getReadingRateFrequency() const
Definition: config_store.cpp:354
_SbgEComMagCalibResults::numPoints
uint16_t numPoints
Definition: sbgEComCmdMag.h:128
ros::Exception
sbgRadToDegF
SBG_INLINE float sbgRadToDegF(float angle)
Definition: sbgDefines.h:371
sbgVersion.h
SBG_ECOM_MAG_CALIB_QUAL_POOR
@ SBG_ECOM_MAG_CALIB_QUAL_POOR
Definition: sbgEComCmdMag.h:59
sbg::SbgDevice::onLogReceived
void onLogReceived(SbgEComClass msg_class, SbgEComMsgId msg, const SbgBinaryLogData &ref_sbg_data)
Definition: sbg_device.cpp:113
_SbgEComDeviceInfo::calibrationDay
uint8_t calibrationDay
Definition: sbgEComCmdInfo.h:46
sbg::SbgDevice::loadParameters
void loadParameters()
Definition: sbg_device.cpp:121
sbg::SbgDevice::calib_save_service_
ros::ServiceServer calib_save_service_
Definition: sbg_device.h:84
sbg::SbgDevice::rtcm_sub_
ros::Subscriber rtcm_sub_
Definition: sbg_device.h:86
sbgEComErrorToString
void sbgEComErrorToString(SbgErrorCode errorCode, char errorMsg[256])
Definition: sbgECom.c:245
SBG_UNUSED_PARAMETER
#define SBG_UNUSED_PARAMETER(x)
Definition: sbgDefines.h:194
_SbgEComDeviceInfo::productCode
uint8_t productCode[SBG_ECOM_INFO_PRODUCT_CODE_LENGTH]
Definition: sbgEComCmdInfo.h:41
f
f
_SbgEComMagCalibResults::beforeMaxError
float beforeMaxError
Definition: sbgEComCmdMag.h:118
sbg::SbgDevice::uploadMagCalibrationToDevice
bool uploadMagCalibrationToDevice()
Definition: sbg_device.cpp:345
_SbgEComDeviceInfo::serialNumber
uint32_t serialNumber
Definition: sbgEComCmdInfo.h:42
sbg::SbgDevice::saveMagCalibration
bool saveMagCalibration(std_srvs::Trigger::Request &ref_ros_request, std_srvs::Trigger::Response &ref_ros_response)
Definition: sbg_device.cpp:269
sbg::ConfigApplier
Definition: config_applier.h:50
sbg::MessagePublisher::publish
void publish(SbgEComClass sbg_msg_class, SbgEComMsgId sbg_msg_id, const SbgBinaryLogData &ref_sbg_log)
Definition: message_publisher.cpp:507
sbg::ConfigStore::getRtcmFullTopic
const std::string & getRtcmFullTopic() const
Definition: config_store.cpp:404
sbg::SbgDevice::getUpdateFrequency
uint32_t getUpdateFrequency() const
Definition: sbg_device.cpp:483
sbg::SbgDevice::rate_frequency_
uint32_t rate_frequency_
Definition: sbg_device.h:78
_SbgEComMagCalibResults::confidence
SbgEComMagCalibConfidence confidence
Definition: sbgEComCmdMag.h:113
sbg::SbgDevice::initDeviceForMagCalibration
void initDeviceForMagCalibration()
Definition: sbg_device.cpp:508
sbg::ConfigStore::checkConfigWithRos
bool checkConfigWithRos() const
Definition: config_store.cpp:224
SbgEComClass
enum _SbgEComClass SbgEComClass
_SbgEComMagCalibResults::advancedStatus
uint16_t advancedStatus
Definition: sbgEComCmdMag.h:114
sbgNetworkIpToString
SBG_COMMON_LIB_API void sbgNetworkIpToString(sbgIpAddress ipAddr, char *pBuffer, size_t maxSize)
Definition: sbgNetwork.c:14
sbg::SbgDevice::config_store_
ConfigStore config_store_
Definition: sbg_device.h:76
sbg::SbgDevice::~SbgDevice
~SbgDevice()
Definition: sbg_device.cpp:69
sbgEComCmdMagComputeCalib
SbgErrorCode sbgEComCmdMagComputeCalib(SbgEComHandle *pHandle, SbgEComMagCalibResults *pCalibResults)
Definition: sbgEComCmdMag.c:350
sbg::ConfigStore::getOutputPortAddress
uint32_t getOutputPortAddress() const
Definition: config_store.cpp:259
_SbgEComMagCalibResults::maxAccuracy
float maxAccuracy
Definition: sbgEComCmdMag.h:126
ros::WallTime::now
static WallTime now()
sbg::SbgDevice::message_publisher_
MessagePublisher message_publisher_
Definition: sbg_device.h:75
sbg::SbgDevice::g_mag_calib_bandwidth_
static std::map< SbgEComMagCalibBandwidth, std::string > g_mag_calib_bandwidth_
Definition: sbg_device.h:66
SBG_ERROR
@ SBG_ERROR
Definition: sbgErrorCodes.h:36
_SbgEComMagCalibResults::beforeStdError
float beforeStdError
Definition: sbgEComCmdMag.h:117
_SbgBinaryLogData
This file is used to parse received binary logs.
Definition: sbgEComBinaryLogs.h:49
sbg::SbgDevice::com_handle_
SbgEComHandle com_handle_
Definition: sbg_device.h:72
sbg::SbgDevice::mag_calibration_ongoing_
bool mag_calibration_ongoing_
Definition: sbg_device.h:80
sbg::SbgDevice::mag_calibration_done_
bool mag_calibration_done_
Definition: sbg_device.h:81
sbg::ConfigStore::isInterfaceSerial
bool isInterfaceSerial() const
Definition: config_store.cpp:229
SBG_LOG_ERROR
#define SBG_LOG_ERROR(format,...)
Definition: sbgDebug.h:62
sbgEComClose
SbgErrorCode sbgEComClose(SbgEComHandle *pHandle)
Definition: sbgECom.c:58
_SbgEComDeviceInfo::calibationRev
uint32_t calibationRev
Definition: sbgEComCmdInfo.h:43
SBG_ECOM_MAG_CALIB_X_MOTION_ISSUE
#define SBG_ECOM_MAG_CALIB_X_MOTION_ISSUE
Definition: sbgEComCmdMag.h:80
SBG_ECOM_MAG_CALIB_MODE_2D
@ SBG_ECOM_MAG_CALIB_MODE_2D
Definition: sbgEComCmdMag.h:34
_SbgEComMagCalibResults::beforeMeanError
float beforeMeanError
Definition: sbgEComCmdMag.h:116
sbg::SbgDevice::g_mag_calib_confidence_
static std::map< SbgEComMagCalibConfidence, std::string > g_mag_calib_confidence_
Definition: sbg_device.h:64
ROS_WARN
#define ROS_WARN(...)
_SbgEComDeviceInfo::calibrationYear
uint16_t calibrationYear
Definition: sbgEComCmdInfo.h:44
ros::NodeHandle::subscribe
Subscriber subscribe(const std::string &topic, uint32_t queue_size, const boost::function< void(C)> &callback, const VoidConstPtr &tracked_object=VoidConstPtr(), const TransportHints &transport_hints=TransportHints())
sbg::SbgDevice::readDeviceInfo
void readDeviceInfo()
Definition: sbg_device.cpp:170
ros::WallTime
sbg::SbgDevice::getVersionAsString
std::string getVersionAsString(uint32 sbg_version_enc) const
Definition: sbg_device.cpp:194
sbg::SbgDevice::g_mag_calib_mode_
static std::map< SbgEComMagCalibMode, std::string > g_mag_calib_mode_
Definition: sbg_device.h:65
sbg::ConfigApplier::applyConfiguration
void applyConfiguration(const ConfigStore &ref_config_store)
Definition: config_applier.cpp:405
sbg::ConfigStore::getInputPortAddress
uint32_t getInputPortAddress() const
Definition: config_store.cpp:264
_SbgEComHandle
Definition: sbgECom.h:70
SBG_ECOM_MAG_CALIB_TOO_MUCH_DISTORTIONS
#define SBG_ECOM_MAG_CALIB_TOO_MUCH_DISTORTIONS
Definition: sbgEComCmdMag.h:79
sbgInterfaceSerialCreate
SBG_COMMON_LIB_API SbgErrorCode sbgInterfaceSerialCreate(SbgInterface *pHandle, const char *deviceName, uint32_t baudRate)
sbgEComCmdGetInfo
SbgErrorCode sbgEComCmdGetInfo(SbgEComHandle *pHandle, SbgEComDeviceInfo *pInfo)
Definition: sbgEComCmdInfo.c:14
SBG_ECOM_MAG_CALIB_QUAL_INVALID
@ SBG_ECOM_MAG_CALIB_QUAL_INVALID
Definition: sbgEComCmdMag.h:60
sbg::SbgDevice::startMagCalibration
bool startMagCalibration()
Definition: sbg_device.cpp:300
sbg::SbgDevice::periodicHandle
void periodicHandle()
Definition: sbg_device.cpp:516
sbg::SbgDevice::writeRtcmMessageToDevice
void writeRtcmMessageToDevice(const rtcm_msgs::Message::ConstPtr &msg)
Definition: sbg_device.cpp:465
SbgEComMagCalibMode
enum _SbgEComMagCalibMode SbgEComMagCalibMode
This file implements SbgECom commands related to Magnetometer module.
sbg::SbgDevice::connect
void connect()
Definition: sbg_device.cpp:130
sbg::ConfigStore::isInterfaceUdp
bool isInterfaceUdp() const
Definition: config_store.cpp:249
_SbgEComMagCalibResults::quality
SbgEComMagCalibQuality quality
Definition: sbgEComCmdMag.h:112
SBG_NO_ERROR
@ SBG_NO_ERROR
Definition: sbgErrorCodes.h:35
std
_SbgEComMagCalibResults::afterMaxError
float afterMaxError
Definition: sbgEComCmdMag.h:122
ROS_ERROR
#define ROS_ERROR(...)
SBG_ECOM_MAG_CALIB_TRUST_HIGH
@ SBG_ECOM_MAG_CALIB_TRUST_HIGH
Definition: sbgEComCmdMag.h:68
SbgEComMsgId
uint8_t SbgEComMsgId
Definition: sbgEComIds.h:289
sbgEComHandle
SbgErrorCode sbgEComHandle(SbgEComHandle *pHandle)
Definition: sbgECom.c:165
sbg::ConfigStore::shouldSubscribeToRtcm
bool shouldSubscribeToRtcm() const
Definition: config_store.cpp:399
SBG_ECOM_MAG_CALIB_MEDIUM_BW
@ SBG_ECOM_MAG_CALIB_MEDIUM_BW
Definition: sbgEComCmdMag.h:48
sbg::ConfigStore::getMagnetometerCalibBandwidth
const SbgEComMagCalibBandwidth & getMagnetometerCalibBandwidth() const
Definition: config_store.cpp:309
sbg::ConfigStore::loadFromRosNodeHandle
void loadFromRosNodeHandle(const ros::NodeHandle &ref_node_handle)
Definition: config_store.cpp:423
_SbgEComDeviceInfo::calibrationMonth
uint8_t calibrationMonth
Definition: sbgEComCmdInfo.h:45
sbg::SbgDevice::endMagCalibration
bool endMagCalibration()
Definition: sbg_device.cpp:325
SbgErrorCode
enum _SbgErrorCode SbgErrorCode
Header file that defines all error codes for SBG Systems libraries.
sbgInterfaceUdpCreate
SbgErrorCode sbgInterfaceUdpCreate(SbgInterface *pHandle, sbgIpAddress remoteAddr, uint32 remotePort, uint32 localPort)
Definition: sbgInterfaceUdp.c:158
sbg::ConfigStore::getUartPortName
const std::string & getUartPortName() const
Definition: config_store.cpp:234
_SbgEComMagCalibResults::meanAccuracy
float meanAccuracy
Definition: sbgEComCmdMag.h:124
sbg::MessagePublisher::initPublishers
void initPublishers(ros::NodeHandle &ref_ros_node_handle, const ConfigStore &ref_config_store)
Definition: message_publisher.cpp:472
_SbgEComDeviceInfo
Definition: sbgEComCmdInfo.h:39
sbgEComCmdMagSetCalibData
SbgErrorCode sbgEComCmdMagSetCalibData(SbgEComHandle *pHandle, const float offset[3], const float matrix[9])
Definition: sbgEComCmdMag.c:44
SBG_ECOM_MAG_CALIB_Y_MOTION_ISSUE
#define SBG_ECOM_MAG_CALIB_Y_MOTION_ISSUE
Definition: sbgEComCmdMag.h:81
sbgVersionToStringEncoded
SBG_COMMON_LIB_API SbgErrorCode sbgVersionToStringEncoded(uint32_t version, char *pBuffer, uint32_t sizeOfBuffer)
Definition: sbgVersion.c:414
sbg::ConfigStore::getMagnetometerCalibMode
const SbgEComMagCalibMode & getMagnetometerCalibMode() const
Definition: config_store.cpp:304
_SbgEComDeviceInfo::firmwareRev
uint32_t firmwareRev
Definition: sbgEComCmdInfo.h:48
ROS_INFO
#define ROS_INFO(...)
SBG_ECOM_MAG_CALIB_TRUST_MEDIUM
@ SBG_ECOM_MAG_CALIB_TRUST_MEDIUM
Definition: sbgEComCmdMag.h:69
sbg::SbgDevice
Definition: sbg_device.h:55
sbg::ConfigStore::getBaudRate
uint32_t getBaudRate() const
Definition: config_store.cpp:239
uint32
unsigned int uint32
Definition: sbgTypes.h:52
sbg::SbgDevice::configure
void configure()
Definition: sbg_device.cpp:221
sbg::SbgDevice::calib_service_
ros::ServiceServer calib_service_
Definition: sbg_device.h:83
SbgEComMagCalibBandwidth
enum _SbgEComMagCalibBandwidth SbgEComMagCalibBandwidth
sbg::SbgDevice::processMagCalibration
bool processMagCalibration(std_srvs::Trigger::Request &ref_ros_request, std_srvs::Trigger::Response &ref_ros_response)
Definition: sbg_device.cpp:230
ros::NodeHandle
sbg_device.h
Implement device connection / parsing.
sbg::SbgDevice::initSubscribers
void initSubscribers()
Definition: sbg_device.cpp:209


sbg_driver
Author(s): SBG Systems
autogenerated on Fri Oct 11 2024 02:13:40