@@ -177,14 +177,15 @@ TEST(RotationShimControllerTest, rotationAndTransformTests)
177
177
std::string name = " PathFollower" ;
178
178
auto tf = std::make_shared<tf2_ros::Buffer>(node->get_clock ());
179
179
auto costmap = std::make_shared<nav2_costmap_2d::Costmap2DROS>(" fake_costmap" );
180
- rclcpp_lifecycle::State state;
181
- costmap->on_configure (state);
180
+ costmap->configure ();
182
181
183
182
// set a valid primary controller so we can do lifecycle
184
183
node->declare_parameter (
185
184
" PathFollower.primary_controller" ,
186
185
std::string (" nav2_regulated_pure_pursuit_controller::RegulatedPurePursuitController" ));
187
186
187
+ node->declare_parameter (" controller_frequency" , 1.0 );
188
+
188
189
auto controller = std::make_shared<RotationShimShim>();
189
190
controller->configure (node, name, tf, costmap);
190
191
controller->activate ();
@@ -193,8 +194,8 @@ TEST(RotationShimControllerTest, rotationAndTransformTests)
193
194
nav_msgs::msg::Path path;
194
195
path.header .frame_id = " fake_frame" ;
195
196
path.poses .resize (10 );
196
- path.poses [1 ].pose .position .x = 0.1 ;
197
- path.poses [1 ].pose .position .y = 0.1 ;
197
+ path.poses [1 ].pose .position .x = 0.15 ;
198
+ path.poses [1 ].pose .position .y = 0.15 ;
198
199
path.poses [2 ].pose .position .x = 1.0 ;
199
200
path.poses [2 ].pose .position .y = 1.0 ;
200
201
path.poses [3 ].pose .position .x = 10.0 ;
@@ -204,14 +205,14 @@ TEST(RotationShimControllerTest, rotationAndTransformTests)
204
205
const geometry_msgs::msg::Twist velocity;
205
206
EXPECT_EQ (
206
207
controller->computeRotateToHeadingCommandWrapper (
207
- 0.7 , path.poses [0 ], velocity).twist .angular .z , 1.8 );
208
+ 0.7 , path.poses [1 ], velocity).twist .angular .z , 1.8 );
208
209
EXPECT_EQ (
209
210
controller->computeRotateToHeadingCommandWrapper (
210
- -0.7 , path.poses [0 ], velocity).twist .angular .z , -1.8 );
211
+ -0.7 , path.poses [1 ], velocity).twist .angular .z , -1.8 );
211
212
212
213
EXPECT_EQ (
213
214
controller->computeRotateToHeadingCommandWrapper (
214
- 0.87 , path.poses [0 ], velocity).twist .angular .z , 1.8 );
215
+ 0.87 , path.poses [1 ], velocity).twist .angular .z , 1.8 );
215
216
216
217
// in base_link, so should pass through values without issue
217
218
geometry_msgs::msg::PoseStamped pt;
@@ -237,8 +238,9 @@ TEST(RotationShimControllerTest, computeVelocityTests)
237
238
auto tf = std::make_shared<tf2_ros::Buffer>(node->get_clock ());
238
239
auto listener = std::make_shared<tf2_ros::TransformListener>(*tf, node, true );
239
240
auto costmap = std::make_shared<nav2_costmap_2d::Costmap2DROS>(" fake_costmap" );
240
- rclcpp_lifecycle::State state;
241
- costmap->on_configure (state);
241
+ costmap->set_parameter (rclcpp::Parameter (" origin_x" , -25.0 ));
242
+ costmap->set_parameter (rclcpp::Parameter (" origin_y" , -25.0 ));
243
+ costmap->configure ();
242
244
auto tf_broadcaster = std::make_shared<tf2_ros::TransformBroadcaster>(node);
243
245
244
246
geometry_msgs::msg::TransformStamped transform;
@@ -254,6 +256,7 @@ TEST(RotationShimControllerTest, computeVelocityTests)
254
256
node->declare_parameter (
255
257
" PathFollower.primary_controller" ,
256
258
std::string (" nav2_regulated_pure_pursuit_controller::RegulatedPurePursuitController" ));
259
+ node->declare_parameter (" controller_frequency" , 1.0 );
257
260
258
261
auto controller = std::make_shared<RotationShimShim>();
259
262
controller->configure (node, name, tf, costmap);
@@ -308,7 +311,7 @@ TEST(RotationShimControllerTest, computeVelocityTests)
308
311
// this should allow it to find the sampled point, then transform to base_link
309
312
// validly because we setup the TF for it. The 1.0 should be selected since default min
310
313
// is 0.5 and that should cause a pass off to the RPP controller which will throw
311
- // and exception because the costmap is bogus
314
+ // and exception because it is off of the costmap
312
315
controller->setPlan (path);
313
316
tf_broadcaster->sendTransform (transform);
314
317
EXPECT_THROW (controller->computeVelocityCommands (pose, velocity, &checker), std::runtime_error);
0 commit comments