From 33fd1190acdf2675e4ed042577b8fe5bcba52654 Mon Sep 17 00:00:00 2001 From: Mirko Waechter <mirko.waechter@kit.edu> Date: Thu, 5 Jan 2017 20:21:20 +0100 Subject: [PATCH] added simple pid controller sanity test --- .../libraries/core/test/CMakeLists.txt | 1 + .../libraries/core/test/PIDControllerTest.cpp | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 source/RobotAPI/libraries/core/test/PIDControllerTest.cpp diff --git a/source/RobotAPI/libraries/core/test/CMakeLists.txt b/source/RobotAPI/libraries/core/test/CMakeLists.txt index 35d29e49c..83127d642 100644 --- a/source/RobotAPI/libraries/core/test/CMakeLists.txt +++ b/source/RobotAPI/libraries/core/test/CMakeLists.txt @@ -1,4 +1,5 @@ set(LIBS ${LIBS} RobotAPICore ) armarx_add_test(TrajectoryTest TrajectoryTest.cpp "${LIBS}") +armarx_add_test(PIDControllerTest PIDControllerTest.cpp "${LIBS}") diff --git a/source/RobotAPI/libraries/core/test/PIDControllerTest.cpp b/source/RobotAPI/libraries/core/test/PIDControllerTest.cpp new file mode 100644 index 000000000..85ec430aa --- /dev/null +++ b/source/RobotAPI/libraries/core/test/PIDControllerTest.cpp @@ -0,0 +1,41 @@ +/* +* This file is part of ArmarX. +* +* ArmarX is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* ArmarX is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +* +* @package ArmarX::RobotAPI::Test +* @author Nils Adermann (naderman at naderman dot de) +* @date 2010 +* @copyright http://www.gnu.org/licenses/gpl-2.0.txt +* GNU General Public License +*/ + +#define BOOST_TEST_MODULE RobotAPI::PIDController::Test +#define ARMARX_BOOST_TEST +#include <RobotAPI/Test.h> +#include <ArmarXCore/core/test/IceTestHelper.h> +#include <ArmarXCore/util/json/JSONObject.h> +#include "../PIDController.h" +using namespace armarx; + + +BOOST_AUTO_TEST_CASE(PIDControllerTest) +{ + PIDController c(1, 0, 0, 0.1, 0.1); + c.update(0.1, 0, 1); + ARMARX_INFO << "velocity: " << c.getControlValue(); + BOOST_CHECK_LE(c.getControlValue(), 0.1); + BOOST_CHECK_LE(c.controlValueDerivation, 0.11); + +} + -- GitLab