Skip to content
Snippets Groups Projects
Commit 9c49af1c authored by Alejandro Lopez Gestoso's avatar Alejandro Lopez Gestoso
Browse files

Fixed exception when creating a logger with a tree not initialized

parent 86ac6d8c
No related branches found
No related tags found
No related merge requests found
......@@ -476,7 +476,12 @@ template <class ConfigClass>
void IriBaseBTClient<ConfigClass>::enable_cout_logger()
{
if(this->logger_cout==NULL)
this->logger_cout=new BT::StdCoutLogger(this->tree);
{
if (this->tree.rootNode() != nullptr)
this->logger_cout=new BT::StdCoutLogger(this->tree);
else
ROS_WARN("IriBaseBTClient::enable_cout_logger -> BehaviorTree not initialized. Disable and re-enable BT cout logger if not working.");
}
}
template <class ConfigClass>
......@@ -504,7 +509,12 @@ void IriBaseBTClient<ConfigClass>::enable_minitrace_logger()
path_ok=true;
if(path_ok)
this->logger_minitrace=new BT::MinitraceLogger(this->tree, (this->path + "/logs/" + this->tree_xml_file + ".json").c_str());
{
if (this->tree.rootNode() != nullptr)
this->logger_minitrace=new BT::MinitraceLogger(this->tree, (this->path + "/logs/" + this->tree_xml_file + ".json").c_str());
else
ROS_WARN("IriBaseBTClient::enable_minitrace_logger -> BehaviorTree not initialized. Disable and re-enable BT minitrace logger if not working.");
}
else
ROS_ERROR("IriBaseBTClient: MinitraceLogger couldn't be enabled");
}
......@@ -535,7 +545,12 @@ void IriBaseBTClient<ConfigClass>::enable_file_logger()
path_ok=true;
if(path_ok)
this->logger_file=new BT::FileLogger(this->tree, (this->path + "/logs/" + this->tree_xml_file + ".fbl").c_str());
{
if (this->tree.rootNode() != nullptr)
this->logger_file=new BT::FileLogger(this->tree, (this->path + "/logs/" + this->tree_xml_file + ".fbl").c_str());
else
ROS_WARN("IriBaseBTClient::enable_file_logger -> BehaviorTree not initialized. Disable and re-enable BT file logger if not working.");
}
else
ROS_ERROR("IriBaseBTClient: Filelogger couldn't be enabled");
}
......@@ -545,7 +560,12 @@ template <class ConfigClass>
void IriBaseBTClient<ConfigClass>::enable_zmq_publisher()
{
if(this->publisher_zmq==NULL)
this->publisher_zmq=new BT::PublisherZMQ(this->tree);
{
if (this->tree.rootNode() != nullptr)
this->publisher_zmq=new BT::PublisherZMQ(this->tree);
else
ROS_WARN("IriBaseBTClient::enable_zmq_publisher -> BehaviorTree not initialized. Disable and re-enable BT ZMQ logger if not working.");
}
}
template <class ConfigClass>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment