BehaviorTree/BehaviorTree.CPP

Question on Json conversion in 4.6

Closed this issue · 1 comments

In 4.5 I could register json conversion functions such as:

void jsonPoint(const geometry_msgs::msg::Point& p, nlohmann::json& j)
{
  j["x"] = p.x;
  j["y"] = p.y;
  j["z"] = p.z;
}
void jsonTime(const rclcpp::Time& t, nlohmann::json& j)
{
  j["stamp"] = t.seconds();
}
void jsonOptionalString(const std::optional<std::string>& s, nlohmann::json& j)
{
    if (s.has_value())
    {
        j["value"] = *s;
    }
    else
    {
        j["value"] = "nullopt";
    }
}

However in 4.6 with the removal of adding custom converters in favor of the macro BT_JSON_CONVERTER I cannot figure out how to replicate this behavior and was wondering:

  1. Was this functionality removed? And was it removed on purpose?
  2. How I can recreate this in 4.6 if it was not removed?

I can only find examples of using the macro with simple structs. I have been reading through the code to try and figure this out, but have not made any progress yet so I figured I would reach out in case there is a simple solution.

Thank you for your time and for all the hard work on this!

Fixed