Go to the documentation of this file.
35 #include <unordered_map>
44 #include <diagnostic_msgs/DiagnosticArray.h>
45 #include <diagnostic_msgs/DiagnosticStatus.h>
46 #include <geometry_msgs/PoseWithCovarianceStamped.h>
47 #include <geometry_msgs/Quaternion.h>
48 #include <geometry_msgs/TwistWithCovarianceStamped.h>
49 #include <gps_common/GPSFix.h>
50 #include <nav_msgs/Odometry.h>
51 #include <sensor_msgs/Imu.h>
52 #include <sensor_msgs/NavSatFix.h>
53 #include <sensor_msgs/TimeReference.h>
55 #include <septentrio_gnss_driver/AIMPlusStatus.h>
56 #include <septentrio_gnss_driver/AttCovEuler.h>
57 #include <septentrio_gnss_driver/AttEuler.h>
58 #include <septentrio_gnss_driver/BaseVectorCart.h>
59 #include <septentrio_gnss_driver/BaseVectorGeod.h>
60 #include <septentrio_gnss_driver/BlockHeader.h>
61 #include <septentrio_gnss_driver/GALAuthStatus.h>
62 #include <septentrio_gnss_driver/MeasEpoch.h>
63 #include <septentrio_gnss_driver/MeasEpochChannelType1.h>
64 #include <septentrio_gnss_driver/MeasEpochChannelType2.h>
65 #include <septentrio_gnss_driver/PVTCartesian.h>
66 #include <septentrio_gnss_driver/PVTGeodetic.h>
67 #include <septentrio_gnss_driver/PosCovCartesian.h>
68 #include <septentrio_gnss_driver/PosCovGeodetic.h>
69 #include <septentrio_gnss_driver/RFBand.h>
70 #include <septentrio_gnss_driver/RFStatus.h>
71 #include <septentrio_gnss_driver/ReceiverTime.h>
72 #include <septentrio_gnss_driver/VectorInfoCart.h>
73 #include <septentrio_gnss_driver/VectorInfoGeod.h>
74 #include <septentrio_gnss_driver/VelCovCartesian.h>
75 #include <septentrio_gnss_driver/VelCovGeodetic.h>
77 #include <nmea_msgs/Gpgga.h>
78 #include <nmea_msgs/Gpgsa.h>
79 #include <nmea_msgs/Gpgsv.h>
80 #include <nmea_msgs/Gprmc.h>
82 #include <septentrio_gnss_driver/ExtSensorMeas.h>
83 #include <septentrio_gnss_driver/IMUSetup.h>
84 #include <septentrio_gnss_driver/INSNavCart.h>
85 #include <septentrio_gnss_driver/INSNavGeod.h>
86 #include <septentrio_gnss_driver/VelSensorSetup.h>
212 }
catch (
const std::runtime_error& ex)
215 std::string(ex.what()) +
".");
230 uint32_t defaultVal)
const
233 if ((!
pNh_->getParam(name, tempVal)) || (tempVal < 0))
251 template <
typename T>
252 bool param(
const std::string& name, T& val,
const T& defaultVal)
const
254 return pNh_->param(name, val, defaultVal);
297 template <
typename M>
309 it->second.publish(msg);
313 topicMap_.insert(std::make_pair(topic, pub));
324 if (std::isnan(loc.pose.pose.orientation.w))
331 geometry_msgs::TransformStamped transformStamped;
332 transformStamped.header.stamp = loc.header.stamp;
333 transformStamped.header.frame_id = loc.header.frame_id;
334 transformStamped.child_frame_id = loc.child_frame_id;
335 transformStamped.transform.translation.x = loc.pose.pose.position.x;
336 transformStamped.transform.translation.y = loc.pose.pose.position.y;
337 transformStamped.transform.translation.z = loc.pose.pose.position.z;
338 transformStamped.transform.rotation.x = loc.pose.pose.orientation.x;
339 transformStamped.transform.rotation.y = loc.pose.pose.orientation.y;
340 transformStamped.transform.rotation.z = loc.pose.pose.orientation.z;
341 transformStamped.transform.rotation.w = loc.pose.pose.orientation.w;
345 geometry_msgs::TransformStamped T_l_b;
358 <<
": No transform for insertion of local frame at t="
360 <<
". Exception: " << std::string(ex.what()));
369 <<
": No most recent transform for insertion of local frame. Exception: "
370 << std::string(ex.what()));
379 transformStamped.header.stamp = loc.header.stamp;
380 transformStamped.header.frame_id = loc.header.frame_id;
433 const geometry_msgs::TwistWithCovariance& twist)
439 thread_local Eigen::Vector3d vel = Eigen::Vector3d::Zero();
440 thread_local Eigen::Vector3d var = Eigen::Vector3d::Zero();
441 thread_local uint64_t ctr = 0;
445 vel[0] += twist.twist.linear.x;
446 vel[1] += twist.twist.linear.y;
447 vel[2] += twist.twist.linear.z;
448 var[0] += twist.covariance[0];
449 var[1] += twist.covariance[7];
450 var[2] += twist.covariance[14];
453 if ((stamp - lastStamp) >= 495000000)
457 time_t epochSeconds = stamp / 1000000000;
458 struct tm* tm_temp = std::gmtime(&epochSeconds);
459 std::stringstream timeUtc;
460 timeUtc << std::setfill(
'0') << std::setw(2)
461 << std::to_string(tm_temp->tm_hour) << std::setw(2)
462 << std::to_string(tm_temp->tm_min) << std::setw(2)
463 << std::to_string(tm_temp->tm_sec) <<
"." << std::setw(3)
464 << std::to_string((stamp - (stamp / 1000000000) * 1000000000) /
479 else if (var[0] > 0.0)
484 std::to_string(var[0]) +
485 ". Ignoring measurement.");
490 std_x = std::to_string(1000000.0);
499 else if (var[1] > 0.0)
504 std::to_string(var[1]) +
505 ". Ignoring measurement.");
519 else if (var[2] > 0.0)
524 std::to_string(var[2]) +
525 ". Ignoring measurement.");
532 std::string velNmea =
"$PSSN,VSM," + timeUtc.str() +
"," + v_x +
"," +
533 v_y +
"," + std_x +
"," + std_y +
"," + v_z +
"," +
536 char crc = std::accumulate(velNmea.begin() + 1, velNmea.end(), 0,
537 [](
char sum,
char ch) { return sum ^ ch; });
539 std::stringstream crcss;
540 crcss << std::hex << static_cast<int32_t>(
crc);
542 velNmea +=
"*" + crcss.str() +
"\r\n";
545 vel = Eigen::Vector3d::Zero();
546 var = Eigen::Vector3d::Zero();
554 std::shared_ptr<ros::NodeHandle>
pNh_;
558 virtual void sendVelocity(
const std::string& velNmea) = 0;
562 std::unordered_map<std::string, ros::Publisher>
topicMap_;
septentrio_gnss_driver::AttCovEuler AttCovEulerMsg
tf2_ros::TransformListener tfListener_
void registerSubscriber()
septentrio_gnss_driver::AIMPlusStatus AimPlusStatusMsg
std::string local_frame_id
Frame id of the local frame to be inserted.
Capabilities capabilities_
std::string ros_source
VSM source for INS.
std::vector< bool > ros_config
Whether or not to use individual elements of 3D velocity (v_x, v_y, v_z)
septentrio_gnss_driver::MeasEpoch MeasEpochMsg
#define ROS_ERROR_STREAM(args)
sensor_msgs::NavSatStatus NavSatStatusMsg
geometry_msgs::PoseWithCovarianceStamped PoseWithCovarianceStampedMsg
septentrio_gnss_driver::VectorInfoGeod VectorInfoGeodMsg
septentrio_gnss_driver::MeasEpochChannelType1 MeasEpochChannelType1Msg
septentrio_gnss_driver::VectorInfoCart VectorInfoCartMsg
bool insert_local_frame
Wether local frame should be inserted into tf.
void log(log_level::LogLevel logLevel, const std::string &s) const
Log function to provide abstraction of ROS loggers.
bool has_heading
Wether Rx has heading.
septentrio_gnss_driver::VelCovGeodetic VelCovGeodeticMsg
#define ROS_FATAL_STREAM(args)
bool has_improved_vsm_handling
Wether Rx has improved VSM handling.
geometry_msgs::TwistWithCovarianceStamped TwistWithCovarianceStampedMsg
void processTwist(Timestamp stamp, const geometry_msgs::TwistWithCovariance &twist)
sensor_msgs::NavSatFix NavSatFixMsg
bool hasImprovedVsmHandling()
Check if Rx has improved VSM handling.
ros::Subscriber odometrySubscriber_
Odometry subscriber.
void publishMessage(const std::string &topic, const M &msg)
Publishing function.
std::unordered_map< std::string, std::any > topicMap_
Map of topics and publishers.
void callbackOdometry(const nav_msgs::msg::Odometry::ConstSharedPtr odo)
#define ROS_DEBUG_STREAM(args)
septentrio_gnss_driver::PVTGeodetic PVTGeodeticMsg
void publish(const boost::shared_ptr< M > &message) const
This class is the base class for abstraction.
septentrio_gnss_driver::PosCovCartesian PosCovCartesianMsg
geometry_msgs::TransformStamped eigenToTransform(const Eigen::Affine3d &T)
septentrio_gnss_driver::BaseVectorGeod BaseVectorGeodMsg
std::unordered_map< std::string, ros::Publisher > topicMap_
Map of topics and publishers.
Timestamp lastTfStamp_
Last tf stamp.
geometry_msgs::Quaternion QuaternionMsg
#define ROS_WARN_STREAM(args)
nmea_msgs::Gpgsa GpgsaMsg
void processTwist(Timestamp stamp, const geometry_msgs::msg::TwistWithCovariance &twist)
rclcpp::Subscription< nav_msgs::msg::Odometry >::SharedPtr odometrySubscriber_
Odometry subscriber.
nmea_msgs::Gprmc GprmcMsg
#define ROS_WARN_STREAM_THROTTLE(period, args)
void callbackTwist(const TwistWithCovarianceStampedMsg::ConstSharedPtr twist)
septentrio_gnss_driver::PVTCartesian PVTCartesianMsg
virtual void sendVelocity(const std::string &velNmea)=0
Send velocity to communication layer (virtual)
#define ROS_INFO_STREAM_THROTTLE(period, args)
diagnostic_msgs::DiagnosticStatus DiagnosticStatusMsg
bool use_ros_axis_orientation
ROS axis orientation, body: front-left-up, geographic: ENU.
septentrio_gnss_driver::VelCovCartesian VelCovCartesianMsg
std::string trimDecimalPlaces(double num)
Trims decimal places to three.
geometry_msgs::TransformStamped TransformStampedMsg
geometry_msgs::msg::TwistWithCovarianceStamped TwistWithCovarianceStampedMsg
bool isIns()
Check if Rx is INS.
const Settings * settings() const
void setImprovedVsmHandling()
Set improved VSM handling to true.
bool validValue(T s)
Check if value is not set to Do-Not-Use.
septentrio_gnss_driver::INSNavCart INSNavCartMsg
diagnostic_msgs::DiagnosticArray DiagnosticArrayMsg
void callbackOdometry(const nav_msgs::Odometry::ConstPtr &odo)
std::vector< double > ros_variances
Variances of the 3D velocity (var_x, var_y, var_z)
gps_common::GPSStatus GpsStatusMsg
geometry_msgs::Vector3 Vector3Msg
rclcpp::Time TimestampRos
nmea_msgs::Gpgsv GpgsvMsg
bool getUint32Param(const std::string &name, uint32_t &val, uint32_t defaultVal) const
Gets an integer or unsigned integer value from the parameter server.
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())
septentrio_gnss_driver::PosCovGeodetic PosCovGeodeticMsg
#define ROS_INFO_STREAM(args)
septentrio_gnss_driver::RFBand RfBandMsg
bool hasHeading()
Check if Rx has heading.
septentrio_gnss_driver::IMUSetup IMUSetupMsg
Settings settings_
Settings.
Eigen::Isometry3d transformToEigen(const geometry_msgs::Transform &t)
septentrio_gnss_driver::ReceiverTime ReceiverTimeMsg
tf2_ros::TransformBroadcaster tf2Publisher_
Transform publisher.
septentrio_gnss_driver::AttEuler AttEulerMsg
Timestamp timestampFromRos(const TimestampRos &tsr)
Convert ROS timestamp to nsec timestamp.
void setIsIns()
Set INS to true.
septentrio_gnss_driver::MeasEpochChannelType2 MeasEpochChannelType2Msg
nmea_msgs::Gpgga GpggaMsg
const ROSCPP_DECL std::string & getName()
Log level for ROS logging.
sensor_msgs::TimeReference TimeReferenceMsg
ros::Subscriber twistSubscriber_
Twist subscriber.
Timestamp getTime() const
Gets current timestamp.
InsVsm ins_vsm
INS VSM setting.
void callbackTwist(const TwistWithCovarianceStampedMsg::ConstPtr &twist)
Declares lower-level string utility functions used when parsing messages.
TimestampRos timestampToRos(Timestamp ts)
Convert nsec timestamp to ROS timestamp.
nav_msgs::Odometry LocalizationMsg
bool param(const std::string &name, T &val, const T &defaultVal) const
Gets parameter of type T from the parameter server.
gps_common::GPSFix GpsFixMsg
std::shared_ptr< ros::NodeHandle > pNh_
Node handle pointer.
bool is_ins
Wether Rx is INS.
void setHasHeading()
Set has heading to true.
septentrio_gnss_driver::INSNavGeod INSNavGeodMsg
septentrio_gnss_driver::BaseVectorCart BaseVectorCartMsg
rclcpp::Subscription< TwistWithCovarianceStampedMsg >::SharedPtr twistSubscriber_
Twist subscriber.
septentrio_gnss_driver::VelSensorSetup VelSensorSetupMsg
tf2_ros::Buffer tfBuffer_
tf buffer
bool publish_only_valid
Wether to publish only valid messages.
septentrio_gnss_driver::ExtSensorMeas ExtSensorMeasMsg
nav_msgs::msg::Odometry LocalizationMsg
septentrio_gnss_driver::RFStatus RfStatusMsg
septentrio_gnss_driver::GALAuthStatus GalAuthStatusMsg
uint32_t queueSize_
Publisher queue size.
septentrio_gnss_driver::BlockHeader BlockHeaderMsg
TimestampRos lastTfStamp_
Last tf stamp.
bool ros_variances_by_parameter
Whether or not to use variance defined by ROS parameter.
void publishTf(const LocalizationMsg &loc)
Publishing function for tf.
virtual geometry_msgs::TransformStamped lookupTransform(const std::string &target_frame, const ros::Time &target_time, const std::string &source_frame, const ros::Time &source_time, const std::string &fixed_frame, const ros::Duration timeout) const