diff --git a/VirtualRobot/CMakeLists.txt b/VirtualRobot/CMakeLists.txt index f273eb11beca7fe48d7848b267ef2d644a12e5ef..91f960db76c2885df53d1927aa5039ee76c35b98 100644 --- a/VirtualRobot/CMakeLists.txt +++ b/VirtualRobot/CMakeLists.txt @@ -178,6 +178,7 @@ math/Kernels.cpp math/Line.cpp math/LinearContinuedBezier.cpp math/LinearInterpolatedOrientation.cpp +math/LinearInterpolatedPose.cpp math/LineR2.cpp math/LineStrip.cpp math/MarchingCubes.cpp @@ -345,6 +346,7 @@ math/LineStrip.h math/LineStripR1RM.h math/LinearContinuedBezier.h math/LinearInterpolatedOrientation.h +math/LinearInterpolatedPose.h math/MarchingCubes.h math/MathForwardDefinitions.h math/Plane.h diff --git a/VirtualRobot/math/LinearInterpolatedOrientation.h b/VirtualRobot/math/LinearInterpolatedOrientation.h index e506ce97bb641fadf2e0286b176ffe346040b353..1754029be3c9bf71c259c0ef112792b8f815032c 100644 --- a/VirtualRobot/math/LinearInterpolatedOrientation.h +++ b/VirtualRobot/math/LinearInterpolatedOrientation.h @@ -25,9 +25,7 @@ #include "AbstractFunctionR1Ori.h" #include "MathForwardDefinitions.h" -#ifndef Q_MOC_RUN // workaround for some bug in some QT/boost versions -#include <boost/shared_ptr.hpp> -#endif + namespace math { diff --git a/VirtualRobot/math/LinearInterpolatedPose.cpp b/VirtualRobot/math/LinearInterpolatedPose.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b49ce0322ffb2067b7cda63559018d2d8533f7d9 --- /dev/null +++ b/VirtualRobot/math/LinearInterpolatedPose.cpp @@ -0,0 +1,44 @@ +/** + * This file is part of Simox. + * + * Simox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * Simox 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @author Simon Ottenhaus (simon dot ottenhaus at kit dot edu) + * @copyright 2019 Simon Ottenhaus + * GNU Lesser General Public License + */ + +#include "LinearInterpolatedPose.h" +#include "Helpers.h" + +using namespace math; + +LinearInterpolatedPose::LinearInterpolatedPose(const Eigen::Matrix4f &startPose, const Eigen::Matrix4f &endPose, float startT, float endT, bool clamp) + : ori(Helpers::GetOrientation(startPose), Helpers::GetOrientation(endPose), startT, endT, clamp), + startPos(Helpers::GetPosition(startPose)), + endPos(Helpers::GetPosition(endPose)), + startT(startT), endT(endT), clamp(clamp) +{ + +} + +Eigen::Matrix4f LinearInterpolatedPose::Get(float t) +{ + float f = Helpers::ILerp(startT, endT, t); + if(clamp) + { + f = Helpers::Clamp(0, 1, f); + } + return Helpers::CreatePose(Helpers::Lerp(startPos, endPos, f), ori.Get(t)); +} diff --git a/VirtualRobot/math/LinearInterpolatedPose.h b/VirtualRobot/math/LinearInterpolatedPose.h new file mode 100644 index 0000000000000000000000000000000000000000..7b1e33f28f8dcb47493ac107b43aa1ea48bdbaa0 --- /dev/null +++ b/VirtualRobot/math/LinearInterpolatedPose.h @@ -0,0 +1,46 @@ +/** + * This file is part of Simox. + * + * Simox is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * Simox 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * @author Simon Ottenhaus (simon dot ottenhaus at kit dot edu) + * @copyright 2019 Simon Ottenhaus + * GNU Lesser General Public License + */ + +#pragma once + +#include "MathForwardDefinitions.h" +#include "LinearInterpolatedOrientation.h" + + +namespace math +{ + + class LinearInterpolatedPose + { + public: + LinearInterpolatedPose(const Eigen::Matrix4f& startPose, const Eigen::Matrix4f& endPose, float startT, float endT, bool clamp); + + Eigen::Matrix4f Get(float t); + + private: + math::LinearInterpolatedOrientation ori; + Eigen::Vector3f startPos; + Eigen::Vector3f endPos; + float startT; + float endT; + bool clamp; + }; +} diff --git a/VirtualRobot/math/MathForwardDefinitions.h b/VirtualRobot/math/MathForwardDefinitions.h index f5213a9af794e772da7663163cd3f8ab86652616..b260249427c4b8c3a8a5352fa089325fd5149396 100644 --- a/VirtualRobot/math/MathForwardDefinitions.h +++ b/VirtualRobot/math/MathForwardDefinitions.h @@ -93,6 +93,7 @@ namespace math typedef boost::shared_ptr<class SimpleAbstractFunctionR2R3> SimpleAbstractFunctionR2R3Ptr; typedef boost::shared_ptr<class SimpleAbstractFunctionR3R1> SimpleAbstractFunctionR3R1Ptr; typedef boost::shared_ptr<class LinearInterpolatedOrientation> LinearInterpolatedOrientationPtr; + typedef boost::shared_ptr<class LinearInterpolatedPose> LinearInterpolatedPosePtr; typedef boost::shared_ptr<class AbstractFunctionR1Ori> AbstractFunctionR1OriPtr; typedef boost::shared_ptr<class SimpleAbstractFunctionR1Ori> SimpleAbstractFunctionR1OriPtr; typedef boost::shared_ptr<class CompositeFunctionR1R6> CompositeFunctionR1R6Ptr;