message_wrapper.h
Go to the documentation of this file.
1 
34 #ifndef SBG_ROS_MESSAGE_WRAPPER_H
35 #define SBG_ROS_MESSAGE_WRAPPER_H
36 
37 // SbgECom headers
38 #include <sbgEComLib.h>
39 #include <sbgEComIds.h>
40 
41 // Sbg header
42 #include <sbg_matrix3.h>
43 #include <config_store.h>
44 
45 // ROS headers
46 #include <geometry_msgs/TwistStamped.h>
47 #include <geometry_msgs/PointStamped.h>
48 #include "ros/ros.h"
49 #include <sensor_msgs/Imu.h>
50 #include <sensor_msgs/Temperature.h>
51 #include <sensor_msgs/MagneticField.h>
52 #include <sensor_msgs/FluidPressure.h>
53 #include <sensor_msgs/TimeReference.h>
54 #include <sensor_msgs/NavSatFix.h>
58 #include <nav_msgs/Odometry.h>
59 
60 // SbgRos message headers
61 #include "sbg_driver/SbgStatus.h"
62 #include "sbg_driver/SbgUtcTime.h"
63 #include "sbg_driver/SbgImuData.h"
64 #include "sbg_driver/SbgEkfEuler.h"
65 #include "sbg_driver/SbgEkfQuat.h"
66 #include "sbg_driver/SbgEkfNav.h"
67 #include "sbg_driver/SbgShipMotion.h"
68 #include "sbg_driver/SbgMag.h"
69 #include "sbg_driver/SbgMagCalib.h"
70 #include "sbg_driver/SbgGpsVel.h"
71 #include "sbg_driver/SbgGpsPos.h"
72 #include "sbg_driver/SbgGpsHdt.h"
73 #include "sbg_driver/SbgGpsRaw.h"
74 #include "sbg_driver/SbgOdoVel.h"
75 #include "sbg_driver/SbgEvent.h"
76 #include "sbg_driver/SbgImuShort.h"
77 #include "sbg_driver/SbgAirData.h"
78 
79 namespace sbg
80 {
81 typedef struct _UTM0
82 {
83  double easting;
84  double northing;
85  double altitude;
86  int zone;
87 } UTM0;
88 
93 {
94 private:
95 
97  sbg_driver::SbgUtcTime m_last_sbg_utc_;
99  std::string m_frame_id_;
105 
108  std::string m_odom_frame_id_;
111 
112  //---------------------------------------------------------------------//
113  //- Internal methods -//
114  //---------------------------------------------------------------------//
115 
122  float wrapAngle2Pi(float angle_rad) const;
123 
130  float wrapAngle360(float angle_deg) const;
131 
138  double computeMeridian(int zone_number) const;
139 
146  const std_msgs::Header createRosHeader(uint32_t device_timestamp) const;
147 
154  const ros::Time convertInsTimeToUnix(uint32_t device_timestamp) const;
155 
162  const sbg_driver::SbgEkfStatus createEkfStatusMessage(uint32_t ekf_status) const;
163 
170  const sbg_driver::SbgGpsPosStatus createGpsPosStatusMessage(const SbgLogGpsPos& ref_log_gps_pos) const;
171 
178  const sbg_driver::SbgGpsVelStatus createGpsVelStatusMessage(const SbgLogGpsVel& ref_log_gps_vel) const;
179 
186  const sbg_driver::SbgImuStatus createImuStatusMessage(uint16_t sbg_imu_status) const;
187 
194  const sbg_driver::SbgMagStatus createMagStatusMessage(const SbgLogMag& ref_log_mag) const;
195 
202  const sbg_driver::SbgShipMotionStatus createShipMotionStatusMessage(const SbgLogShipMotionData& ref_log_ship_motion) const;
203 
210  const sbg_driver::SbgStatusAiding createStatusAidingMessage(const SbgLogStatusData& ref_log_status) const;
211 
218  const sbg_driver::SbgStatusCom createStatusComMessage(const SbgLogStatusData& ref_log_status) const;
219 
226  const sbg_driver::SbgStatusGeneral createStatusGeneralMessage(const SbgLogStatusData& ref_log_status) const;
227 
234  const sbg_driver::SbgUtcTimeStatus createUtcStatusMessage(const SbgLogUtcData& ref_log_utc) const;
235 
242  uint32_t getNumberOfDaysInYear(uint16_t year) const;
243 
251  uint32_t getNumberOfDaysInMonth(uint16_t year, uint8_t month_index) const;
252 
259  bool isLeapYear(uint16_t year) const;
260 
267  const ros::Time convertUtcToUnix(const sbg_driver::SbgUtcTime& ref_sbg_utc_msg) const;
268 
275  const sbg_driver::SbgAirDataStatus createAirDataStatusMessage(const SbgLogAirData& ref_sbg_air_data) const;
276 
284  const geometry_msgs::TwistStamped createRosTwistStampedMessage(const sbg::SbgVector3f& body_vel, const sbg_driver::SbgImuData& ref_sbg_imu_msg) const;
285 
294  void fillTransform(const std::string &ref_parent_frame_id, const std::string &ref_child_frame_id, const geometry_msgs::Pose &ref_pose, geometry_msgs::TransformStamped &ref_transform_stamped);
295 
302  char UTMLetterDesignator(double Lat);
303 
311  void initUTM(double Lat, double Long, double altitude);
312 
322  void LLtoUTM(double Lat, double Long, int zoneNumber, double &UTMNorthing, double &UTMEasting) const;
323 
324 public:
325 
326  //---------------------------------------------------------------------//
327  //- Constructor -//
328  //---------------------------------------------------------------------//
329 
333  MessageWrapper(void);
334 
335  //---------------------------------------------------------------------//
336  //- Parameters -//
337  //---------------------------------------------------------------------//
338 
344  void setTimeReference(TimeReference time_reference);
345 
351  void setFrameId(const std::string &frame_id);
352 
358  void setUseEnu(bool enu);
359 
365  void setOdomEnable(bool odom_enable);
366 
372  void setOdomPublishTf(bool publish_tf);
373 
379  void setOdomFrameId(const std::string &ref_frame_id);
380 
386  void setOdomBaseFrameId(const std::string &ref_frame_id);
387 
393  void setOdomInitFrameId(const std::string &ref_frame_id);
394 
395  //---------------------------------------------------------------------//
396  //- Operations -//
397  //---------------------------------------------------------------------//
398 
405  const sbg_driver::SbgEkfEuler createSbgEkfEulerMessage(const SbgLogEkfEulerData& ref_log_ekf_euler) const;
406 
413  const sbg_driver::SbgEkfNav createSbgEkfNavMessage(const SbgLogEkfNavData& ref_log_ekf_nav) const;
414 
421  const sbg_driver::SbgEkfQuat createSbgEkfQuatMessage(const SbgLogEkfQuatData& ref_log_ekf_quat) const;
422 
429  const sbg_driver::SbgEvent createSbgEventMessage(const SbgLogEvent& ref_log_event) const;
430 
437  const sbg_driver::SbgGpsHdt createSbgGpsHdtMessage(const SbgLogGpsHdt& ref_log_gps_hdt) const;
438 
445  const sbg_driver::SbgGpsPos createSbgGpsPosMessage(const SbgLogGpsPos& ref_log_gps_pos) const;
446 
453  const sbg_driver::SbgGpsRaw createSbgGpsRawMessage(const SbgLogGpsRaw& ref_log_gps_raw) const;
454 
461  const sbg_driver::SbgGpsVel createSbgGpsVelMessage(const SbgLogGpsVel& ref_log_gps_vel) const;
462 
469  const sbg_driver::SbgImuData createSbgImuDataMessage(const SbgLogImuData& ref_log_imu_data) const;
470 
477  const sbg_driver::SbgMag createSbgMagMessage(const SbgLogMag& ref_log_mag) const;
478 
485  const sbg_driver::SbgMagCalib createSbgMagCalibMessage(const SbgLogMagCalib& ref_log_mag_calib) const;
486 
493  const sbg_driver::SbgOdoVel createSbgOdoVelMessage(const SbgLogOdometerData& ref_log_odo) const;
494 
501  const sbg_driver::SbgShipMotion createSbgShipMotionMessage(const SbgLogShipMotionData& ref_log_ship_motion) const;
502 
509  const sbg_driver::SbgStatus createSbgStatusMessage(const SbgLogStatusData& ref_log_status) const;
510 
517  const sbg_driver::SbgUtcTime createSbgUtcTimeMessage(const SbgLogUtcData& ref_log_utc);
518 
525  const sbg_driver::SbgAirData createSbgAirDataMessage(const SbgLogAirData& ref_air_data_log) const;
526 
533  const sbg_driver::SbgImuShort createSbgImuShortMessage(const SbgLogImuShort& ref_short_imu_log) const;
534 
542  const sensor_msgs::Imu createRosImuMessage(const sbg_driver::SbgImuData& ref_sbg_imu_msg, const sbg_driver::SbgEkfQuat& ref_sbg_quat_msg) const;
543 
553  const nav_msgs::Odometry createRosOdoMessage(const sbg_driver::SbgImuData &ref_sbg_imu_msg, const sbg_driver::SbgEkfNav &ref_sbg_ekf_nav_msg, const sbg_driver::SbgEkfQuat &ref_sbg_ekf_quat_msg, const sbg_driver::SbgEkfEuler &ref_sbg_ekf_euler_msg);
554 
563  const nav_msgs::Odometry createRosOdoMessage(const sbg_driver::SbgImuData &ref_sbg_imu_msg, const sbg_driver::SbgEkfNav &ref_sbg_ekf_nav_msg, const sbg_driver::SbgEkfEuler &ref_sbg_ekf_euler_msg);
564 
574  const nav_msgs::Odometry createRosOdoMessage(const sbg_driver::SbgImuData &ref_sbg_imu_msg, const sbg_driver::SbgEkfNav &ref_sbg_ekf_nav_msg, const tf2::Quaternion &ref_orientation, const sbg_driver::SbgEkfEuler &ref_sbg_ekf_euler_msg);
575 
582  const sensor_msgs::Temperature createRosTemperatureMessage(const sbg_driver::SbgImuData& ref_sbg_imu_msg) const;
583 
590  const sensor_msgs::MagneticField createRosMagneticMessage(const sbg_driver::SbgMag& ref_sbg_mag_msg) const;
591 
600  const geometry_msgs::TwistStamped createRosTwistStampedMessage(const sbg_driver::SbgEkfEuler& ref_sbg_ekf_vel_msg, const sbg_driver::SbgEkfNav& ref_sbg_ekf_nav_msg, const sbg_driver::SbgImuData& ref_sbg_imu_msg) const;
601 
610  const geometry_msgs::TwistStamped createRosTwistStampedMessage(const sbg_driver::SbgEkfQuat& ref_sbg_ekf_vel_msg, const sbg_driver::SbgEkfNav& ref_sbg_ekf_nav_msg, const sbg_driver::SbgImuData& ref_sbg_imu_msg) const;
611 
618  const geometry_msgs::PointStamped createRosPointStampedMessage(const sbg_driver::SbgEkfNav& ref_sbg_ekf_msg) const;
619 
626  const sensor_msgs::TimeReference createRosUtcTimeReferenceMessage(const sbg_driver::SbgUtcTime& ref_sbg_utc_msg) const;
627 
634  const sensor_msgs::NavSatFix createRosNavSatFixMessage(const sbg_driver::SbgGpsPos& ref_sbg_gps_msg) const;
635 
642  const sensor_msgs::FluidPressure createRosFluidPressureMessage(const sbg_driver::SbgAirData& ref_sbg_air_msg) const;
643 };
644 }
645 
646 #endif // SBG_ROS_MESSAGE_WRAPPER_H
double easting
tf2_ros::TransformBroadcaster m_tf_broadcaster_
sbg_driver::SbgUtcTime m_last_sbg_utc_
std::string m_odom_frame_id_
Defines all sbgECom commands identifiers.
double altitude
std::string m_frame_id_
Class to handle the device configuration.
TimeReference m_time_reference_
Handle a 3x3 matrix.
std::string m_odom_init_frame_id_
struct sbg::_UTM0 UTM0
double northing
TimeReference
Definition: config_store.h:51
ros::Time m_ros_processing_time_
Main header file for the SBG Systems Enhanced Communication Library.
std::string m_odom_base_frame_id_
tf2_ros::StaticTransformBroadcaster m_static_tf_broadcaster_


sbg_driver
Author(s): SBG Systems
autogenerated on Sat Sep 3 2022 02:53:35