10 double num = std::fmod(_value, (2 * M_PI));
13 num = num - (2 * M_PI);
20 double num = std::fmod(_value, (2 * M_PI));
23 num = num - (2 * M_PI);
30 return std::fmod(_value, (2 * M_PI));
35 return std::fmod(_value, (2 * M_PI));
41 quat.
setRPY(roll, pitch, yaw);
50 kvh_geo_fog_3d_msgs::KvhGeoFog3DSystemState sysStateMsg;
59 sysStateMsg.latitude_rad = _packet.
latitude;
60 sysStateMsg.longitude_rad = _packet.
longitude;
61 sysStateMsg.height_m = _packet.
height;
63 sysStateMsg.absolute_velocity_north_mps = _packet.
velocity[0];
64 sysStateMsg.absolute_velocity_east_mps = _packet.
velocity[1];
65 sysStateMsg.absolute_velocity_down_mps = _packet.
velocity[2];
71 sysStateMsg.g_force_g = _packet.
g_force;
85 _publisher.
publish(sysStateMsg);
90 kvh_geo_fog_3d_msgs::KvhGeoFog3DSatellites satellitesMsg;
92 satellitesMsg.hdop = _packet.
hdop;
93 satellitesMsg.vdop = _packet.
vdop;
99 _publisher.
publish(satellitesMsg);
104 kvh_geo_fog_3d_msgs::KvhGeoFog3DDetailSatellites detailSatellitesMsg;
123 detailSatellitesMsg.satellite_number.push_back(satellite.
number);
124 detailSatellitesMsg.satellite_frequencies.push_back(satellite.
frequencies.
r);
125 detailSatellitesMsg.elevation_deg.push_back(satellite.
elevation);
126 detailSatellitesMsg.azimuth_deg.push_back(satellite.
azimuth);
127 detailSatellitesMsg.snr_decibal.push_back(satellite.
snr);
130 _publisher.
publish(detailSatellitesMsg);
135 kvh_geo_fog_3d_msgs::KvhGeoFog3DLocalMagneticField localMagFieldMsg;
141 _publisher.
publish(localMagFieldMsg);
146 kvh_geo_fog_3d_msgs::KvhGeoFog3DUTMPosition utmPosMsg;
148 utmPosMsg.northing_m = _packet.
position[0];
149 utmPosMsg.easting_m = _packet.
position[1];
150 utmPosMsg.height_m = _packet.
position[2];
151 utmPosMsg.zone_character = _packet.
zone;
158 kvh_geo_fog_3d_msgs::KvhGeoFog3DECEFPos ecefPosMsg;
160 ecefPosMsg.ecef_x_m = _packet.
position[0];
161 ecefPosMsg.ecef_y_m = _packet.
position[1];
162 ecefPosMsg.ecef_z_m = _packet.
position[2];
164 _publisher.
publish(ecefPosMsg);
169 kvh_geo_fog_3d_msgs::KvhGeoFog3DNorthSeekingInitStatus northSeekInitStatMsg;
185 _publisher.
publish(northSeekInitStatMsg);
190 kvh_geo_fog_3d_msgs::KvhGeoFog3DOdometerState odometerStateMsg;
192 odometerStateMsg.odometer_pulse_count = _packet.
pulse_count;
193 odometerStateMsg.odometer_distance_m = _packet.
distance;
194 odometerStateMsg.odometer_speed_mps = _packet.
speed;
195 odometerStateMsg.odometer_slip_m = _packet.
slip;
196 odometerStateMsg.odometer_active = _packet.
active;
198 _publisher.
publish(odometerStateMsg);
203 kvh_geo_fog_3d_msgs::KvhGeoFog3DRawSensors rawSensorMsg;
211 rawSensorMsg.gyro_x_rps = _packet.
gyroscopes[0];
212 rawSensorMsg.gyro_y_rps = _packet.
gyroscopes[1];
213 rawSensorMsg.gyro_z_rps = _packet.
gyroscopes[2];
220 rawSensorMsg.pressure_pa = _packet.
pressure;
223 _publisher.
publish(rawSensorMsg);
228 kvh_geo_fog_3d_msgs::KvhGeoFog3DRawGNSS rawGnssMsg;
234 rawGnssMsg.latitude_rad = _packet.
position[0];
235 rawGnssMsg.longitude_rad = _packet.
position[1];
236 rawGnssMsg.height_m = _packet.
position[2];
242 rawGnssMsg.vel_north_m = _packet.
velocity[0];
243 rawGnssMsg.vel_east_m = _packet.
velocity[1];
244 rawGnssMsg.vel_down_m = _packet.
velocity[2];
246 rawGnssMsg.tilt_rad = _packet.
tilt;
249 rawGnssMsg.heading_rad = _packet.
heading;
252 rawGnssMsg.gnss_fix = _packet.
flags.
b.fix_type;
253 rawGnssMsg.doppler_velocity_valid = _packet.
flags.
b.velocity_valid;
254 rawGnssMsg.time_valid = _packet.
flags.
b.time_valid;
255 rawGnssMsg.external_gnss = _packet.
flags.
b.external_gnss;
256 rawGnssMsg.tilt_valid = _packet.
flags.
b.tilt_valid;
257 rawGnssMsg.heading_valid = _packet.
flags.
b.heading_valid;
259 _publisher.
publish(rawGnssMsg);
264 sensor_msgs::Imu imuRaw;
266 imuRaw.header.frame_id =
"imu_link_frd";
271 imuRaw.orientation_covariance[0] = -1;
294 sensor_msgs::Imu imuRawFLU;
296 imuRawFLU.header.frame_id =
"imu_link_flu";
301 imuRawFLU.orientation_covariance[0] = -1;
326 sensor_msgs::Imu imuNED;
328 imuNED.header.frame_id =
"imu_link_frd";
336 imuNED.orientation.x = q.getX();
337 imuNED.orientation.y = q.getY();
338 imuNED.orientation.z = q.getZ();
339 imuNED.orientation.w = q.
getW();
368 sensor_msgs::Imu imuENU;
370 imuENU.header.frame_id =
"imu_link_flu";
375 double pitch = -1 * _sysStatePacket.
orientation[1];
381 imuENU.orientation.x = q.getX();
382 imuENU.orientation.y = q.getY();
383 imuENU.orientation.z = q.getZ();
384 imuENU.orientation.w = q.
getW();
409 geometry_msgs::Vector3Stamped imuRpyNED;
411 imuRpyNED.header.frame_id =
"imu_link_frd";
418 imuRpyNED.vector.x = roll;
419 imuRpyNED.vector.y = pitch;
420 imuRpyNED.vector.z = boundedYaw;
426 geometry_msgs::Vector3Stamped imuRpyNEDDeg;
428 imuRpyNEDDeg.header.frame_id =
"imu_link_frd";
435 imuRpyNEDDeg.vector.x = ((roll * 180.0) / M_PI);
436 imuRpyNEDDeg.vector.y = ((pitch * 180.0) / M_PI);
437 imuRpyNEDDeg.vector.z = ((boundedYaw * 180.0) / M_PI);
439 _publisher.
publish(imuRpyNEDDeg);
444 geometry_msgs::Vector3Stamped imuRpyENU;
446 imuRpyENU.header.frame_id =
"imu_link_flu";
451 double pitch = -1 * _sysStatePacket.
orientation[1];
455 imuRpyENU.vector.x = roll;
456 imuRpyENU.vector.y = pitch;
457 imuRpyENU.vector.z = yawENU;
464 geometry_msgs::Vector3Stamped imuRpyENUDeg;
466 imuRpyENUDeg.header.frame_id =
"imu_link_flu";
470 double rollDeg = ((_sysStatePacket.
orientation[0] * 180.0) / M_PI);
471 double pitchDeg = -1 * ((_sysStatePacket.
orientation[1] * 180.0) / M_PI);
474 double yawENUDeg = ((yawENU * 180.0) / M_PI);
476 imuRpyENUDeg.vector.x = rollDeg;
477 imuRpyENUDeg.vector.y = pitchDeg;
478 imuRpyENUDeg.vector.z = yawENUDeg;
480 _publisher.
publish(imuRpyENUDeg);
485 sensor_msgs::NavSatFix navSatFixMsg;
487 navSatFixMsg.header.frame_id =
"gps";
494 navSatFixMsg.status.status = navSatFixMsg.status.STATUS_NO_FIX;
498 navSatFixMsg.status.status = navSatFixMsg.status.STATUS_FIX;
501 navSatFixMsg.status.status = navSatFixMsg.status.STATUS_SBAS_FIX;
504 navSatFixMsg.status.status = navSatFixMsg.status.STATUS_GBAS_FIX;
508 double latitude_deg = (_sysStatePacket.
latitude * 180.0) / M_PI;
509 double longitude_deg = (_sysStatePacket.
longitude * 180.0) / M_PI;
510 navSatFixMsg.latitude = latitude_deg;
511 navSatFixMsg.longitude = longitude_deg;
512 navSatFixMsg.altitude = _sysStatePacket.
height;
513 navSatFixMsg.position_covariance_type = navSatFixMsg.COVARIANCE_TYPE_DIAGONAL_KNOWN;
519 _publisher.
publish(navSatFixMsg);
524 sensor_msgs::NavSatFix rawNavSatFixMsg;
526 rawNavSatFixMsg.header.frame_id =
"gps";
529 double rawGnssLatitude_deg = (_rawGnssPacket.
position[0] * 180.0) / M_PI;
530 double rawGnssLongitude_deg = (_rawGnssPacket.
position[1] * 180.0) / M_PI;
531 rawNavSatFixMsg.latitude = rawGnssLatitude_deg;
532 rawNavSatFixMsg.longitude = rawGnssLongitude_deg;
533 rawNavSatFixMsg.altitude = _rawGnssPacket.
position[2];
539 rawNavSatFixMsg.status.status = rawNavSatFixMsg.status.STATUS_NO_FIX;
543 rawNavSatFixMsg.status.status = rawNavSatFixMsg.status.STATUS_FIX;
546 rawNavSatFixMsg.status.status = rawNavSatFixMsg.status.STATUS_SBAS_FIX;
549 rawNavSatFixMsg.status.status = rawNavSatFixMsg.status.STATUS_GBAS_FIX;
552 rawNavSatFixMsg.position_covariance_type = rawNavSatFixMsg.COVARIANCE_TYPE_DIAGONAL_KNOWN;
559 _publisher.
publish(rawNavSatFixMsg);
564 sensor_msgs::MagneticField magFieldMsg;
567 magFieldMsg.header.frame_id =
"imu_link_frd";
568 magFieldMsg.magnetic_field.x = _rawSensorPack.
magnetometers[0];
569 magFieldMsg.magnetic_field.y = _rawSensorPack.
magnetometers[1];
570 magFieldMsg.magnetic_field.z = _rawSensorPack.
magnetometers[2];
572 _publisher.
publish(magFieldMsg);
578 nav_msgs::Odometry odomMsgNED;
580 odomMsgNED.header.frame_id =
"utm_ned";
581 odomMsgNED.child_frame_id =
"imu_link_frd";
584 odomMsgNED.pose.pose.position.x = _utmPosPacket.
position[0];
585 odomMsgNED.pose.pose.position.y = _utmPosPacket.
position[1];
586 odomMsgNED.pose.pose.position.z = -1 * _utmPosPacket.
position[2];
596 odomMsgNED.pose.pose.orientation.x = q.getX();
597 odomMsgNED.pose.pose.orientation.y = q.getY();
598 odomMsgNED.pose.pose.orientation.z = q.getZ();
599 odomMsgNED.pose.pose.orientation.w = q.
getW();
606 odomMsgNED.twist.twist.linear.x = _bodyVelPacket.
velocity[0];
607 odomMsgNED.twist.twist.linear.y = _bodyVelPacket.
velocity[1];
608 odomMsgNED.twist.twist.linear.z = _bodyVelPacket.
velocity[2];
609 odomMsgNED.twist.covariance[0] = 0.0001;
610 odomMsgNED.twist.covariance[7] = 0.0001;
611 odomMsgNED.twist.covariance[14] = 0.0001;
616 odomMsgNED.twist.covariance[21] = 0.0001;
617 odomMsgNED.twist.covariance[28] = 0.0001;
618 odomMsgNED.twist.covariance[35] = 0.0001;
620 _publisher.
publish(odomMsgNED);
626 nav_msgs::Odometry odomMsgENU;
628 odomMsgENU.header.frame_id =
"utm_enu";
629 odomMsgENU.child_frame_id =
"imu_link_flu";
633 odomMsgENU.pose.pose.position.x = _utmPosPacket.
position[1];
634 odomMsgENU.pose.pose.position.y = _utmPosPacket.
position[0];
635 odomMsgENU.pose.pose.position.z = _utmPosPacket.
position[2];
644 double pitch = -1 * _sysStatePacket.
orientation[1];
646 double yawENU = (-1 * yawNED + M_PI_2);
651 odomMsgENU.pose.pose.orientation.x = q.getX();
652 odomMsgENU.pose.pose.orientation.y = q.getY();
653 odomMsgENU.pose.pose.orientation.z = q.getZ();
654 odomMsgENU.pose.pose.orientation.w = q.
getW();
662 odomMsgENU.twist.twist.linear.x = _bodyVelPacket.
velocity[0];
663 odomMsgENU.twist.twist.linear.y = -(_bodyVelPacket.
velocity[1]);
664 odomMsgENU.twist.twist.linear.z = -(_bodyVelPacket.
velocity[2]);
665 odomMsgENU.twist.covariance[0] = 0.0001;
666 odomMsgENU.twist.covariance[7] = 0.0001;
667 odomMsgENU.twist.covariance[14] = 0.0001;
670 odomMsgENU.twist.twist.angular.y = (-1 * _sysStatePacket.
angular_velocity[1]);
671 odomMsgENU.twist.twist.angular.z = (-1 * _sysStatePacket.
angular_velocity[2]);
672 odomMsgENU.twist.covariance[21] = 0.0001;
673 odomMsgENU.twist.covariance[28] = 0.0001;
674 odomMsgENU.twist.covariance[35] = 0.0001;
676 _publisher.
publish(odomMsgENU);
681 nav_msgs::Odometry kvhOdomStateMsg;
688 kvhOdomStateMsg.header.frame_id =
"base_link";
690 kvhOdomStateMsg.pose.pose.position.x = (_odomStatePacket.
pulse_count * odomPulseToMeters);
692 kvhOdomStateMsg.pose.pose.position.x = (_odomStatePacket.
pulse_count * odomPulseToMeters);
693 kvhOdomStateMsg.pose.pose.position.y = 0;
694 kvhOdomStateMsg.pose.pose.position.z = 0;
695 kvhOdomStateMsg.twist.twist.linear.x = _odomStatePacket.
speed;
696 kvhOdomStateMsg.twist.twist.linear.y = 0;
697 kvhOdomStateMsg.twist.twist.linear.z = 0;
699 _publisher.
publish(kvhOdomStateMsg);
703 double _trackWidth,
double _odometerVelocityCovariance,
bool _encoderOnLeft)
708 double trackWidth = _trackWidth;
709 double vehicleVelocity;
712 vehicleVelocity = _odomStatePacket.
speed + (0.5 * trackWidth * yawRate);
716 vehicleVelocity = _odomStatePacket.
speed - (0.5 * trackWidth * yawRate);
719 geometry_msgs::TwistWithCovarianceStamped kvhOdomVehSpeedMsg;
722 kvhOdomVehSpeedMsg.header.frame_id =
"base_link";
724 kvhOdomVehSpeedMsg.twist.twist.linear.x = vehicleVelocity;
725 kvhOdomVehSpeedMsg.twist.twist.linear.y = 0.0;
726 kvhOdomVehSpeedMsg.twist.twist.linear.z = 0.0;
727 kvhOdomVehSpeedMsg.twist.covariance[0] = _odometerVelocityCovariance;
728 kvhOdomVehSpeedMsg.twist.covariance[7] = _odometerVelocityCovariance;
729 kvhOdomVehSpeedMsg.twist.covariance[14] = _odometerVelocityCovariance;
731 _publisher.
publish(kvhOdomVehSpeedMsg);
736 sensor_msgs::Imu imuRaw;
738 imuRaw.header.frame_id =
"imu_link_frd";
741 imuRaw.orientation_covariance[0] = -1;
744 imuRaw.angular_velocity.x = _rawSensorPack.
gyroscopes[0];
745 imuRaw.angular_velocity.y = _rawSensorPack.
gyroscopes[1];
746 imuRaw.angular_velocity.z = _rawSensorPack.
gyroscopes[2];
758 sensor_msgs::Imu imuRawFLU;
760 imuRawFLU.header.frame_id =
"imu_link_flu";
763 imuRawFLU.angular_velocity.x = _rawSensorPack.
gyroscopes[0];
764 imuRawFLU.angular_velocity.y = -1 * _rawSensorPack.
gyroscopes[1];
765 imuRawFLU.angular_velocity.z = -1 * _rawSensorPack.
gyroscopes[2];
768 imuRawFLU.linear_acceleration.x = _rawSensorPack.
accelerometers[0];
769 imuRawFLU.linear_acceleration.y = -1 * _rawSensorPack.
accelerometers[1];
770 imuRawFLU.linear_acceleration.z = -1 * _rawSensorPack.
accelerometers[2];
777 geometry_msgs::TwistWithCovarianceStamped velNED;
778 velNED.header.frame_id =
"utm_ned";
780 velNED.twist.twist.linear.x = _sysStatePack.
velocity[0];
781 velNED.twist.twist.linear.y = _sysStatePack.
velocity[1];
782 velNED.twist.twist.linear.z = _sysStatePack.
velocity[2];
793 geometry_msgs::TwistWithCovarianceStamped velENU;
794 velENU.header.frame_id =
"utm_enu";
796 velENU.twist.twist.linear.x = _sysStatePack.
velocity[1];
797 velENU.twist.twist.linear.y = _sysStatePack.
velocity[0];
798 velENU.twist.twist.linear.z = -1 * (_sysStatePack.
velocity[2]);
810 geometry_msgs::TwistWithCovarianceStamped bodyVelFLU;
811 bodyVelFLU.header.frame_id =
"imu_link_flu";
813 bodyVelFLU.twist.twist.linear.x = _bodyVelPack.
velocity[0];
814 bodyVelFLU.twist.twist.linear.y = -(_bodyVelPack.
velocity[1]);
815 bodyVelFLU.twist.twist.linear.z = -(_bodyVelPack.
velocity[2]);
820 bodyVelFLU.twist.covariance[0] = pow(bodyVelStdDevX, 2);
821 bodyVelFLU.twist.covariance[7] = pow(bodyVelStdDevY, 2);
824 _publisher.
publish(bodyVelFLU);
830 geometry_msgs::TwistWithCovarianceStamped bodyVelFRD;
831 bodyVelFRD.header.frame_id =
"imu_link_frd";
833 bodyVelFRD.twist.twist.linear.x = _bodyVelPack.
velocity[0];
834 bodyVelFRD.twist.twist.linear.y = _bodyVelPack.
velocity[1];
835 bodyVelFRD.twist.twist.linear.z = _bodyVelPack.
velocity[2];
840 bodyVelFRD.twist.covariance[0] = pow(bodyVelStdDevX, 2);
841 bodyVelFRD.twist.covariance[7] = pow(bodyVelStdDevY, 2);
844 _publisher.
publish(bodyVelFRD);
float angular_velocity[3]
struct raw_gnss_packet_t::@8::@9 b
void PublishOdomSpeed(ros::Publisher &_publisher, system_state_packet_t _sysStatePacket, odometer_state_packet_t _odomStatePacket, double _trackWidth, double _odometerVelocityCovariance, bool _encoderOnLeft)
float pressure_temperature
void setRPY(const tf2Scalar &roll, const tf2Scalar &pitch, const tf2Scalar &yaw)
union system_state_packet_t::@1 filter_status
void PublishKvhOdometerState(ros::Publisher &_publisher, odometer_state_packet_t _packet)
float current_rotation_angle
void PublishRawGnss(ros::Publisher &_publisher, raw_gnss_packet_t _packet)
float current_gyroscope_bias_solution[3]
void PublishVelNEDTwist(ros::Publisher &_publisher, system_state_packet_t _sysStatePack, velocity_standard_deviation_packet_t _velStdPack)
tf2::Quaternion quatFromRPY(double roll, double pitch, double yaw)
union satellite_t::@10 frequencies
uint8_t beidou_satellites
float standard_deviation[3]
void PublishNorthSeekingStatus(ros::Publisher &_publisher, north_seeking_status_packet_t _packet)
float standard_deviation[3]
void PublishRawSensors(ros::Publisher &_publisher, raw_sensors_packet_t _packet)
void PublishIMU_RPY_ENU(ros::Publisher &_publisher, system_state_packet_t _sysStatePacket)
double BoundFromNegPiToPi(const double _value)
void PublishIMU_RPY_ENU_DEG(ros::Publisher &_publisher, system_state_packet_t _sysStatePacket)
union north_seeking_status_packet_t::@20 north_seeking_status
void PublishUtmPosition(ros::Publisher &_publisher, utm_position_packet_t _packet)
float tilt_standard_deviation
void PublishIMURaw(ros::Publisher &_publisher, system_state_packet_t _sysStatePacket)
uint8_t quadrant_data_collection_progress[4]
void PublishIMUSensorRawFLU(ros::Publisher &_publisher, raw_sensors_packet_t _rawSensorPack)
void PublishSystemState(ros::Publisher &_publisher, system_state_packet_t _packet)
float heading_standard_deviation
void PublishIMUSensorRaw(ros::Publisher &_publisher, raw_sensors_packet_t _rawSensorPack)
uint32_t unix_time_seconds
void publish(const boost::shared_ptr< M > &message) const
#define MAXIMUM_DETAILED_SATELLITES
float standard_deviation[3]
uint32_t unix_time_seconds
struct system_state_packet_t::@0::@2 b
void PublishLocalMagnetics(ros::Publisher &_publisher, local_magnetics_packet_t _packet)
satellite_t satellites[MAXIMUM_DETAILED_SATELLITES]
void PublishIMU_NED(ros::Publisher &_publisher, system_state_packet_t _sysStatePacket, euler_orientation_standard_deviation_packet_t _eulStdDevPack)
void PublishEcefPosition(ros::Publisher &_publisher, ecef_position_packet_t _packet)
void PublishNavSatFix(ros::Publisher &_publisher, system_state_packet_t _sysStatePacket)
float position_standard_deviation[3]
void PublishIMURawFLU(ros::Publisher &_publisher, system_state_packet_t _sysStatePacket)
void PublishSatellites(ros::Publisher &_publisher, satellites_packet_t _packet)
void PublishVelENUTwist(ros::Publisher &_publisher, system_state_packet_t _sysStatePack, velocity_standard_deviation_packet_t _velStdPack)
void PublishSatellitesDetailed(ros::Publisher &_publisher, detailed_satellites_packet_t _packet)
void PublishMagField(ros::Publisher &_publisher, raw_sensors_packet_t _rawSensorPack)
void PublishRawNavSatFix(ros::Publisher &_publisher, system_state_packet_t _sysStatePacket, raw_gnss_packet_t _rawGnssPacket)
TF2SIMD_FORCE_INLINE const tf2Scalar & getW() const
void PublishOdomENU(ros::Publisher &_publisher, system_state_packet_t _sysStatePacket, utm_position_packet_t _utmPosPacket, euler_orientation_standard_deviation_packet_t _eulStdPacket, body_velocity_packet_t _bodyVelPacket)
double BoundFromZeroTo2Pi(const double _value)
void PublishIMU_ENU(ros::Publisher &_publisher, system_state_packet_t _sysStatePacket, euler_orientation_standard_deviation_packet_t _eulStdDevPack)
void PublishVelBodyTwistFLU(ros::Publisher &_publisher, system_state_packet_t _sysStatePacket, body_velocity_packet_t _bodyVelPack, velocity_standard_deviation_packet_t _velStdPack)
void PublishVelBodyTwistFRD(ros::Publisher &_publisher, system_state_packet_t _sysStatePacket, body_velocity_packet_t _bodyVelPack, velocity_standard_deviation_packet_t _velStdPack)
uint8_t glonass_satellites
float current_gyroscope_bias_solution_error
union raw_gnss_packet_t::@8 flags
float body_acceleration[3]
void PublishOdomNED(ros::Publisher &_publisher, system_state_packet_t _sysStatePacket, utm_position_packet_t _utmPosPacket, euler_orientation_standard_deviation_packet_t _eulerStdPacket, body_velocity_packet_t _bodyVelPacket)
union system_state_packet_t::@0 system_status
void PublishOdomState(ros::Publisher &_publisher, odometer_state_packet_t _odomStatePacket, double odomPulseToMeters)
void PublishIMU_RPY_NED_DEG(ros::Publisher &_publisher, system_state_packet_t _sysStatePacket)
void PublishIMU_RPY_NED(ros::Publisher &_publisher, system_state_packet_t _sysStatePacket)