Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameter to optionally disable the publication of the static tf #330

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading