Skip to content

Commit fd8b434

Browse files
authored
[JTC] Fix the JTC length_error exceptions in the tests (backport #1360) (#1362)
1 parent 927f123 commit fd8b434

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

joint_trajectory_controller/test/test_trajectory_controller_utils.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "hardware_interface/types/hardware_interface_type_values.hpp"
2727
#include "joint_trajectory_controller/joint_trajectory_controller.hpp"
2828
#include "joint_trajectory_controller/tolerances.hpp"
29+
#include "lifecycle_msgs/msg/state.hpp"
2930

3031
namespace
3132
{
@@ -383,6 +384,19 @@ class TrajectoryControllerTest : public ::testing::Test
383384
return traj_controller_->get_node()->activate();
384385
}
385386

387+
void DeactivateTrajectoryController()
388+
{
389+
if (traj_controller_)
390+
{
391+
if (traj_controller_->get_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE)
392+
{
393+
EXPECT_EQ(
394+
traj_controller_->get_node()->deactivate().id(),
395+
lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE);
396+
}
397+
}
398+
}
399+
386400
static void TearDownTestCase() { rclcpp::shutdown(); }
387401

388402
void subscribeToState(rclcpp::Executor & executor)
@@ -768,6 +782,8 @@ class TrajectoryControllerTestParameterized
768782
state_interface_types_ = std::get<1>(GetParam());
769783
}
770784

785+
virtual void TearDown() { TrajectoryControllerTest::DeactivateTrajectoryController(); }
786+
771787
static void TearDownTestCase() { TrajectoryControllerTest::TearDownTestCase(); }
772788
};
773789

0 commit comments

Comments
 (0)