44
44
// ROS 2:
45
45
#include < nav_msgs/msg/odometry.hpp>
46
46
#include < rclcpp/node.hpp>
47
+ #include < std_msgs/msg/float32.hpp>
47
48
#include < tf2_geometry_msgs/tf2_geometry_msgs.hpp>
48
49
49
50
using namespace mola ;
@@ -1272,24 +1273,33 @@ void BridgeROS2::timerPubLocalization()
1272
1273
1273
1274
// 1/2: Publish to /tf:
1274
1275
const std::string locLabel = (l->method .empty () ? " slam" s : l->method ) + " /pose" s;
1276
+ const std::string locQualityLabel =
1277
+ (l->method .empty () ? " slam" s : l->method ) + " /pose_quality" s;
1275
1278
1276
1279
auto lck = mrpt::lockHelper (rosPubsMtx_);
1277
1280
1278
1281
// Create the publisher the first time an observation arrives:
1279
1282
const bool is_1st_pub = rosPubs_.pub_sensors .find (locLabel) == rosPubs_.pub_sensors .end ();
1280
1283
auto & pub = rosPubs_.pub_sensors [locLabel];
1284
+ auto & pubQuality = rosPubs_.pub_sensors [locQualityLabel];
1281
1285
1282
1286
if (is_1st_pub)
1283
1287
{
1284
1288
pub = rosNode ()->create_publisher <nav_msgs::msg::Odometry>(
1285
1289
locLabel, rclcpp::SystemDefaultsQoS ());
1290
+ pubQuality = rosNode ()->create_publisher <std_msgs::msg::Float32>(
1291
+ locQualityLabel, rclcpp::SystemDefaultsQoS ());
1286
1292
}
1287
1293
lck.unlock ();
1288
1294
1289
1295
rclcpp::Publisher<nav_msgs::msg::Odometry>::SharedPtr pubOdo =
1290
1296
std::dynamic_pointer_cast<rclcpp::Publisher<nav_msgs::msg::Odometry>>(pub);
1291
1297
ASSERT_ (pubOdo);
1292
1298
1299
+ rclcpp::Publisher<std_msgs::msg::Float32>::SharedPtr pubOdoQuality =
1300
+ std::dynamic_pointer_cast<rclcpp::Publisher<std_msgs::msg::Float32>>(pubQuality);
1301
+ ASSERT_ (pubOdoQuality);
1302
+
1293
1303
// Send TF:
1294
1304
tf2::Transform transform = mrpt::ros2bridge::toROS_tfTransform (l->pose );
1295
1305
@@ -1316,6 +1326,13 @@ void BridgeROS2::timerPubLocalization()
1316
1326
1317
1327
pubOdo->publish (msg);
1318
1328
}
1329
+
1330
+ // And always publish quality:
1331
+ {
1332
+ std_msgs::msg::Float32 msg;
1333
+ msg.data = l->quality ;
1334
+ pubOdoQuality->publish (msg);
1335
+ }
1319
1336
}
1320
1337
1321
1338
void BridgeROS2::timerPubMap ()
0 commit comments