@@ -175,6 +175,15 @@ class TestDiffDriveController : public ::testing::Test
175175 controller_->assign_interfaces (std::move (command_ifs), std::move (state_ifs));
176176 }
177177
178+ void assignResourcesNoFeedback ()
179+ {
180+ std::vector<LoanedCommandInterface> command_ifs;
181+ command_ifs.emplace_back (left_wheel_vel_cmd_);
182+ command_ifs.emplace_back (right_wheel_vel_cmd_);
183+
184+ controller_->assign_interfaces (std::move (command_ifs), {});
185+ }
186+
178187 controller_interface::return_type InitController (
179188 const std::vector<std::string> left_wheel_joints_init = left_wheel_names,
180189 const std::vector<std::string> right_wheel_joints_init = right_wheel_names,
@@ -262,6 +271,26 @@ TEST_F(
262271 EXPECT_EQ (cmd_if_conf.type , controller_interface::interface_configuration_type::INDIVIDUAL);
263272}
264273
274+ TEST_F (
275+ TestDiffDriveController,
276+ command_and_state_interface_configuration_succeeds_when_wheels_and_open_loop_are_specified)
277+ {
278+ ASSERT_EQ (
279+ InitController (
280+ left_wheel_names, right_wheel_names,
281+ {rclcpp::Parameter (" open_loop" , rclcpp::ParameterValue (true ))}),
282+ controller_interface::return_type::OK);
283+
284+ ASSERT_EQ (controller_->on_configure (rclcpp_lifecycle::State ()), CallbackReturn::SUCCESS);
285+
286+ auto state_if_conf = controller_->state_interface_configuration ();
287+ ASSERT_THAT (state_if_conf.names , SizeIs (0 ));
288+ EXPECT_EQ (state_if_conf.type , controller_interface::interface_configuration_type::NONE);
289+ auto cmd_if_conf = controller_->command_interface_configuration ();
290+ ASSERT_THAT (cmd_if_conf.names , SizeIs (left_wheel_names.size () + right_wheel_names.size ()));
291+ EXPECT_EQ (cmd_if_conf.type , controller_interface::interface_configuration_type::INDIVIDUAL);
292+ }
293+
265294TEST_F (TestDiffDriveController, configure_succeeds_tf_test_prefix_false_no_namespace)
266295{
267296 std::string odom_id = " odom" ;
@@ -458,6 +487,19 @@ TEST_F(TestDiffDriveController, activate_succeeds_with_vel_resources_assigned)
458487 ASSERT_EQ (controller_->on_activate (rclcpp_lifecycle::State ()), CallbackReturn::SUCCESS);
459488}
460489
490+ TEST_F (TestDiffDriveController, activate_succeeds_with_open_loop_assigned)
491+ {
492+ ASSERT_EQ (
493+ InitController (
494+ left_wheel_names, right_wheel_names,
495+ {rclcpp::Parameter (" open_loop" , rclcpp::ParameterValue (true ))}),
496+ controller_interface::return_type::OK);
497+
498+ ASSERT_EQ (controller_->on_configure (rclcpp_lifecycle::State ()), CallbackReturn::SUCCESS);
499+ assignResourcesNoFeedback ();
500+ ASSERT_EQ (controller_->on_activate (rclcpp_lifecycle::State ()), CallbackReturn::SUCCESS);
501+ }
502+
461503TEST_F (TestDiffDriveController, test_speed_limiter)
462504{
463505 // If you send a linear velocity command without acceleration limits,
@@ -690,6 +732,34 @@ TEST_F(TestDiffDriveController, activate_fails_with_wrong_resources_assigned_2)
690732 ASSERT_EQ (controller_->on_activate (rclcpp_lifecycle::State ()), CallbackReturn::ERROR);
691733}
692734
735+ TEST_F (TestDiffDriveController, activate_silently_ignores_with_unnecessary_resources_assigned_1)
736+ {
737+ ASSERT_EQ (
738+ InitController (
739+ left_wheel_names, right_wheel_names,
740+ {rclcpp::Parameter (" open_loop" , rclcpp::ParameterValue (true )),
741+ rclcpp::Parameter (" position_feedback" , rclcpp::ParameterValue (false ))}),
742+ controller_interface::return_type::OK);
743+
744+ ASSERT_EQ (controller_->on_configure (rclcpp_lifecycle::State ()), CallbackReturn::SUCCESS);
745+ assignResourcesPosFeedback ();
746+ ASSERT_EQ (controller_->on_activate (rclcpp_lifecycle::State ()), CallbackReturn::SUCCESS);
747+ }
748+
749+ TEST_F (TestDiffDriveController, activate_silently_ignores_with_unnecessary_resources_assigned_2)
750+ {
751+ ASSERT_EQ (
752+ InitController (
753+ left_wheel_names, right_wheel_names,
754+ {rclcpp::Parameter (" open_loop" , rclcpp::ParameterValue (true )),
755+ rclcpp::Parameter (" position_feedback" , rclcpp::ParameterValue (true ))}),
756+ controller_interface::return_type::OK);
757+
758+ ASSERT_EQ (controller_->on_configure (rclcpp_lifecycle::State ()), CallbackReturn::SUCCESS);
759+ assignResourcesVelFeedback ();
760+ ASSERT_EQ (controller_->on_activate (rclcpp_lifecycle::State ()), CallbackReturn::SUCCESS);
761+ }
762+
693763TEST_F (TestDiffDriveController, cleanup)
694764{
695765 ASSERT_EQ (
0 commit comments