File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change 11
11
*/
12
12
13
13
// A custom struct that I want to visualize in Groot2
14
- struct Position2D {
14
+ struct Position2D
15
+ {
15
16
double x;
16
17
double y;
17
18
};
18
19
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()
19
24
BT_JSON_CONVERTER (Position2D, pos)
20
25
{
21
26
add_field (" x" , &pos.x );
Original file line number Diff line number Diff line change 1
1
#pragma once
2
2
3
+ #include " behaviortree_cpp/action_node.h"
3
4
#include " behaviortree_cpp/json_export.h"
4
- #include " behaviortree_cpp/behavior_tree.h"
5
5
6
6
// Custom type
7
7
struct Pose2D
8
8
{
9
- double x, y, theta;
9
+ double x, y, theta;
10
10
};
11
11
12
- // Use this to register this function into JsonExporter:
12
+ // Add this to you main() to register this function into JsonExporter:
13
13
//
14
14
// 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 );
19
21
}
20
22
21
23
You can’t perform that action at this time.
0 commit comments