Skip to content

Commit 74a658a

Browse files
committed
Publish localization quality topic
1 parent 7804018 commit 74a658a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

mola_bridge_ros2/src/BridgeROS2.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
// ROS 2:
4545
#include <nav_msgs/msg/odometry.hpp>
4646
#include <rclcpp/node.hpp>
47+
#include <std_msgs/msg/float32.hpp>
4748
#include <tf2_geometry_msgs/tf2_geometry_msgs.hpp>
4849

4950
using namespace mola;
@@ -1272,24 +1273,33 @@ void BridgeROS2::timerPubLocalization()
12721273

12731274
// 1/2: Publish to /tf:
12741275
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;
12751278

12761279
auto lck = mrpt::lockHelper(rosPubsMtx_);
12771280

12781281
// Create the publisher the first time an observation arrives:
12791282
const bool is_1st_pub = rosPubs_.pub_sensors.find(locLabel) == rosPubs_.pub_sensors.end();
12801283
auto& pub = rosPubs_.pub_sensors[locLabel];
1284+
auto& pubQuality = rosPubs_.pub_sensors[locQualityLabel];
12811285

12821286
if (is_1st_pub)
12831287
{
12841288
pub = rosNode()->create_publisher<nav_msgs::msg::Odometry>(
12851289
locLabel, rclcpp::SystemDefaultsQoS());
1290+
pubQuality = rosNode()->create_publisher<std_msgs::msg::Float32>(
1291+
locQualityLabel, rclcpp::SystemDefaultsQoS());
12861292
}
12871293
lck.unlock();
12881294

12891295
rclcpp::Publisher<nav_msgs::msg::Odometry>::SharedPtr pubOdo =
12901296
std::dynamic_pointer_cast<rclcpp::Publisher<nav_msgs::msg::Odometry>>(pub);
12911297
ASSERT_(pubOdo);
12921298

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+
12931303
// Send TF:
12941304
tf2::Transform transform = mrpt::ros2bridge::toROS_tfTransform(l->pose);
12951305

@@ -1316,6 +1326,13 @@ void BridgeROS2::timerPubLocalization()
13161326

13171327
pubOdo->publish(msg);
13181328
}
1329+
1330+
// And always publish quality:
1331+
{
1332+
std_msgs::msg::Float32 msg;
1333+
msg.data = l->quality;
1334+
pubOdoQuality->publish(msg);
1335+
}
13191336
}
13201337

13211338
void BridgeROS2::timerPubMap()

0 commit comments

Comments
 (0)