Skip to content

Commit

Permalink
fix: thrown CoreException if node is not initialized when adding tf
Browse files Browse the repository at this point in the history
  • Loading branch information
bpapaspyros committed Dec 5, 2024
1 parent b1e5c0f commit f28ff78
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions source/modulo_controllers/src/BaseControllerInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <lifecycle_msgs/msg/state.hpp>

#include <modulo_core/exceptions.hpp>
#include <modulo_core/translators/message_readers.hpp>

template<class... Ts>
Expand Down Expand Up @@ -542,6 +543,10 @@ void BaseControllerInterface::add_service(
}

void BaseControllerInterface::add_tf_listener() {
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_buffer_ == nullptr || this->tf_listener_ == nullptr) {
RCLCPP_DEBUG(this->get_node()->get_logger(), "Adding TF buffer and listener.");
console_bridge::setLogLevel(console_bridge::CONSOLE_BRIDGE_LOG_NONE);
Expand Down

0 comments on commit f28ff78

Please sign in to comment.