Skip to content

Commit 851c7a0

Browse files
committed
added comments
1 parent fefd16b commit 851c7a0

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

examples/t12_groot_howto.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@
1111
*/
1212

1313
// A custom struct that I want to visualize in Groot2
14-
struct Position2D {
14+
struct Position2D
15+
{
1516
double x;
1617
double y;
1718
};
1819

20+
// This macro will generate the code that is needed to convert
21+
// the object to/from JSON.
22+
// You still need to call BT::RegisterJsonDefinition<Position2D>()
23+
// in main()
1924
BT_JSON_CONVERTER(Position2D, pos)
2025
{
2126
add_field("x", &pos.x);

sample_nodes/movebase_node.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
#pragma once
22

3+
#include "behaviortree_cpp/action_node.h"
34
#include "behaviortree_cpp/json_export.h"
4-
#include "behaviortree_cpp/behavior_tree.h"
55

66
// Custom type
77
struct Pose2D
88
{
9-
double x, y, theta;
9+
double x, y, theta;
1010
};
1111

12-
// Use this to register this function into JsonExporter:
12+
// Add this to you main() to register this function into JsonExporter:
1313
//
1414
// BT::JsonExporter::get().addConverter<Pose2D>();
15-
inline void to_json(nlohmann::json& dest, const Pose2D& pose) {
16-
dest["x"] = pose.x;
17-
dest["y"] = pose.y;
18-
dest["theta"] = pose.theta;
15+
16+
BT_JSON_CONVERTER(Pose2D, pose)
17+
{
18+
add_field("x", &pose.x);
19+
add_field("y", &pose.y);
20+
add_field("theta", &pose.theta);
1921
}
2022

2123

0 commit comments

Comments
 (0)