Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes tests to work with use_global_arguments NodeOptions parameter #1256

Merged
6 changes: 2 additions & 4 deletions ackermann_steering_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ if(BUILD_TESTING)
find_package(ros2_control_test_assets REQUIRED)


add_rostest_with_parameters_gmock(test_load_ackermann_steering_controller
test/test_load_ackermann_steering_controller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/ackermann_steering_controller_params.yaml
)
add_definitions(-DTEST_FILES_DIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}/test")
ament_add_gmock(test_load_ackermann_steering_controller test/test_load_ackermann_steering_controller.cpp)
ament_target_dependencies(test_load_ackermann_steering_controller
controller_manager
hardware_interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ TEST(TestLoadAckermannSteeringController, load_controller)

controller_manager::ControllerManager cm(
executor, ros2_control_test_assets::minimal_robot_urdf, true, "test_controller_manager");
const std::string test_file_path =
std::string(TEST_FILES_DIRECTORY) + "/ackermann_steering_controller_params.yaml";

ASSERT_NE(
cm.load_controller(
"test_ackermann_steering_controller",
"ackermann_steering_controller/AckermannSteeringController"),
nullptr);
cm.set_parameter({"test_ackermann_steering_controller.params_file", test_file_path});
cm.set_parameter(
{"test_ackermann_steering_controller.type",
"ackermann_steering_controller/AckermannSteeringController"});

ASSERT_NE(cm.load_controller("test_ackermann_steering_controller"), nullptr);
}

int main(int argc, char ** argv)
Expand Down
6 changes: 2 additions & 4 deletions admittance_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ if(BUILD_TESTING)
find_package(kinematics_interface_kdl REQUIRED)

# test loading admittance controller
add_rostest_with_parameters_gmock(test_load_admittance_controller
test/test_load_admittance_controller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/test_params.yaml
)
add_definitions(-DTEST_FILES_DIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}/test")
ament_add_gmock(test_load_admittance_controller test/test_load_admittance_controller.cpp)
ament_target_dependencies(test_load_admittance_controller
controller_manager
hardware_interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ TEST(TestLoadAdmittanceController, load_controller)

controller_manager::ControllerManager cm(
executor, ros2_control_test_assets::minimal_robot_urdf, true, "test_controller_manager");
const std::string test_file_path = std::string(TEST_FILES_DIRECTORY) + "/test_params.yaml";

ASSERT_EQ(
cm.load_controller("load_admittance_controller", "admittance_controller/AdmittanceController"),
nullptr);
cm.set_parameter({"load_admittance_controller.params_file", test_file_path});
cm.set_parameter(
{"load_admittance_controller.type", "admittance_controller/AdmittanceController"});

ASSERT_EQ(cm.load_controller("load_admittance_controller"), nullptr);
}

int main(int argc, char ** argv)
Expand Down
6 changes: 2 additions & 4 deletions bicycle_steering_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ if(BUILD_TESTING)
find_package(hardware_interface REQUIRED)
find_package(ros2_control_test_assets REQUIRED)

add_rostest_with_parameters_gmock(test_load_bicycle_steering_controller
test/test_load_bicycle_steering_controller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/bicycle_steering_controller_params.yaml
)
add_definitions(-DTEST_FILES_DIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}/test")
ament_add_gmock(test_load_bicycle_steering_controller test/test_load_bicycle_steering_controller.cpp)
ament_target_dependencies(test_load_bicycle_steering_controller
controller_manager
hardware_interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ TEST(TestLoadBicycleSteeringController, load_controller)

controller_manager::ControllerManager cm(
executor, ros2_control_test_assets::minimal_robot_urdf, true, "test_controller_manager");
const std::string test_file_path =
std::string(TEST_FILES_DIRECTORY) + "/bicycle_steering_controller_params.yaml";

ASSERT_NE(
cm.load_controller(
"test_bicycle_steering_controller", "bicycle_steering_controller/BicycleSteeringController"),
nullptr);
cm.set_parameter({"test_bicycle_steering_controller.params_file", test_file_path});
cm.set_parameter(
{"test_bicycle_steering_controller.type",
"bicycle_steering_controller/BicycleSteeringController"});

ASSERT_NE(cm.load_controller("test_bicycle_steering_controller"), nullptr);
}

int main(int argc, char ** argv)
Expand Down
6 changes: 2 additions & 4 deletions diff_drive_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ if(BUILD_TESTING)
tf2_msgs
)

add_rostest_with_parameters_gmock(test_load_diff_drive_controller
test/test_load_diff_drive_controller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/config/test_diff_drive_controller.yaml
)
add_definitions(-DTEST_FILES_DIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}/test")
ament_add_gmock(test_load_diff_drive_controller test/test_load_diff_drive_controller.cpp)
ament_target_dependencies(test_load_diff_drive_controller
controller_manager
ros2_control_test_assets
Expand Down
10 changes: 7 additions & 3 deletions diff_drive_controller/test/test_load_diff_drive_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ TEST(TestLoadDiffDriveController, load_controller)

controller_manager::ControllerManager cm(
executor, ros2_control_test_assets::diffbot_urdf, true, "test_controller_manager");
const std::string test_file_path =
std::string(TEST_FILES_DIRECTORY) + "/config/test_diff_drive_controller.yaml";

ASSERT_NE(
cm.load_controller("test_diff_drive_controller", "diff_drive_controller/DiffDriveController"),
nullptr);
cm.set_parameter({"test_diff_drive_controller.params_file", test_file_path});
cm.set_parameter(
{"test_diff_drive_controller.type", "diff_drive_controller/DiffDriveController"});

ASSERT_NE(cm.load_controller("test_diff_drive_controller"), nullptr);
}

int main(int argc, char ** argv)
Expand Down
5 changes: 2 additions & 3 deletions force_torque_sensor_broadcaster/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ if(BUILD_TESTING)
find_package(hardware_interface REQUIRED)
find_package(ros2_control_test_assets REQUIRED)

add_rostest_with_parameters_gmock(test_load_force_torque_sensor_broadcaster
test/test_load_force_torque_sensor_broadcaster.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/force_torque_sensor_broadcaster_params.yaml)
add_definitions(-DTEST_FILES_DIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}/test")
ament_add_gmock(test_load_force_torque_sensor_broadcaster test/test_load_force_torque_sensor_broadcaster.cpp)
target_include_directories(test_load_force_torque_sensor_broadcaster PRIVATE include)
target_link_libraries(test_load_force_torque_sensor_broadcaster
force_torque_sensor_broadcaster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ TEST(TestLoadForceTorqueSensorBroadcaster, load_controller)
controller_manager::ControllerManager cm(
executor, ros2_control_test_assets::minimal_robot_urdf, true, "test_controller_manager");

ASSERT_NE(
cm.load_controller(
"test_force_torque_sensor_broadcaster",
"force_torque_sensor_broadcaster/ForceTorqueSensorBroadcaster"),
nullptr);
const std::string test_file_path =
std::string(TEST_FILES_DIRECTORY) + "/force_torque_sensor_broadcaster_params.yaml";

cm.set_parameter({"test_force_torque_sensor_broadcaster.params_file", test_file_path});
cm.set_parameter(
{"test_force_torque_sensor_broadcaster.type",
"force_torque_sensor_broadcaster/ForceTorqueSensorBroadcaster"});

ASSERT_NE(cm.load_controller("test_force_torque_sensor_broadcaster"), nullptr);
}

int main(int argc, char ** argv)
Expand Down
5 changes: 2 additions & 3 deletions imu_sensor_broadcaster/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,8 @@ if(BUILD_TESTING)
find_package(hardware_interface REQUIRED)
find_package(ros2_control_test_assets REQUIRED)

add_rostest_with_parameters_gmock(test_load_imu_sensor_broadcaster
test/test_load_imu_sensor_broadcaster.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/imu_sensor_broadcaster_params.yaml)
add_definitions(-DTEST_FILES_DIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}/test")
ament_add_gmock(test_load_imu_sensor_broadcaster test/test_load_imu_sensor_broadcaster.cpp)
target_include_directories(test_load_imu_sensor_broadcaster PRIVATE include)
target_link_libraries(test_load_imu_sensor_broadcaster
imu_sensor_broadcaster
Expand Down
11 changes: 7 additions & 4 deletions imu_sensor_broadcaster/test/test_load_imu_sensor_broadcaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ TEST(TestLoadIMUSensorBroadcaster, load_controller)

controller_manager::ControllerManager cm(
executor, ros2_control_test_assets::minimal_robot_urdf, true, "test_controller_manager");
const std::string test_file_path =
std::string(TEST_FILES_DIRECTORY) + "/imu_sensor_broadcaster_params.yaml";

ASSERT_NE(
cm.load_controller(
"test_imu_sensor_broadcaster", "imu_sensor_broadcaster/IMUSensorBroadcaster"),
nullptr);
cm.set_parameter({"test_imu_sensor_broadcaster.params_file", test_file_path});
cm.set_parameter(
{"test_imu_sensor_broadcaster.type", "imu_sensor_broadcaster/IMUSensorBroadcaster"});

ASSERT_NE(cm.load_controller("test_imu_sensor_broadcaster"), nullptr);
}

int main(int argc, char ** argv)
Expand Down
5 changes: 2 additions & 3 deletions parallel_gripper_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ if(BUILD_TESTING)
find_package(controller_manager REQUIRED)
find_package(ros2_control_test_assets REQUIRED)

add_rostest_with_parameters_gmock(test_load_parallel_gripper_action_controllers
test/test_load_parallel_gripper_action_controller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/gripper_action_controller_params.yaml)
add_definitions(-DTEST_FILES_DIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}/test")
ament_add_gmock(test_load_parallel_gripper_action_controllers test/test_load_parallel_gripper_action_controller.cpp)
target_include_directories(test_load_parallel_gripper_action_controllers PRIVATE include)
ament_target_dependencies(test_load_parallel_gripper_action_controllers
controller_manager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ TEST(TestLoadGripperActionControllers, load_controller)

controller_manager::ControllerManager cm(
executor, ros2_control_test_assets::minimal_robot_urdf, true, "test_controller_manager");
const std::string test_file_path =
std::string(TEST_FILES_DIRECTORY) + "/gripper_action_controller_params.yaml";

ASSERT_NE(
cm.load_controller(
"test_gripper_action_position_controller",
"parallel_gripper_action_controller/GripperActionController"),
nullptr);
cm.set_parameter({"test_gripper_action_position_controller.params_file", test_file_path});
cm.set_parameter(
{"test_gripper_action_position_controller.type",
"parallel_gripper_action_controller/GripperActionController"});

ASSERT_NE(cm.load_controller("test_gripper_action_position_controller"), nullptr);
}

int main(int argc, char ** argv)
Expand Down
5 changes: 2 additions & 3 deletions range_sensor_broadcaster/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ if(BUILD_TESTING)
find_package(hardware_interface REQUIRED)
find_package(ros2_control_test_assets REQUIRED)

add_rostest_with_parameters_gmock(test_load_range_sensor_broadcaster
test/test_load_range_sensor_broadcaster.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/range_sensor_broadcaster_params.yaml)
add_definitions(-DTEST_FILES_DIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}/test")
ament_add_gmock(test_load_range_sensor_broadcaster test/test_load_range_sensor_broadcaster.cpp)
target_include_directories(test_load_range_sensor_broadcaster PRIVATE include)
target_link_libraries(test_load_range_sensor_broadcaster
range_sensor_broadcaster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ TEST(TestLoadRangeSensorBroadcaster, load_controller)

controller_manager::ControllerManager cm(
executor, ros2_control_test_assets::minimal_robot_urdf, true, "test_controller_manager");
const std::string test_file_path =
std::string(TEST_FILES_DIRECTORY) + "/range_sensor_broadcaster_params.yaml";

ASSERT_NE(
cm.load_controller(
"test_range_sensor_broadcaster", "range_sensor_broadcaster/RangeSensorBroadcaster"),
nullptr);
cm.set_parameter({"test_range_sensor_broadcaster.params_file", test_file_path});
cm.set_parameter(
{"test_range_sensor_broadcaster.type", "range_sensor_broadcaster/RangeSensorBroadcaster"});

ASSERT_NE(cm.load_controller("test_range_sensor_broadcaster"), nullptr);
}

int main(int argc, char ** argv)
Expand Down
6 changes: 2 additions & 4 deletions tricycle_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@ if(BUILD_TESTING)
tf2_msgs
)

add_rostest_with_parameters_gmock(test_load_tricycle_controller
test/test_load_tricycle_controller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/config/test_tricycle_controller.yaml
)
add_definitions(-DTEST_FILES_DIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}/test")
ament_add_gmock(test_load_tricycle_controller test/test_load_tricycle_controller.cpp)
target_link_libraries(test_load_tricycle_controller
tricycle_controller
)
Expand Down
9 changes: 6 additions & 3 deletions tricycle_controller/test/test_load_tricycle_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ TEST(TestLoadTricycleController, load_controller)

controller_manager::ControllerManager cm(
executor, ros2_control_test_assets::minimal_robot_urdf, true, "test_controller_manager");
const std::string test_file_path =
std::string(TEST_FILES_DIRECTORY) + "/config/test_tricycle_controller.yaml";

ASSERT_NE(
cm.load_controller("test_tricycle_controller", "tricycle_controller/TricycleController"),
nullptr);
cm.set_parameter({"test_tricycle_controller.params_file", test_file_path});
cm.set_parameter({"test_tricycle_controller.type", "tricycle_controller/TricycleController"});

ASSERT_NE(cm.load_controller("test_tricycle_controller"), nullptr);
}

int main(int argc, char ** argv)
Expand Down
6 changes: 2 additions & 4 deletions tricycle_steering_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ if(BUILD_TESTING)
find_package(hardware_interface REQUIRED)
find_package(ros2_control_test_assets REQUIRED)

add_rostest_with_parameters_gmock(test_load_tricycle_steering_controller
test/test_load_tricycle_steering_controller.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/tricycle_steering_controller_params.yaml
)
add_definitions(-DTEST_FILES_DIRECTORY="${CMAKE_CURRENT_SOURCE_DIR}/test")
ament_add_gmock(test_load_tricycle_steering_controller test/test_load_tricycle_steering_controller.cpp)
ament_target_dependencies(test_load_tricycle_steering_controller
controller_manager
hardware_interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ TEST(TestLoadTricycleSteeringController, load_controller)

controller_manager::ControllerManager cm(
executor, ros2_control_test_assets::minimal_robot_urdf, true, "test_controller_manager");
const std::string test_file_path =
std::string(TEST_FILES_DIRECTORY) + "/tricycle_steering_controller_params.yaml";

ASSERT_NE(
cm.load_controller(
"test_tricycle_steering_controller",
"tricycle_steering_controller/TricycleSteeringController"),
nullptr);
cm.set_parameter({"test_tricycle_steering_controller.params_file", test_file_path});
cm.set_parameter(
{"test_tricycle_steering_controller.type",
"tricycle_steering_controller/TricycleSteeringController"});

ASSERT_NE(cm.load_controller("test_tricycle_steering_controller"), nullptr);
}

int main(int argc, char ** argv)
Expand Down
Loading