@@ -88,26 +88,29 @@ TEST_F(GoalUpdaterTestFixture, test_tick)
88
88
R"(
89
89
<root BTCPP_format="4">
90
90
<BehaviorTree ID="MainTree">
91
- <GoalUpdater input_goal="{goal}" output_goal="{updated_goal}">
91
+ <GoalUpdater input_goal="{goal}" input_goals="{goals}" output_goal="{updated_goal}" output_goals="{updated_goals }">
92
92
<AlwaysSuccess/>
93
93
</GoalUpdater>
94
94
</BehaviorTree>
95
95
</root>)" ;
96
96
97
97
tree_ = std::make_shared<BT::Tree>(factory_->createTreeFromText (xml_txt, config_->blackboard ));
98
- auto goal_updater_pub =
99
- node_->create_publisher <geometry_msgs::msg::PoseStamped>(" goal_update" , 10 );
100
98
101
99
// create new goal and set it on blackboard
102
100
geometry_msgs::msg::PoseStamped goal;
101
+ geometry_msgs::msg::PoseStampedArray goals;
103
102
goal.header .stamp = node_->now ();
104
103
goal.pose .position .x = 1.0 ;
104
+ goals.poses .push_back (goal);
105
105
config_->blackboard ->set (" goal" , goal);
106
+ config_->blackboard ->set (" goals" , goals);
106
107
107
108
// tick tree without publishing updated goal and get updated_goal
108
109
tree_->rootNode ()->executeTick ();
109
110
geometry_msgs::msg::PoseStamped updated_goal;
111
+ geometry_msgs::msg::PoseStampedArray updated_goals;
110
112
EXPECT_TRUE (config_->blackboard ->get (" updated_goal" , updated_goal));
113
+ EXPECT_TRUE (config_->blackboard ->get (" updated_goals" , updated_goals));
111
114
}
112
115
113
116
TEST_F (GoalUpdaterTestFixture, test_older_goal_update)
@@ -117,7 +120,7 @@ TEST_F(GoalUpdaterTestFixture, test_older_goal_update)
117
120
R"(
118
121
<root BTCPP_format="4">
119
122
<BehaviorTree ID="MainTree">
120
- <GoalUpdater input_goal="{goal}" output_goal="{updated_goal}">
123
+ <GoalUpdater input_goal="{goal}" input_goals="{goals}" output_goal="{updated_goal}" output_goals="{updated_goals }">
121
124
<AlwaysSuccess/>
122
125
</GoalUpdater>
123
126
</BehaviorTree>
@@ -126,26 +129,39 @@ TEST_F(GoalUpdaterTestFixture, test_older_goal_update)
126
129
tree_ = std::make_shared<BT::Tree>(factory_->createTreeFromText (xml_txt, config_->blackboard ));
127
130
auto goal_updater_pub =
128
131
node_->create_publisher <geometry_msgs::msg::PoseStamped>(" goal_update" , 10 );
132
+ auto goals_updater_pub =
133
+ node_->create_publisher <geometry_msgs::msg::PoseStampedArray>(" goals_update" , 10 );
129
134
130
135
// create new goal and set it on blackboard
131
136
geometry_msgs::msg::PoseStamped goal;
137
+ geometry_msgs::msg::PoseStampedArray goals;
132
138
goal.header .stamp = node_->now ();
133
139
goal.pose .position .x = 1.0 ;
140
+ goals.header .stamp = goal.header .stamp ;
141
+ goals.poses .push_back (goal);
134
142
config_->blackboard ->set (" goal" , goal);
143
+ config_->blackboard ->set (" goals" , goals);
135
144
136
145
// publish updated_goal older than goal
137
146
geometry_msgs::msg::PoseStamped goal_to_update;
147
+ geometry_msgs::msg::PoseStampedArray goals_to_update;
138
148
goal_to_update.header .stamp = rclcpp::Time (goal.header .stamp ) - rclcpp::Duration (1 , 0 );
139
149
goal_to_update.pose .position .x = 2.0 ;
150
+ goals_to_update.header .stamp = goal_to_update.header .stamp ;
151
+ goals_to_update.poses .push_back (goal_to_update);
140
152
141
153
goal_updater_pub->publish (goal_to_update);
154
+ goals_updater_pub->publish (goals_to_update);
142
155
tree_->rootNode ()->executeTick ();
143
156
geometry_msgs::msg::PoseStamped updated_goal;
157
+ geometry_msgs::msg::PoseStampedArray updated_goals;
144
158
EXPECT_TRUE (config_->blackboard ->get (" updated_goal" , updated_goal));
159
+ EXPECT_TRUE (config_->blackboard ->get (" updated_goals" , updated_goals));
145
160
146
161
// expect to succeed and not update goal
147
162
EXPECT_EQ (tree_->rootNode ()->status (), BT::NodeStatus::SUCCESS);
148
163
EXPECT_EQ (updated_goal, goal);
164
+ EXPECT_EQ (updated_goals, goals);
149
165
}
150
166
151
167
TEST_F (GoalUpdaterTestFixture, test_get_latest_goal_update)
@@ -155,7 +171,7 @@ TEST_F(GoalUpdaterTestFixture, test_get_latest_goal_update)
155
171
R"(
156
172
<root BTCPP_format="4">
157
173
<BehaviorTree ID="MainTree">
158
- <GoalUpdater input_goal="{goal}" output_goal="{updated_goal}">
174
+ <GoalUpdater input_goal="{goal}" input_goals="{goals}" output_goal="{updated_goal}" output_goals="{updated_goals }">
159
175
<AlwaysSuccess/>
160
176
</GoalUpdater>
161
177
</BehaviorTree>
@@ -164,32 +180,48 @@ TEST_F(GoalUpdaterTestFixture, test_get_latest_goal_update)
164
180
tree_ = std::make_shared<BT::Tree>(factory_->createTreeFromText (xml_txt, config_->blackboard ));
165
181
auto goal_updater_pub =
166
182
node_->create_publisher <geometry_msgs::msg::PoseStamped>(" goal_update" , 10 );
183
+ auto goals_updater_pub =
184
+ node_->create_publisher <geometry_msgs::msg::PoseStampedArray>(" goals_update" , 10 );
167
185
168
186
// create new goal and set it on blackboard
169
187
geometry_msgs::msg::PoseStamped goal;
188
+ geometry_msgs::msg::PoseStampedArray goals;
170
189
goal.header .stamp = node_->now ();
171
190
goal.pose .position .x = 1.0 ;
191
+ goals.poses .push_back (goal);
172
192
config_->blackboard ->set (" goal" , goal);
193
+ config_->blackboard ->set (" goals" , goals);
173
194
174
195
// publish updated_goal older than goal
175
196
geometry_msgs::msg::PoseStamped goal_to_update_1;
197
+ geometry_msgs::msg::PoseStampedArray goals_to_update_1;
176
198
goal_to_update_1.header .stamp = node_->now ();
177
199
goal_to_update_1.pose .position .x = 2.0 ;
200
+ goals_to_update_1.header .stamp = goal_to_update_1.header .stamp ;
201
+ goals_to_update_1.poses .push_back (goal_to_update_1);
178
202
179
203
geometry_msgs::msg::PoseStamped goal_to_update_2;
204
+ geometry_msgs::msg::PoseStampedArray goals_to_update_2;
180
205
goal_to_update_2.header .stamp = node_->now ();
181
206
goal_to_update_2.pose .position .x = 3.0 ;
207
+ goals_to_update_2.header .stamp = goal_to_update_2.header .stamp ;
208
+ goals_to_update_2.poses .push_back (goal_to_update_2);
182
209
183
210
goal_updater_pub->publish (goal_to_update_1);
211
+ goals_updater_pub->publish (goals_to_update_1);
184
212
goal_updater_pub->publish (goal_to_update_2);
213
+ goals_updater_pub->publish (goals_to_update_2);
185
214
tree_->rootNode ()->executeTick ();
186
215
geometry_msgs::msg::PoseStamped updated_goal;
216
+ geometry_msgs::msg::PoseStampedArray updated_goals;
187
217
EXPECT_TRUE (config_->blackboard ->get (" updated_goal" , updated_goal));
218
+ EXPECT_TRUE (config_->blackboard ->get (" updated_goals" , updated_goals));
188
219
189
220
// expect to succeed
190
221
EXPECT_EQ (tree_->rootNode ()->status (), BT::NodeStatus::SUCCESS);
191
222
// expect to update goal with latest goal update
192
223
EXPECT_EQ (updated_goal, goal_to_update_2);
224
+ EXPECT_EQ (updated_goals, goals_to_update_2);
193
225
}
194
226
195
227
int main (int argc, char ** argv)
0 commit comments