@@ -444,6 +444,7 @@ void UbloxNode::getRosParams() {
444444 this ->declare_parameter (" publish.tim.tm2" , false );
445445
446446 this ->declare_parameter (" publish.nmea" , true );
447+ this ->declare_parameter (" publish.versions" , true );
447448
448449 // INF parameters
449450 this ->declare_parameter (" inf.all" , true );
@@ -497,6 +498,11 @@ void UbloxNode::getRosParams() {
497498 // Larger queue depth to handle all NMEA strings being published consecutively
498499 nmea_pub_ = this ->create_publisher <nmea_msgs::msg::Sentence>(" nmea" , 20 );
499500 }
501+ if (getRosBoolean (this , " publish.versions" )) {
502+ rclcpp::QoS qos (1 );
503+ qos.transient_local ();
504+ versions_pub_ = this ->create_publisher <ublox_msgs::msg::Versions>(" versions" , qos);
505+ }
500506
501507 // Create subscriber for RTCM correction data to enable RTK
502508 this ->subscription_ = this ->create_subscription <rtcm_msgs::msg::Message>(" /rtcm" , 10 , std::bind (&UbloxNode::rtcmCallback, this , std::placeholders::_1));
@@ -641,9 +647,11 @@ void UbloxNode::processMonVer() {
641647 throw std::runtime_error (" Failed to poll MonVER & set relevant settings" );
642648 }
643649
650+ software_version_ = std::string (monVer.sw_version .begin (), monVer.sw_version .end ());
651+ hardware_version_ = std::string (monVer.hw_version .begin (), monVer.hw_version .end ());
644652 RCLCPP_INFO (this ->get_logger (), " %s, HW VER: %s" ,
645- std::string (monVer. sw_version . begin (), monVer. sw_version . end ()) .c_str (),
646- std::string (monVer. hw_version . begin (), monVer. hw_version . end ()) .c_str ());
653+ software_version_ .c_str (),
654+ hardware_version_ .c_str ());
647655 // Convert extension to vector of strings
648656 std::vector<std::string> extensions;
649657 extensions.reserve (monVer.extension .size ());
@@ -694,6 +702,8 @@ void UbloxNode::processMonVer() {
694702 strs = stringSplit (extensions[i], " =" );
695703 if (strs.size () > 1 ) {
696704 if (strs[0 ] == " FWVER" ) {
705+ firmware_version_ = strs[1 ];
706+ RCLCPP_INFO (this ->get_logger (), " FWVER: %s" , firmware_version_.c_str ());
697707 if (strs[1 ].length () > 8 ) {
698708 addProductInterface (strs[1 ].substr (0 , 3 ), strs[1 ].substr (8 , 10 ));
699709 } else {
@@ -729,6 +739,7 @@ void UbloxNode::processMonVer() {
729739 }
730740 }
731741 }
742+ publishVersions ();
732743}
733744
734745bool UbloxNode::configureUblox () {
@@ -925,6 +936,15 @@ void UbloxNode::initialize() {
925936 }
926937}
927938
939+ void UbloxNode::publishVersions () {
940+ ublox_msgs::msg::Versions msg;
941+ msg.hardware_version = hardware_version_;
942+ msg.software_version = software_version_;
943+ msg.firmware_version = firmware_version_;
944+ msg.protocol_version = std::to_string (protocol_version_);
945+ versions_pub_->publish (msg);
946+ }
947+
928948void UbloxNode::shutdown () {
929949 if (gps_->isInitialized ()) {
930950 gps_->close ();
0 commit comments