From 6267de979949c1cd05ed6431f5d0a04355da995a Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Fri, 3 Jan 2025 22:51:43 +0000 Subject: [PATCH 1/7] diff_drive --- .../test/test_diff_drive_controller.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/diff_drive_controller/test/test_diff_drive_controller.cpp b/diff_drive_controller/test/test_diff_drive_controller.cpp index f2fc671920..a7493699fd 100644 --- a/diff_drive_controller/test/test_diff_drive_controller.cpp +++ b/diff_drive_controller/test/test_diff_drive_controller.cpp @@ -85,7 +85,9 @@ class TestableDiffDriveController : public diff_drive_controller::DiffDriveContr class TestDiffDriveController : public ::testing::Test { protected: - void SetUp() override + static void SetUpTestCase() {} + + void SetUp() { // use the name of the test as the controller name (i.e, the node name) to be able to set // parameters from yaml for each test @@ -97,7 +99,13 @@ class TestDiffDriveController : public ::testing::Test controller_name + "/cmd_vel", rclcpp::SystemDefaultsQoS()); } - static void TearDownTestCase() { rclcpp::shutdown(); } + void TearDown() + { + controller_->get_node()->shutdown(); + controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition + } + + static void TearDownTestCase() {} /// Publish velocity msgs /** From 267f17a128d7c1a02ef88117e898f881544a0ac2 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Fri, 3 Jan 2025 23:01:25 +0000 Subject: [PATCH 2/7] Steering controllers --- .../test/test_ackermann_steering_controller.hpp | 8 ++++++-- .../test/test_bicycle_steering_controller.hpp | 8 ++++++-- .../test/test_steering_controllers_library.hpp | 8 ++++++-- .../test/test_tricycle_steering_controller.hpp | 8 ++++++-- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ackermann_steering_controller/test/test_ackermann_steering_controller.hpp b/ackermann_steering_controller/test/test_ackermann_steering_controller.hpp index 2e7d688471..8954ca1432 100644 --- a/ackermann_steering_controller/test/test_ackermann_steering_controller.hpp +++ b/ackermann_steering_controller/test/test_ackermann_steering_controller.hpp @@ -126,9 +126,13 @@ class AckermannSteeringControllerFixture : public ::testing::Test "/test_ackermann_steering_controller/reference", rclcpp::SystemDefaultsQoS()); } - static void TearDownTestCase() {} + void TearDown() + { + controller_->get_node()->shutdown(); + controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition + } - void TearDown() { controller_.reset(nullptr); } + static void TearDownTestCase() {} protected: void SetUpController(const std::string controller_name = "test_ackermann_steering_controller") diff --git a/bicycle_steering_controller/test/test_bicycle_steering_controller.hpp b/bicycle_steering_controller/test/test_bicycle_steering_controller.hpp index 25fec7fdf1..9efa4032f9 100644 --- a/bicycle_steering_controller/test/test_bicycle_steering_controller.hpp +++ b/bicycle_steering_controller/test/test_bicycle_steering_controller.hpp @@ -124,9 +124,13 @@ class BicycleSteeringControllerFixture : public ::testing::Test "/test_bicycle_steering_controller/reference", rclcpp::SystemDefaultsQoS()); } - static void TearDownTestCase() {} + void TearDown() + { + controller_->get_node()->shutdown(); + controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition + } - void TearDown() { controller_.reset(nullptr); } + static void TearDownTestCase() {} protected: void SetUpController(const std::string controller_name = "test_bicycle_steering_controller") diff --git a/steering_controllers_library/test/test_steering_controllers_library.hpp b/steering_controllers_library/test/test_steering_controllers_library.hpp index 20d136ab32..355a513699 100644 --- a/steering_controllers_library/test/test_steering_controllers_library.hpp +++ b/steering_controllers_library/test/test_steering_controllers_library.hpp @@ -147,9 +147,13 @@ class SteeringControllersLibraryFixture : public ::testing::Test "/test_steering_controllers_library/reference", rclcpp::SystemDefaultsQoS()); } - static void TearDownTestCase() {} + void TearDown() + { + controller_->get_node()->shutdown(); + controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition + } - void TearDown() { controller_.reset(nullptr); } + static void TearDownTestCase() {} protected: void SetUpController(const std::string controller_name = "test_steering_controllers_library") diff --git a/tricycle_steering_controller/test/test_tricycle_steering_controller.hpp b/tricycle_steering_controller/test/test_tricycle_steering_controller.hpp index cfecf96cc8..1f88880494 100644 --- a/tricycle_steering_controller/test/test_tricycle_steering_controller.hpp +++ b/tricycle_steering_controller/test/test_tricycle_steering_controller.hpp @@ -125,9 +125,13 @@ class TricycleSteeringControllerFixture : public ::testing::Test "/test_tricycle_steering_controller/reference", rclcpp::SystemDefaultsQoS()); } - static void TearDownTestCase() {} + void TearDown() + { + controller_->get_node()->shutdown(); + controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition + } - void TearDown() { controller_.reset(nullptr); } + static void TearDownTestCase() {} protected: void SetUpController(const std::string controller_name = "test_tricycle_steering_controller") From 8c5cc186b96198e7844f39f44b80b64aff3cabe4 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Fri, 3 Jan 2025 23:08:29 +0000 Subject: [PATCH 3/7] Other mobile controllers --- .../test/test_mecanum_drive_controller.hpp | 7 +++++-- tricycle_controller/test/test_tricycle_controller.cpp | 8 +++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mecanum_drive_controller/test/test_mecanum_drive_controller.hpp b/mecanum_drive_controller/test/test_mecanum_drive_controller.hpp index 5f7cf36dc7..d4dbe4d42e 100644 --- a/mecanum_drive_controller/test/test_mecanum_drive_controller.hpp +++ b/mecanum_drive_controller/test/test_mecanum_drive_controller.hpp @@ -154,11 +154,14 @@ class MecanumDriveControllerFixture : public ::testing::Test tf_odom_s_publisher_ = tf_odom_s_publisher_node_->create_publisher( "/test_mecanum_drive_controller/tf_odometry", rclcpp::SystemDefaultsQoS()); } + void TearDown() + { + controller_->get_node()->shutdown(); + controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition + } static void TearDownTestCase() {} - void TearDown() { controller_.reset(nullptr); } - protected: void SetUpController(const std::string controller_name = "test_mecanum_drive_controller") { diff --git a/tricycle_controller/test/test_tricycle_controller.cpp b/tricycle_controller/test/test_tricycle_controller.cpp index 5e868ebeea..480f18ebaa 100644 --- a/tricycle_controller/test/test_tricycle_controller.cpp +++ b/tricycle_controller/test/test_tricycle_controller.cpp @@ -82,7 +82,7 @@ class TestTricycleController : public ::testing::Test protected: static void SetUpTestCase() { rclcpp::init(0, nullptr); } - void SetUp() override + void SetUp() { controller_ = std::make_unique(); pub_node = std::make_shared("velocity_publisher"); @@ -90,6 +90,12 @@ class TestTricycleController : public ::testing::Test controller_name + "/cmd_vel", rclcpp::SystemDefaultsQoS()); } + void TearDown() + { + controller_->get_node()->shutdown(); + controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition + } + static void TearDownTestCase() { rclcpp::shutdown(); } /// Publish velocity msgs From d37d5b2047c6b24808d14af982c2a58a93e58d79 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Fri, 3 Jan 2025 23:10:40 +0000 Subject: [PATCH 4/7] JTC+admittance --- .../test/test_admittance_controller.hpp | 9 +++++---- .../test/test_trajectory_controller_utils.hpp | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/admittance_controller/test/test_admittance_controller.hpp b/admittance_controller/test/test_admittance_controller.hpp index 7ee56b8c11..8a7c31717d 100644 --- a/admittance_controller/test/test_admittance_controller.hpp +++ b/admittance_controller/test/test_admittance_controller.hpp @@ -129,13 +129,14 @@ class AdmittanceControllerTest : public ::testing::Test test_broadcaster_node_ = std::make_shared("test_broadcaster_node"); } - static void TearDownTestCase() + static void TearDownTestCase() {} + + void TearDown() { - // rclcpp::shutdown(); + controller_->get_node()->shutdown(); + controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } - void TearDown() { controller_.reset(nullptr); } - protected: controller_interface::return_type SetUpController( const std::string & controller_name, const std::vector & parameter_overrides) diff --git a/joint_trajectory_controller/test/test_trajectory_controller_utils.hpp b/joint_trajectory_controller/test/test_trajectory_controller_utils.hpp index b0e66394d1..98a0922d35 100644 --- a/joint_trajectory_controller/test/test_trajectory_controller_utils.hpp +++ b/joint_trajectory_controller/test/test_trajectory_controller_utils.hpp @@ -404,6 +404,7 @@ class TrajectoryControllerTest : public ::testing::Test traj_controller_->get_node()->deactivate().id(), lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE); } + traj_controller_->get_node()->shutdown(); } } From ab5de5f38e1a54a04d6c194979f31436e1a872d0 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Fri, 3 Jan 2025 23:12:46 +0000 Subject: [PATCH 5/7] Remaining controllers --- .../test/test_joint_group_effort_controller.cpp | 6 +++++- .../test/test_forward_command_controller.cpp | 6 +++++- .../test_multi_interface_forward_command_controller.cpp | 6 +++++- gripper_controllers/test/test_gripper_controllers.cpp | 3 ++- .../test/test_parallel_gripper_controller.cpp | 6 +++++- pid_controller/test/test_pid_controller.hpp | 8 ++++++-- .../test/test_joint_group_position_controller.cpp | 6 +++++- .../test/test_joint_group_velocity_controller.cpp | 6 +++++- 8 files changed, 38 insertions(+), 9 deletions(-) diff --git a/effort_controllers/test/test_joint_group_effort_controller.cpp b/effort_controllers/test/test_joint_group_effort_controller.cpp index c19cbff9cf..751d4ed9f6 100644 --- a/effort_controllers/test/test_joint_group_effort_controller.cpp +++ b/effort_controllers/test/test_joint_group_effort_controller.cpp @@ -34,7 +34,11 @@ void JointGroupEffortControllerTest::SetUp() controller_ = std::make_unique(); } -void JointGroupEffortControllerTest::TearDown() { controller_.reset(nullptr); } +void JointGroupEffortControllerTest::TearDown() +{ + controller_->get_node()->shutdown(); + controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition +} void JointGroupEffortControllerTest::SetUpController() { diff --git a/forward_command_controller/test/test_forward_command_controller.cpp b/forward_command_controller/test/test_forward_command_controller.cpp index fcfa65ee1c..92f12a477e 100644 --- a/forward_command_controller/test/test_forward_command_controller.cpp +++ b/forward_command_controller/test/test_forward_command_controller.cpp @@ -46,7 +46,11 @@ void ForwardCommandControllerTest::SetUp() controller_ = std::make_unique(); } -void ForwardCommandControllerTest::TearDown() { controller_.reset(nullptr); } +void ForwardCommandControllerTest::TearDown() +{ + controller_->get_node()->shutdown(); + controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition +} void ForwardCommandControllerTest::SetUpController() { diff --git a/forward_command_controller/test/test_multi_interface_forward_command_controller.cpp b/forward_command_controller/test/test_multi_interface_forward_command_controller.cpp index c52f4f3ab6..e584196746 100644 --- a/forward_command_controller/test/test_multi_interface_forward_command_controller.cpp +++ b/forward_command_controller/test/test_multi_interface_forward_command_controller.cpp @@ -48,7 +48,11 @@ void MultiInterfaceForwardCommandControllerTest::SetUp() controller_ = std::make_unique(); } -void MultiInterfaceForwardCommandControllerTest::TearDown() { controller_.reset(nullptr); } +void MultiInterfaceForwardCommandControllerTest::TearDown() +{ + controller_->get_node()->shutdown(); + controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition +} void MultiInterfaceForwardCommandControllerTest::SetUpController(bool set_params_and_activate) { diff --git a/gripper_controllers/test/test_gripper_controllers.cpp b/gripper_controllers/test/test_gripper_controllers.cpp index 97fef24eaf..f2ecae3ac0 100644 --- a/gripper_controllers/test/test_gripper_controllers.cpp +++ b/gripper_controllers/test/test_gripper_controllers.cpp @@ -52,7 +52,8 @@ void GripperControllerTest::SetUp() template void GripperControllerTest::TearDown() { - controller_.reset(nullptr); + controller_->get_node()->shutdown(); + controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } template diff --git a/parallel_gripper_controller/test/test_parallel_gripper_controller.cpp b/parallel_gripper_controller/test/test_parallel_gripper_controller.cpp index 417d87d40f..7df1889c9e 100644 --- a/parallel_gripper_controller/test/test_parallel_gripper_controller.cpp +++ b/parallel_gripper_controller/test/test_parallel_gripper_controller.cpp @@ -44,7 +44,11 @@ void GripperControllerTest::SetUp() controller_ = std::make_unique(); } -void GripperControllerTest::TearDown() { controller_.reset(nullptr); } +void GripperControllerTest::TearDown() +{ + controller_->get_node()->shutdown(); + controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition +} void GripperControllerTest::SetUpController( const std::string & controller_name = "test_gripper_action_position_controller", diff --git a/pid_controller/test/test_pid_controller.hpp b/pid_controller/test/test_pid_controller.hpp index 4471f35a12..bb1f3c947f 100644 --- a/pid_controller/test/test_pid_controller.hpp +++ b/pid_controller/test/test_pid_controller.hpp @@ -128,9 +128,13 @@ class PidControllerFixture : public ::testing::Test "/test_pid_controller/set_feedforward_control"); } - static void TearDownTestCase() { rclcpp::shutdown(); } + void TearDown() + { + controller_->get_node()->shutdown(); + controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition + } - void TearDown() { controller_.reset(nullptr); } + static void TearDownTestCase() {} protected: void SetUpController(const std::string controller_name = "test_pid_controller") diff --git a/position_controllers/test/test_joint_group_position_controller.cpp b/position_controllers/test/test_joint_group_position_controller.cpp index 96a5cead17..f138a9db1d 100644 --- a/position_controllers/test/test_joint_group_position_controller.cpp +++ b/position_controllers/test/test_joint_group_position_controller.cpp @@ -34,7 +34,11 @@ void JointGroupPositionControllerTest::SetUp() controller_ = std::make_unique(); } -void JointGroupPositionControllerTest::TearDown() { controller_.reset(nullptr); } +void JointGroupPositionControllerTest::TearDown() +{ + controller_->get_node()->shutdown(); + controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition +} void JointGroupPositionControllerTest::SetUpController() { diff --git a/velocity_controllers/test/test_joint_group_velocity_controller.cpp b/velocity_controllers/test/test_joint_group_velocity_controller.cpp index d781b6ca5c..9439ad59d5 100644 --- a/velocity_controllers/test/test_joint_group_velocity_controller.cpp +++ b/velocity_controllers/test/test_joint_group_velocity_controller.cpp @@ -34,7 +34,11 @@ void JointGroupVelocityControllerTest::SetUp() controller_ = std::make_unique(); } -void JointGroupVelocityControllerTest::TearDown() { controller_.reset(nullptr); } +void JointGroupVelocityControllerTest::TearDown() +{ + controller_->get_node()->shutdown(); + controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition +} void JointGroupVelocityControllerTest::SetUpController() { From 0562e193cdb3a09a9816b6a2e797fd6aceb0c886 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Fri, 3 Jan 2025 23:16:29 +0000 Subject: [PATCH 6/7] Broadcasters --- .../test/test_force_torque_sensor_broadcaster.cpp | 6 +++++- imu_sensor_broadcaster/test/test_imu_sensor_broadcaster.cpp | 6 +++++- .../test/test_joint_state_broadcaster.cpp | 6 +++++- pose_broadcaster/test/test_pose_broadcaster.cpp | 6 +++++- .../test/test_range_sensor_broadcaster.cpp | 6 +++++- 5 files changed, 25 insertions(+), 5 deletions(-) diff --git a/force_torque_sensor_broadcaster/test/test_force_torque_sensor_broadcaster.cpp b/force_torque_sensor_broadcaster/test/test_force_torque_sensor_broadcaster.cpp index 26f959e88f..561e978b3c 100644 --- a/force_torque_sensor_broadcaster/test/test_force_torque_sensor_broadcaster.cpp +++ b/force_torque_sensor_broadcaster/test/test_force_torque_sensor_broadcaster.cpp @@ -48,7 +48,11 @@ void ForceTorqueSensorBroadcasterTest::SetUp() fts_broadcaster_ = std::make_unique(); } -void ForceTorqueSensorBroadcasterTest::TearDown() { fts_broadcaster_.reset(nullptr); } +void ForceTorqueSensorBroadcasterTest::TearDown() +{ + fts_broadcaster_->get_node()->shutdown(); + fts_broadcaster_.reset(nullptr); // this calls the dtor, but does not call shutdown transition +} void ForceTorqueSensorBroadcasterTest::SetUpFTSBroadcaster() { diff --git a/imu_sensor_broadcaster/test/test_imu_sensor_broadcaster.cpp b/imu_sensor_broadcaster/test/test_imu_sensor_broadcaster.cpp index 67cf31f8a5..243a6173f0 100644 --- a/imu_sensor_broadcaster/test/test_imu_sensor_broadcaster.cpp +++ b/imu_sensor_broadcaster/test/test_imu_sensor_broadcaster.cpp @@ -48,7 +48,11 @@ void IMUSensorBroadcasterTest::SetUp() imu_broadcaster_ = std::make_unique(); } -void IMUSensorBroadcasterTest::TearDown() { imu_broadcaster_.reset(nullptr); } +void IMUSensorBroadcasterTest::TearDown() +{ + imu_broadcaster_->get_node()->shutdown(); + imu_broadcaster_.reset(nullptr); // this calls the dtor, but does not call shutdown transition +} void IMUSensorBroadcasterTest::SetUpIMUBroadcaster() { diff --git a/joint_state_broadcaster/test/test_joint_state_broadcaster.cpp b/joint_state_broadcaster/test/test_joint_state_broadcaster.cpp index 3ec7ff4ac2..c30dac4612 100644 --- a/joint_state_broadcaster/test/test_joint_state_broadcaster.cpp +++ b/joint_state_broadcaster/test/test_joint_state_broadcaster.cpp @@ -57,7 +57,11 @@ void JointStateBroadcasterTest::SetUp() state_broadcaster_ = std::make_unique(); } -void JointStateBroadcasterTest::TearDown() { state_broadcaster_.reset(nullptr); } +void JointStateBroadcasterTest::TearDown() +{ + state_broadcaster_->get_node()->shutdown(); + state_broadcaster_.reset(nullptr); // this calls the dtor, but does not call shutdown transition +} void JointStateBroadcasterTest::SetUpStateBroadcaster( const std::vector & joint_names, const std::vector & interfaces) diff --git a/pose_broadcaster/test/test_pose_broadcaster.cpp b/pose_broadcaster/test/test_pose_broadcaster.cpp index 0ed2e84619..fd0086fe4a 100644 --- a/pose_broadcaster/test/test_pose_broadcaster.cpp +++ b/pose_broadcaster/test/test_pose_broadcaster.cpp @@ -20,7 +20,11 @@ using hardware_interface::LoanedStateInterface; void PoseBroadcasterTest::SetUp() { pose_broadcaster_ = std::make_unique(); } -void PoseBroadcasterTest::TearDown() { pose_broadcaster_.reset(nullptr); } +void PoseBroadcasterTest::TearDown() +{ + pose_broadcaster_->get_node()->shutdown(); + pose_broadcaster_.reset(nullptr); // this calls the dtor, but does not call shutdown transition +} void PoseBroadcasterTest::SetUpPoseBroadcaster() { diff --git a/range_sensor_broadcaster/test/test_range_sensor_broadcaster.cpp b/range_sensor_broadcaster/test/test_range_sensor_broadcaster.cpp index 052c0384d3..fde5d8c31e 100644 --- a/range_sensor_broadcaster/test/test_range_sensor_broadcaster.cpp +++ b/range_sensor_broadcaster/test/test_range_sensor_broadcaster.cpp @@ -33,7 +33,11 @@ void RangeSensorBroadcasterTest::SetUp() range_broadcaster_ = std::make_unique(); } -void RangeSensorBroadcasterTest::TearDown() { range_broadcaster_.reset(nullptr); } +void RangeSensorBroadcasterTest::TearDown() +{ + range_broadcaster_->get_node()->shutdown(); + range_broadcaster_.reset(nullptr); // this calls the dtor, but does not call shutdown transition +} controller_interface::return_type RangeSensorBroadcasterTest::init_broadcaster( std::string broadcaster_name) From cb3d66a4f8201bc8258972cec7b3f3a2e1d38a0f Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sat, 4 Jan 2025 15:12:56 +0000 Subject: [PATCH 7/7] Try-catch if the node is not initialized --- .../test/test_ackermann_steering_controller.hpp | 9 ++++++++- .../test/test_admittance_controller.hpp | 9 ++++++++- .../test/test_bicycle_steering_controller.hpp | 9 ++++++++- .../test/test_diff_drive_controller.cpp | 9 ++++++++- .../test/test_joint_group_effort_controller.cpp | 9 ++++++++- .../test/test_force_torque_sensor_broadcaster.cpp | 9 ++++++++- .../test/test_forward_command_controller.cpp | 9 ++++++++- ...test_multi_interface_forward_command_controller.cpp | 9 ++++++++- gripper_controllers/test/test_gripper_controllers.cpp | 9 ++++++++- .../test/test_imu_sensor_broadcaster.cpp | 9 ++++++++- .../test/test_joint_state_broadcaster.cpp | 9 ++++++++- .../test/test_trajectory_controller_utils.hpp | 9 ++++++++- .../test/test_mecanum_drive_controller.hpp | 10 +++++++++- .../test/test_parallel_gripper_controller.cpp | 9 ++++++++- pid_controller/test/test_pid_controller.hpp | 9 ++++++++- pose_broadcaster/test/test_pose_broadcaster.cpp | 9 ++++++++- .../test/test_joint_group_position_controller.cpp | 9 ++++++++- .../test/test_range_sensor_broadcaster.cpp | 9 ++++++++- .../test/test_steering_controllers_library.hpp | 9 ++++++++- tricycle_controller/test/test_tricycle_controller.cpp | 9 ++++++++- .../test/test_tricycle_steering_controller.hpp | 9 ++++++++- .../test/test_joint_group_velocity_controller.cpp | 9 ++++++++- 22 files changed, 177 insertions(+), 22 deletions(-) diff --git a/ackermann_steering_controller/test/test_ackermann_steering_controller.hpp b/ackermann_steering_controller/test/test_ackermann_steering_controller.hpp index 8954ca1432..12a7fcb278 100644 --- a/ackermann_steering_controller/test/test_ackermann_steering_controller.hpp +++ b/ackermann_steering_controller/test/test_ackermann_steering_controller.hpp @@ -128,7 +128,14 @@ class AckermannSteeringControllerFixture : public ::testing::Test void TearDown() { - controller_->get_node()->shutdown(); + try + { + controller_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/admittance_controller/test/test_admittance_controller.hpp b/admittance_controller/test/test_admittance_controller.hpp index 8a7c31717d..3d70ea48c9 100644 --- a/admittance_controller/test/test_admittance_controller.hpp +++ b/admittance_controller/test/test_admittance_controller.hpp @@ -133,7 +133,14 @@ class AdmittanceControllerTest : public ::testing::Test void TearDown() { - controller_->get_node()->shutdown(); + try + { + controller_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/bicycle_steering_controller/test/test_bicycle_steering_controller.hpp b/bicycle_steering_controller/test/test_bicycle_steering_controller.hpp index 9efa4032f9..d4bc4f499c 100644 --- a/bicycle_steering_controller/test/test_bicycle_steering_controller.hpp +++ b/bicycle_steering_controller/test/test_bicycle_steering_controller.hpp @@ -126,7 +126,14 @@ class BicycleSteeringControllerFixture : public ::testing::Test void TearDown() { - controller_->get_node()->shutdown(); + try + { + controller_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/diff_drive_controller/test/test_diff_drive_controller.cpp b/diff_drive_controller/test/test_diff_drive_controller.cpp index a7493699fd..069446f506 100644 --- a/diff_drive_controller/test/test_diff_drive_controller.cpp +++ b/diff_drive_controller/test/test_diff_drive_controller.cpp @@ -101,7 +101,14 @@ class TestDiffDriveController : public ::testing::Test void TearDown() { - controller_->get_node()->shutdown(); + try + { + controller_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/effort_controllers/test/test_joint_group_effort_controller.cpp b/effort_controllers/test/test_joint_group_effort_controller.cpp index 751d4ed9f6..0e6e614476 100644 --- a/effort_controllers/test/test_joint_group_effort_controller.cpp +++ b/effort_controllers/test/test_joint_group_effort_controller.cpp @@ -36,7 +36,14 @@ void JointGroupEffortControllerTest::SetUp() void JointGroupEffortControllerTest::TearDown() { - controller_->get_node()->shutdown(); + try + { + controller_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/force_torque_sensor_broadcaster/test/test_force_torque_sensor_broadcaster.cpp b/force_torque_sensor_broadcaster/test/test_force_torque_sensor_broadcaster.cpp index 561e978b3c..7fb2cf940e 100644 --- a/force_torque_sensor_broadcaster/test/test_force_torque_sensor_broadcaster.cpp +++ b/force_torque_sensor_broadcaster/test/test_force_torque_sensor_broadcaster.cpp @@ -50,7 +50,14 @@ void ForceTorqueSensorBroadcasterTest::SetUp() void ForceTorqueSensorBroadcasterTest::TearDown() { - fts_broadcaster_->get_node()->shutdown(); + try + { + fts_broadcaster_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } fts_broadcaster_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/forward_command_controller/test/test_forward_command_controller.cpp b/forward_command_controller/test/test_forward_command_controller.cpp index 92f12a477e..c04b843c2c 100644 --- a/forward_command_controller/test/test_forward_command_controller.cpp +++ b/forward_command_controller/test/test_forward_command_controller.cpp @@ -48,7 +48,14 @@ void ForwardCommandControllerTest::SetUp() void ForwardCommandControllerTest::TearDown() { - controller_->get_node()->shutdown(); + try + { + controller_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/forward_command_controller/test/test_multi_interface_forward_command_controller.cpp b/forward_command_controller/test/test_multi_interface_forward_command_controller.cpp index e584196746..ff218083b1 100644 --- a/forward_command_controller/test/test_multi_interface_forward_command_controller.cpp +++ b/forward_command_controller/test/test_multi_interface_forward_command_controller.cpp @@ -50,7 +50,14 @@ void MultiInterfaceForwardCommandControllerTest::SetUp() void MultiInterfaceForwardCommandControllerTest::TearDown() { - controller_->get_node()->shutdown(); + try + { + controller_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/gripper_controllers/test/test_gripper_controllers.cpp b/gripper_controllers/test/test_gripper_controllers.cpp index f2ecae3ac0..a263f1e681 100644 --- a/gripper_controllers/test/test_gripper_controllers.cpp +++ b/gripper_controllers/test/test_gripper_controllers.cpp @@ -52,7 +52,14 @@ void GripperControllerTest::SetUp() template void GripperControllerTest::TearDown() { - controller_->get_node()->shutdown(); + try + { + controller_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/imu_sensor_broadcaster/test/test_imu_sensor_broadcaster.cpp b/imu_sensor_broadcaster/test/test_imu_sensor_broadcaster.cpp index 243a6173f0..9debe67836 100644 --- a/imu_sensor_broadcaster/test/test_imu_sensor_broadcaster.cpp +++ b/imu_sensor_broadcaster/test/test_imu_sensor_broadcaster.cpp @@ -50,7 +50,14 @@ void IMUSensorBroadcasterTest::SetUp() void IMUSensorBroadcasterTest::TearDown() { - imu_broadcaster_->get_node()->shutdown(); + try + { + imu_broadcaster_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } imu_broadcaster_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/joint_state_broadcaster/test/test_joint_state_broadcaster.cpp b/joint_state_broadcaster/test/test_joint_state_broadcaster.cpp index c30dac4612..952a2c766e 100644 --- a/joint_state_broadcaster/test/test_joint_state_broadcaster.cpp +++ b/joint_state_broadcaster/test/test_joint_state_broadcaster.cpp @@ -59,7 +59,14 @@ void JointStateBroadcasterTest::SetUp() void JointStateBroadcasterTest::TearDown() { - state_broadcaster_->get_node()->shutdown(); + try + { + state_broadcaster_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } state_broadcaster_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/joint_trajectory_controller/test/test_trajectory_controller_utils.hpp b/joint_trajectory_controller/test/test_trajectory_controller_utils.hpp index 98a0922d35..513afbda1a 100644 --- a/joint_trajectory_controller/test/test_trajectory_controller_utils.hpp +++ b/joint_trajectory_controller/test/test_trajectory_controller_utils.hpp @@ -404,7 +404,14 @@ class TrajectoryControllerTest : public ::testing::Test traj_controller_->get_node()->deactivate().id(), lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE); } - traj_controller_->get_node()->shutdown(); + try + { + traj_controller_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } } } diff --git a/mecanum_drive_controller/test/test_mecanum_drive_controller.hpp b/mecanum_drive_controller/test/test_mecanum_drive_controller.hpp index d4dbe4d42e..bdd578aa27 100644 --- a/mecanum_drive_controller/test/test_mecanum_drive_controller.hpp +++ b/mecanum_drive_controller/test/test_mecanum_drive_controller.hpp @@ -154,9 +154,17 @@ class MecanumDriveControllerFixture : public ::testing::Test tf_odom_s_publisher_ = tf_odom_s_publisher_node_->create_publisher( "/test_mecanum_drive_controller/tf_odometry", rclcpp::SystemDefaultsQoS()); } + void TearDown() { - controller_->get_node()->shutdown(); + try + { + controller_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/parallel_gripper_controller/test/test_parallel_gripper_controller.cpp b/parallel_gripper_controller/test/test_parallel_gripper_controller.cpp index 7df1889c9e..d12c3eb495 100644 --- a/parallel_gripper_controller/test/test_parallel_gripper_controller.cpp +++ b/parallel_gripper_controller/test/test_parallel_gripper_controller.cpp @@ -46,7 +46,14 @@ void GripperControllerTest::SetUp() void GripperControllerTest::TearDown() { - controller_->get_node()->shutdown(); + try + { + controller_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/pid_controller/test/test_pid_controller.hpp b/pid_controller/test/test_pid_controller.hpp index bb1f3c947f..a23846a1b3 100644 --- a/pid_controller/test/test_pid_controller.hpp +++ b/pid_controller/test/test_pid_controller.hpp @@ -130,7 +130,14 @@ class PidControllerFixture : public ::testing::Test void TearDown() { - controller_->get_node()->shutdown(); + try + { + controller_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/pose_broadcaster/test/test_pose_broadcaster.cpp b/pose_broadcaster/test/test_pose_broadcaster.cpp index fd0086fe4a..a24ba655dd 100644 --- a/pose_broadcaster/test/test_pose_broadcaster.cpp +++ b/pose_broadcaster/test/test_pose_broadcaster.cpp @@ -22,7 +22,14 @@ void PoseBroadcasterTest::SetUp() { pose_broadcaster_ = std::make_uniqueget_node()->shutdown(); + try + { + pose_broadcaster_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } pose_broadcaster_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/position_controllers/test/test_joint_group_position_controller.cpp b/position_controllers/test/test_joint_group_position_controller.cpp index f138a9db1d..e84080b20f 100644 --- a/position_controllers/test/test_joint_group_position_controller.cpp +++ b/position_controllers/test/test_joint_group_position_controller.cpp @@ -36,7 +36,14 @@ void JointGroupPositionControllerTest::SetUp() void JointGroupPositionControllerTest::TearDown() { - controller_->get_node()->shutdown(); + try + { + controller_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/range_sensor_broadcaster/test/test_range_sensor_broadcaster.cpp b/range_sensor_broadcaster/test/test_range_sensor_broadcaster.cpp index fde5d8c31e..ea125c2cd7 100644 --- a/range_sensor_broadcaster/test/test_range_sensor_broadcaster.cpp +++ b/range_sensor_broadcaster/test/test_range_sensor_broadcaster.cpp @@ -35,7 +35,14 @@ void RangeSensorBroadcasterTest::SetUp() void RangeSensorBroadcasterTest::TearDown() { - range_broadcaster_->get_node()->shutdown(); + try + { + range_broadcaster_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } range_broadcaster_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/steering_controllers_library/test/test_steering_controllers_library.hpp b/steering_controllers_library/test/test_steering_controllers_library.hpp index 355a513699..3e2b43c3b4 100644 --- a/steering_controllers_library/test/test_steering_controllers_library.hpp +++ b/steering_controllers_library/test/test_steering_controllers_library.hpp @@ -149,7 +149,14 @@ class SteeringControllersLibraryFixture : public ::testing::Test void TearDown() { - controller_->get_node()->shutdown(); + try + { + controller_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/tricycle_controller/test/test_tricycle_controller.cpp b/tricycle_controller/test/test_tricycle_controller.cpp index 480f18ebaa..17c66c9d3d 100644 --- a/tricycle_controller/test/test_tricycle_controller.cpp +++ b/tricycle_controller/test/test_tricycle_controller.cpp @@ -92,7 +92,14 @@ class TestTricycleController : public ::testing::Test void TearDown() { - controller_->get_node()->shutdown(); + try + { + controller_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/tricycle_steering_controller/test/test_tricycle_steering_controller.hpp b/tricycle_steering_controller/test/test_tricycle_steering_controller.hpp index 1f88880494..137da927df 100644 --- a/tricycle_steering_controller/test/test_tricycle_steering_controller.hpp +++ b/tricycle_steering_controller/test/test_tricycle_steering_controller.hpp @@ -127,7 +127,14 @@ class TricycleSteeringControllerFixture : public ::testing::Test void TearDown() { - controller_->get_node()->shutdown(); + try + { + controller_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition } diff --git a/velocity_controllers/test/test_joint_group_velocity_controller.cpp b/velocity_controllers/test/test_joint_group_velocity_controller.cpp index 9439ad59d5..ea7aeeaf2e 100644 --- a/velocity_controllers/test/test_joint_group_velocity_controller.cpp +++ b/velocity_controllers/test/test_joint_group_velocity_controller.cpp @@ -36,7 +36,14 @@ void JointGroupVelocityControllerTest::SetUp() void JointGroupVelocityControllerTest::TearDown() { - controller_->get_node()->shutdown(); + try + { + controller_->get_node()->shutdown(); + } + catch (...) + { + // ignore case where node is not initialized + } controller_.reset(nullptr); // this calls the dtor, but does not call shutdown transition }