Skip to content

Commit

Permalink
added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Feb 29, 2024
1 parent fefd16b commit 851c7a0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
7 changes: 6 additions & 1 deletion examples/t12_groot_howto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@
*/

// A custom struct that I want to visualize in Groot2
struct Position2D {
struct Position2D
{
double x;
double y;
};

// This macro will generate the code that is needed to convert
// the object to/from JSON.
// You still need to call BT::RegisterJsonDefinition<Position2D>()
// in main()
BT_JSON_CONVERTER(Position2D, pos)
{
add_field("x", &pos.x);
Expand Down
16 changes: 9 additions & 7 deletions sample_nodes/movebase_node.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
#pragma once

#include "behaviortree_cpp/action_node.h"
#include "behaviortree_cpp/json_export.h"
#include "behaviortree_cpp/behavior_tree.h"

// Custom type
struct Pose2D
{
double x, y, theta;
double x, y, theta;
};

// Use this to register this function into JsonExporter:
// Add this to you main() to register this function into JsonExporter:
//
// BT::JsonExporter::get().addConverter<Pose2D>();
inline void to_json(nlohmann::json& dest, const Pose2D& pose) {
dest["x"] = pose.x;
dest["y"] = pose.y;
dest["theta"] = pose.theta;

BT_JSON_CONVERTER(Pose2D, pose)
{
add_field("x", &pose.x);
add_field("y", &pose.y);
add_field("theta", &pose.theta);
}


Expand Down

0 comments on commit 851c7a0

Please sign in to comment.