Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions joint_trajectory_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,12 @@ if(BUILD_TESTING)
ros2_control_test_assets
)

# TODO(andyz): Disabled due to flakiness
# ament_add_gmock(test_trajectory_actions
# test/test_trajectory_actions.cpp
# )
# target_link_libraries(test_trajectory_actions
# joint_trajectory_controller
# )
ament_add_gmock(test_trajectory_actions
test/test_trajectory_actions.cpp
)
target_link_libraries(test_trajectory_actions
joint_trajectory_controller
)
endif()


Expand Down
22 changes: 9 additions & 13 deletions joint_trajectory_controller/test/test_trajectory_actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,13 @@ class TestTrajectoryActions : public TrajectoryControllerTest
{
setup_executor_ = true;

executor_ = std::make_unique<rclcpp::executors::MultiThreadedExecutor>();

SetUpAndActivateTrajectoryController(true, parameters);

executor_->add_node(traj_controller_->get_node()->get_node_base_interface());
SetUpAndActivateTrajectoryController(executor_, true, parameters);

SetUpActionClient();

executor_->add_node(node_->get_node_base_interface());
executor_.add_node(node_->get_node_base_interface());

executor_future_handle_ = std::async(std::launch::async, [&]() -> void { executor_->spin(); });
executor_future_handle_ = std::async(std::launch::async, [&]() -> void { executor_.spin(); });
}

void SetUpControllerHardware()
Expand Down Expand Up @@ -132,7 +128,7 @@ class TestTrajectoryActions : public TrajectoryControllerTest
if (setup_executor_)
{
setup_executor_ = false;
executor_->cancel();
executor_.cancel();
executor_future_handle_.wait();
}
}
Expand Down Expand Up @@ -169,7 +165,7 @@ class TestTrajectoryActions : public TrajectoryControllerTest
int common_action_result_code_ = control_msgs::action::FollowJointTrajectory_Result::SUCCESSFUL;

bool setup_executor_ = false;
rclcpp::executors::MultiThreadedExecutor::UniquePtr executor_;
rclcpp::executors::MultiThreadedExecutor executor_;
std::future<void> executor_future_handle_;

bool setup_controller_hw_ = false;
Expand Down Expand Up @@ -417,7 +413,7 @@ TEST_F(TestTrajectoryActions, test_state_tolerances_fail)
common_action_result_code_);

// run an update, it should be holding
traj_controller_->update(rclcpp::Time(0), rclcpp::Duration::from_seconds(0.01));
updateController(rclcpp::Duration::from_seconds(0.01));

EXPECT_NEAR(INITIAL_POS_JOINT1, joint_pos_[0], COMMON_THRESHOLD);
EXPECT_NEAR(INITIAL_POS_JOINT2, joint_pos_[1], COMMON_THRESHOLD);
Expand Down Expand Up @@ -467,7 +463,7 @@ TEST_F(TestTrajectoryActions, test_goal_tolerances_fail)
common_action_result_code_);

// run an update, it should be holding
traj_controller_->update(rclcpp::Time(0), rclcpp::Duration::from_seconds(0.01));
updateController(rclcpp::Duration::from_seconds(0.01));

EXPECT_NEAR(init_pos1, joint_pos_[0], COMMON_THRESHOLD);
EXPECT_NEAR(init_pos2, joint_pos_[1], COMMON_THRESHOLD);
Expand Down Expand Up @@ -514,7 +510,7 @@ TEST_F(TestTrajectoryActions, test_no_time_from_start_state_tolerance_fail)
common_action_result_code_);

// run an update, it should be holding
traj_controller_->update(rclcpp::Time(0), rclcpp::Duration::from_seconds(0.01));
updateController(rclcpp::Duration::from_seconds(0.01));

EXPECT_NEAR(init_pos1, joint_pos_[0], COMMON_THRESHOLD);
EXPECT_NEAR(init_pos2, joint_pos_[1], COMMON_THRESHOLD);
Expand Down Expand Up @@ -563,7 +559,7 @@ TEST_F(TestTrajectoryActions, test_cancel_hold_position)
const double prev_pos3 = joint_pos_[2];

// run an update, it should be holding
traj_controller_->update(rclcpp::Time(0), rclcpp::Duration::from_seconds(0.01));
updateController(rclcpp::Duration::from_seconds(0.01));

EXPECT_EQ(prev_pos1, joint_pos_[0]);
EXPECT_EQ(prev_pos2, joint_pos_[1]);
Expand Down