Skip to content

Commit 4bd7dcf

Browse files
committed
Update failing tests
Signed-off-by: mini-1235 <[email protected]>
1 parent 04a07e0 commit 4bd7dcf

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

nav2_rotation_shim_controller/test/test_shim_controller.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,15 @@ TEST(RotationShimControllerTest, rotationAndTransformTests)
177177
std::string name = "PathFollower";
178178
auto tf = std::make_shared<tf2_ros::Buffer>(node->get_clock());
179179
auto costmap = std::make_shared<nav2_costmap_2d::Costmap2DROS>("fake_costmap");
180-
rclcpp_lifecycle::State state;
181-
costmap->on_configure(state);
180+
costmap->configure();
182181

183182
// set a valid primary controller so we can do lifecycle
184183
node->declare_parameter(
185184
"PathFollower.primary_controller",
186185
std::string("nav2_regulated_pure_pursuit_controller::RegulatedPurePursuitController"));
187186

187+
node->declare_parameter("controller_frequency", 1.0);
188+
188189
auto controller = std::make_shared<RotationShimShim>();
189190
controller->configure(node, name, tf, costmap);
190191
controller->activate();
@@ -193,8 +194,8 @@ TEST(RotationShimControllerTest, rotationAndTransformTests)
193194
nav_msgs::msg::Path path;
194195
path.header.frame_id = "fake_frame";
195196
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;
198199
path.poses[2].pose.position.x = 1.0;
199200
path.poses[2].pose.position.y = 1.0;
200201
path.poses[3].pose.position.x = 10.0;
@@ -204,14 +205,14 @@ TEST(RotationShimControllerTest, rotationAndTransformTests)
204205
const geometry_msgs::msg::Twist velocity;
205206
EXPECT_EQ(
206207
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);
208209
EXPECT_EQ(
209210
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);
211212

212213
EXPECT_EQ(
213214
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);
215216

216217
// in base_link, so should pass through values without issue
217218
geometry_msgs::msg::PoseStamped pt;
@@ -237,8 +238,9 @@ TEST(RotationShimControllerTest, computeVelocityTests)
237238
auto tf = std::make_shared<tf2_ros::Buffer>(node->get_clock());
238239
auto listener = std::make_shared<tf2_ros::TransformListener>(*tf, node, true);
239240
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();
242244
auto tf_broadcaster = std::make_shared<tf2_ros::TransformBroadcaster>(node);
243245

244246
geometry_msgs::msg::TransformStamped transform;
@@ -254,6 +256,7 @@ TEST(RotationShimControllerTest, computeVelocityTests)
254256
node->declare_parameter(
255257
"PathFollower.primary_controller",
256258
std::string("nav2_regulated_pure_pursuit_controller::RegulatedPurePursuitController"));
259+
node->declare_parameter("controller_frequency", 1.0);
257260

258261
auto controller = std::make_shared<RotationShimShim>();
259262
controller->configure(node, name, tf, costmap);
@@ -308,7 +311,7 @@ TEST(RotationShimControllerTest, computeVelocityTests)
308311
// this should allow it to find the sampled point, then transform to base_link
309312
// validly because we setup the TF for it. The 1.0 should be selected since default min
310313
// 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
312315
controller->setPlan(path);
313316
tf_broadcaster->sendTransform(transform);
314317
EXPECT_THROW(controller->computeVelocityCommands(pose, velocity, &checker), std::runtime_error);

0 commit comments

Comments
 (0)