From 36ecdda94fd2dbdbae37c48ff18d35b66123389f Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 24 Jun 2024 20:31:59 +0000 Subject: [PATCH] Remove test_tolerances_utils --- .../test/test_tolerances.cpp | 6 +- .../test/test_tolerances_utils.hpp | 57 ------------------- .../test/test_trajectory_actions.cpp | 1 - .../test/test_trajectory_controller_utils.hpp | 35 ++++++++++++ 4 files changed, 38 insertions(+), 61 deletions(-) delete mode 100644 joint_trajectory_controller/test/test_tolerances_utils.hpp diff --git a/joint_trajectory_controller/test/test_tolerances.cpp b/joint_trajectory_controller/test/test_tolerances.cpp index fd51ca61bc..66914b6da4 100644 --- a/joint_trajectory_controller/test/test_tolerances.cpp +++ b/joint_trajectory_controller/test/test_tolerances.cpp @@ -20,12 +20,12 @@ #include "gmock/gmock.h" #include "rclcpp/duration.hpp" #include "rclcpp/logger.hpp" - -#include "joint_trajectory_controller/tolerances.hpp" -#include "test_tolerances_utils.hpp" #include "trajectory_msgs/msg/joint_trajectory.hpp" #include "trajectory_msgs/msg/joint_trajectory_point.hpp" +#include "joint_trajectory_controller/tolerances.hpp" +#include "test_trajectory_controller_utils.hpp" + using joint_trajectory_controller::SegmentTolerances; using trajectory_msgs::msg::JointTrajectoryPoint; diff --git a/joint_trajectory_controller/test/test_tolerances_utils.hpp b/joint_trajectory_controller/test/test_tolerances_utils.hpp deleted file mode 100644 index 622656aa99..0000000000 --- a/joint_trajectory_controller/test/test_tolerances_utils.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2024 Austrian Institute of Technology -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef TEST_TOLERANCES_UTILS_HPP_ -#define TEST_TOLERANCES_UTILS_HPP_ - -#include - -#include "gmock/gmock.h" - -#include "joint_trajectory_controller/tolerances.hpp" - -double default_goal_time = 0.1; -double stopped_velocity_tolerance = 0.1; - -void expectDefaultTolerances(joint_trajectory_controller::SegmentTolerances active_tolerances) -{ - // acceleration is never set, and goal_state_tolerance.velocity from stopped_velocity_tolerance - - ASSERT_EQ(active_tolerances.state_tolerance.size(), 3); - EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(0).position, 0.1); - EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(0).velocity, 0.0); - EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(0).acceleration, 0.0); - EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(1).position, 0.1); - EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(1).velocity, 0.0); - EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(1).acceleration, 0.0); - EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(2).position, 0.1); - EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(2).velocity, 0.0); - EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(2).acceleration, 0.0); - - ASSERT_EQ(active_tolerances.goal_state_tolerance.size(), 3); - EXPECT_DOUBLE_EQ(active_tolerances.goal_state_tolerance.at(0).position, 0.1); - EXPECT_DOUBLE_EQ( - active_tolerances.goal_state_tolerance.at(0).velocity, stopped_velocity_tolerance); - EXPECT_DOUBLE_EQ(active_tolerances.goal_state_tolerance.at(0).acceleration, 0.0); - EXPECT_DOUBLE_EQ(active_tolerances.goal_state_tolerance.at(1).position, 0.1); - EXPECT_DOUBLE_EQ( - active_tolerances.goal_state_tolerance.at(1).velocity, stopped_velocity_tolerance); - EXPECT_DOUBLE_EQ(active_tolerances.goal_state_tolerance.at(1).acceleration, 0.0); - EXPECT_DOUBLE_EQ(active_tolerances.goal_state_tolerance.at(2).position, 0.1); - EXPECT_DOUBLE_EQ( - active_tolerances.goal_state_tolerance.at(2).velocity, stopped_velocity_tolerance); - EXPECT_DOUBLE_EQ(active_tolerances.goal_state_tolerance.at(2).acceleration, 0.0); -} - -#endif // TEST_TOLERANCES_UTILS_HPP_ diff --git a/joint_trajectory_controller/test/test_trajectory_actions.cpp b/joint_trajectory_controller/test/test_trajectory_actions.cpp index c626326cc8..fb749ac250 100644 --- a/joint_trajectory_controller/test/test_trajectory_actions.cpp +++ b/joint_trajectory_controller/test/test_trajectory_actions.cpp @@ -47,7 +47,6 @@ #include "trajectory_msgs/msg/joint_trajectory_point.hpp" #include "joint_trajectory_controller/joint_trajectory_controller.hpp" -#include "test_tolerances_utils.hpp" #include "test_trajectory_controller_utils.hpp" using std::placeholders::_1; diff --git a/joint_trajectory_controller/test/test_trajectory_controller_utils.hpp b/joint_trajectory_controller/test/test_trajectory_controller_utils.hpp index f0ccacee5b..693e19e67a 100644 --- a/joint_trajectory_controller/test/test_trajectory_controller_utils.hpp +++ b/joint_trajectory_controller/test/test_trajectory_controller_utils.hpp @@ -25,6 +25,7 @@ #include "hardware_interface/types/hardware_interface_type_values.hpp" #include "joint_trajectory_controller/joint_trajectory_controller.hpp" +#include "joint_trajectory_controller/tolerances.hpp" namespace { @@ -38,6 +39,40 @@ const std::vector INITIAL_VEL_JOINTS = {0.0, 0.0, 0.0}; const std::vector INITIAL_ACC_JOINTS = {0.0, 0.0, 0.0}; const std::vector INITIAL_EFF_JOINTS = {0.0, 0.0, 0.0}; +const double default_goal_time = 0.1; +const double stopped_velocity_tolerance = 0.1; + +[[maybe_unused]] void expectDefaultTolerances( + joint_trajectory_controller::SegmentTolerances active_tolerances) +{ + // acceleration is never set, and goal_state_tolerance.velocity from stopped_velocity_tolerance + + ASSERT_EQ(active_tolerances.state_tolerance.size(), 3); + EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(0).position, 0.1); + EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(0).velocity, 0.0); + EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(0).acceleration, 0.0); + EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(1).position, 0.1); + EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(1).velocity, 0.0); + EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(1).acceleration, 0.0); + EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(2).position, 0.1); + EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(2).velocity, 0.0); + EXPECT_DOUBLE_EQ(active_tolerances.state_tolerance.at(2).acceleration, 0.0); + + ASSERT_EQ(active_tolerances.goal_state_tolerance.size(), 3); + EXPECT_DOUBLE_EQ(active_tolerances.goal_state_tolerance.at(0).position, 0.1); + EXPECT_DOUBLE_EQ( + active_tolerances.goal_state_tolerance.at(0).velocity, stopped_velocity_tolerance); + EXPECT_DOUBLE_EQ(active_tolerances.goal_state_tolerance.at(0).acceleration, 0.0); + EXPECT_DOUBLE_EQ(active_tolerances.goal_state_tolerance.at(1).position, 0.1); + EXPECT_DOUBLE_EQ( + active_tolerances.goal_state_tolerance.at(1).velocity, stopped_velocity_tolerance); + EXPECT_DOUBLE_EQ(active_tolerances.goal_state_tolerance.at(1).acceleration, 0.0); + EXPECT_DOUBLE_EQ(active_tolerances.goal_state_tolerance.at(2).position, 0.1); + EXPECT_DOUBLE_EQ( + active_tolerances.goal_state_tolerance.at(2).velocity, stopped_velocity_tolerance); + EXPECT_DOUBLE_EQ(active_tolerances.goal_state_tolerance.at(2).acceleration, 0.0); +} + bool is_same_sign_or_zero(double val1, double val2) { return val1 * val2 > 0.0 || (val1 == 0.0 && val2 == 0.0);