Skip to content

Commit b5e9ea7

Browse files
author
agennart
committed
Publish current versions
Publish the different versions received from the ublox device on a topic with local durability policy. This is useful to allow for a control node to check whether the different hardware components have the expected versions.
1 parent 577ef65 commit b5e9ea7

4 files changed

Lines changed: 35 additions & 2 deletions

File tree

ublox_gps/include/ublox_gps/node.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <ublox_msgs/msg/cfg_cfg.hpp>
4242
#include <ublox_msgs/msg/cfg_dat.hpp>
4343
#include <ublox_msgs/msg/inf.h>
44+
#include <ublox_msgs/msg/versions.hpp>
4445
#include <rtcm_msgs/msg/message.hpp>
4546
#include <nmea_msgs/msg/sentence.hpp>
4647
// Ublox GPS includes
@@ -217,6 +218,10 @@ class UbloxNode final : public rclcpp::Node {
217218

218219
//! Determined From Mon VER
219220
float protocol_version_ = 0.0;
221+
std::string hardware_version_ = "";
222+
std::string software_version_ = "";
223+
//! Determined From FWVER
224+
std::string firmware_version_ = "";
220225
// Variables set from parameter server
221226
//! Device port
222227
std::string device_;
@@ -271,9 +276,12 @@ class UbloxNode final : public rclcpp::Node {
271276
rclcpp::Publisher<ublox_msgs::msg::AidEPH>::SharedPtr aid_eph_pub_;
272277
rclcpp::Publisher<ublox_msgs::msg::AidHUI>::SharedPtr aid_hui_pub_;
273278
rclcpp::Publisher<nmea_msgs::msg::Sentence>::SharedPtr nmea_pub_;
279+
rclcpp::Publisher<ublox_msgs::msg::Versions>::SharedPtr versions_pub_;
274280

275281
void publish_nmea(const std::string & sentence, const std::string & topic);
276282

283+
void publishVersions();
284+
277285
//! Navigation rate in measurement cycles, see CfgRate.msg
278286
uint16_t nav_rate_{0};
279287

ublox_gps/src/node.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

734745
bool 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+
928948
void UbloxNode::shutdown() {
929949
if (gps_->isInitialized()) {
930950
gps_->close();

ublox_msgs/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ set(msg_files
9999
"msg/TimTM2.msg"
100100
"msg/UpdSOSAck.msg"
101101
"msg/UpdSOS.msg"
102+
"msg/Versions.msg"
102103
)
103104

104105
rosidl_generate_interfaces(${PROJECT_NAME}

ublox_msgs/msg/Versions.msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
string software_version
2+
string hardware_version
3+
string firmware_version
4+
string protocol_version

0 commit comments

Comments
 (0)