Skip to content

Commit

Permalink
pub_static_tf parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Doisy committed May 25, 2024
1 parent 3f97907 commit 084aae3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion ouster-ros/src/os_cloud_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ class OusterCloud : public OusterProcessingNodeBase {
RCLCPP_INFO(get_logger(),
"OusterCloud: retrieved new sensor metadata!");
info = sensor::parse_metadata(metadata_msg->data);
tf_bcast.broadcast_transforms(info);
if (tf_bcast.publish_static_tf()) {
tf_bcast.broadcast_transforms(info);
}
create_publishers_subscriptions(info);
}

Expand Down
4 changes: 3 additions & 1 deletion ouster-ros/src/os_driver_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class OusterDriver : public OusterSensor {

virtual void on_metadata_updated(const sensor::sensor_info& info) override {
OusterSensor::on_metadata_updated(info);
tf_bcast.broadcast_transforms(info);
if (tf_bcast.publish_static_tf()) {
tf_bcast.broadcast_transforms(info);
}
}

virtual void create_publishers() override {
Expand Down
4 changes: 4 additions & 0 deletions ouster-ros/src/os_static_transforms_broadcaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class OusterStaticTransformsBroadcaster {
node->declare_parameter("lidar_frame", "os_lidar");
node->declare_parameter("imu_frame", "os_imu");
node->declare_parameter("point_cloud_frame", "");
node->declare_parameter("pub_static_tf", true);
}

void parse_parameters() {
Expand All @@ -31,6 +32,7 @@ class OusterStaticTransformsBroadcaster {
imu_frame = node->get_parameter("imu_frame").as_string();
point_cloud_frame =
node->get_parameter("point_cloud_frame").as_string();
pub_static_tf = node->get_parameter("pub_static_tf").as_bool();

// validate point_cloud_frame
if (point_cloud_frame.empty()) {
Expand Down Expand Up @@ -65,6 +67,7 @@ class OusterStaticTransformsBroadcaster {
bool apply_lidar_to_sensor_transform() const {
return point_cloud_frame == sensor_frame;
}
bool publish_static_tf() const { return pub_static_tf; }

private:
NodeT* node;
Expand All @@ -73,6 +76,7 @@ class OusterStaticTransformsBroadcaster {
std::string lidar_frame;
std::string sensor_frame;
std::string point_cloud_frame;
bool pub_static_tf;
};

} // namespace ouster_ros

0 comments on commit 084aae3

Please sign in to comment.