Skip to content

Commit

Permalink
Add more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Chi-EEE committed Mar 19, 2024
1 parent 73e1f03 commit 6e4f013
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/rpi/common/include/behaviour_tree/BehaviourTreeHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,19 @@ namespace behaviour_tree

void handleCommand(const std::string message, const rapidjson::Document& message_json)
{
if (message_json["command"].GetString() != "behaviour_tree")
const std::string command = message_json["command"].GetString();
if (command != "behaviour_tree")
{
spdlog::error(R"(The property "command" does not match "behaviour_tree", {})", message_json["command"].GetString());
spdlog::error(R"(The property "command" does not match "behaviour_tree", {})", command);
return;
}
if (!message_json.HasMember("action") || !message_json["action"].IsString())
{
spdlog::error(R"(The property "action" does not exist in the given json.)");
return;
}
switch (utils::hash(message_json["action"].GetString()))
const std::string action = message_json["action"].GetString();
switch (utils::hash(action))
{
case utils::hash("set"):
{
Expand All @@ -53,7 +55,10 @@ namespace behaviour_tree
{
this->startBehaviourTree();
break;
}
}
default:
spdlog::error(R"(The property "action" does not match "set" or "start", {})", action);
break;
};
}

Expand All @@ -71,7 +76,6 @@ namespace behaviour_tree
return;
}
auto &behaviour_tree = maybe_behaviour_tree.value();

spdlog::info("Behaviour tree parsed successfully | {}", behaviour_tree->toString());
this->_setBehaviourTree(behaviour_tree);
}
Expand Down

0 comments on commit 6e4f013

Please sign in to comment.