Skip to content

Commit

Permalink
[JTC] Fix the JTC length_error exceptions in the tests (backport #1360)…
Browse files Browse the repository at this point in the history
… (#1362)
  • Loading branch information
mergify[bot] authored Nov 11, 2024
1 parent 927f123 commit fd8b434
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "hardware_interface/types/hardware_interface_type_values.hpp"
#include "joint_trajectory_controller/joint_trajectory_controller.hpp"
#include "joint_trajectory_controller/tolerances.hpp"
#include "lifecycle_msgs/msg/state.hpp"

namespace
{
Expand Down Expand Up @@ -383,6 +384,19 @@ class TrajectoryControllerTest : public ::testing::Test
return traj_controller_->get_node()->activate();
}

void DeactivateTrajectoryController()
{
if (traj_controller_)
{
if (traj_controller_->get_state().id() == lifecycle_msgs::msg::State::PRIMARY_STATE_ACTIVE)
{
EXPECT_EQ(
traj_controller_->get_node()->deactivate().id(),
lifecycle_msgs::msg::State::PRIMARY_STATE_INACTIVE);
}
}
}

static void TearDownTestCase() { rclcpp::shutdown(); }

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

virtual void TearDown() { TrajectoryControllerTest::DeactivateTrajectoryController(); }

static void TearDownTestCase() { TrajectoryControllerTest::TearDownTestCase(); }
};

Expand Down

0 comments on commit fd8b434

Please sign in to comment.