@@ -1666,6 +1666,67 @@ TEST_P(TrajectoryControllerTestParameterized, test_hw_states_has_offset_later_co
1666
1666
executor.cancel ();
1667
1667
}
1668
1668
1669
+ TEST_P (TrajectoryControllerTestParameterized, test_state_tolerances_fail)
1670
+ {
1671
+ // set joint tolerance parameters
1672
+ const double state_tol = 0.0001 ;
1673
+ std::vector<rclcpp::Parameter> params = {
1674
+ rclcpp::Parameter (" constraints.joint1.trajectory" , state_tol),
1675
+ rclcpp::Parameter (" constraints.joint2.trajectory" , state_tol),
1676
+ rclcpp::Parameter (" constraints.joint3.trajectory" , state_tol)};
1677
+
1678
+ rclcpp::executors::MultiThreadedExecutor executor;
1679
+ SetUpAndActivateTrajectoryController (executor, false , {params}, true );
1680
+
1681
+ // send msg
1682
+ constexpr auto FIRST_POINT_TIME = std::chrono::milliseconds (100 );
1683
+ builtin_interfaces::msg::Duration time_from_start{rclcpp::Duration (FIRST_POINT_TIME)};
1684
+ // *INDENT-OFF*
1685
+ std::vector<std::vector<double >> points{
1686
+ {{3.3 , 4.4 , 5.5 }}, {{7.7 , 8.8 , 9.9 }}, {{10.10 , 11.11 , 12.12 }}};
1687
+ std::vector<std::vector<double >> points_velocities{
1688
+ {{0.01 , 0.01 , 0.01 }}, {{0.05 , 0.05 , 0.05 }}, {{0.06 , 0.06 , 0.06 }}};
1689
+ // *INDENT-ON*
1690
+ publish (time_from_start, points, rclcpp::Time (0 , 0 , RCL_STEADY_TIME), {}, points_velocities);
1691
+ traj_controller_->wait_for_trajectory (executor);
1692
+ updateController (rclcpp::Duration (FIRST_POINT_TIME));
1693
+
1694
+ // it should have aborted and be holding now
1695
+ expectHoldingPoint (joint_state_pos_);
1696
+ }
1697
+
1698
+ TEST_P (TrajectoryControllerTestParameterized, test_goal_tolerances_fail)
1699
+ {
1700
+ // set joint tolerance parameters
1701
+ const double goal_tol = 0.1 ;
1702
+ // set very small goal_time so that goal_time is violated
1703
+ const double goal_time = 0.000001 ;
1704
+ std::vector<rclcpp::Parameter> params = {
1705
+ rclcpp::Parameter (" constraints.joint1.goal" , goal_tol),
1706
+ rclcpp::Parameter (" constraints.joint2.goal" , goal_tol),
1707
+ rclcpp::Parameter (" constraints.joint3.goal" , goal_tol),
1708
+ rclcpp::Parameter (" constraints.goal_time" , goal_time)};
1709
+
1710
+ rclcpp::executors::MultiThreadedExecutor executor;
1711
+ SetUpAndActivateTrajectoryController (executor, false , {params}, true );
1712
+
1713
+ // send msg
1714
+ constexpr auto FIRST_POINT_TIME = std::chrono::milliseconds (100 );
1715
+ builtin_interfaces::msg::Duration time_from_start{rclcpp::Duration (FIRST_POINT_TIME)};
1716
+ // *INDENT-OFF*
1717
+ std::vector<std::vector<double >> points{
1718
+ {{3.3 , 4.4 , 5.5 }}, {{7.7 , 8.8 , 9.9 }}, {{10.10 , 11.11 , 12.12 }}};
1719
+ std::vector<std::vector<double >> points_velocities{
1720
+ {{0.01 , 0.01 , 0.01 }}, {{0.05 , 0.05 , 0.05 }}, {{0.06 , 0.06 , 0.06 }}};
1721
+ // *INDENT-ON*
1722
+ publish (time_from_start, points, rclcpp::Time (0 , 0 , RCL_STEADY_TIME), {}, points_velocities);
1723
+ traj_controller_->wait_for_trajectory (executor);
1724
+ updateController (rclcpp::Duration (4 * FIRST_POINT_TIME));
1725
+
1726
+ // it should have aborted and be holding now
1727
+ expectHoldingPoint (joint_state_pos_);
1728
+ }
1729
+
1669
1730
// position controllers
1670
1731
INSTANTIATE_TEST_SUITE_P (
1671
1732
PositionTrajectoryControllers, TrajectoryControllerTestParameterized,
0 commit comments