Skip to content

Commit

Permalink
fix: check if node is initialized before adding TF broadcasters
Browse files Browse the repository at this point in the history
  • Loading branch information
bpapaspyros committed Dec 5, 2024
1 parent dcae4e5 commit d9c65b6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions source/modulo_controllers/src/BaseControllerInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,9 @@ geometry_msgs::msg::TransformStamped BaseControllerInterface::lookup_ros_transfo
}

void BaseControllerInterface::add_tf_broadcaster() {
if (this->get_node() == nullptr) {
throw modulo_core::exceptions::CoreException("Failed to add TF buffer and listener: Node is not initialized yet.");
}
if (this->tf_broadcaster_ == nullptr) {
RCLCPP_DEBUG(this->get_node()->get_logger(), "Adding TF broadcaster.");
console_bridge::setLogLevel(console_bridge::CONSOLE_BRIDGE_LOG_NONE);
Expand All @@ -609,6 +612,9 @@ void BaseControllerInterface::add_tf_broadcaster() {
}

void BaseControllerInterface::add_static_tf_broadcaster() {
if (this->get_node() == nullptr) {
throw modulo_core::exceptions::CoreException("Failed to add TF buffer and listener: Node is not initialized yet.");
}
if (this->static_tf_broadcaster_ == nullptr) {
RCLCPP_DEBUG(this->get_node()->get_logger(), "Adding static TF broadcaster.");
console_bridge::setLogLevel(console_bridge::CONSOLE_BRIDGE_LOG_NONE);
Expand Down

0 comments on commit d9c65b6

Please sign in to comment.