diff --git a/source/RobotAPI/interface/CMakeLists.txt b/source/RobotAPI/interface/CMakeLists.txt index 76f16c7817f43ef69a4b29d6efb5f200d5726212..34dae6a594d0b94460b795d6119ed70f890fd8a1 100644 --- a/source/RobotAPI/interface/CMakeLists.txt +++ b/source/RobotAPI/interface/CMakeLists.txt @@ -12,7 +12,7 @@ set(SLICE_FILES observers/ObserverFilters.ice core/PoseBase.ice - core/PointWithNormal.ice + core/OrientedPoint.ice core/LinkedPoseBase.ice core/FramedPoseBase.ice core/RobotState.ice diff --git a/source/RobotAPI/interface/core/PointWithNormal.ice b/source/RobotAPI/interface/core/OrientedPoint.ice similarity index 84% rename from source/RobotAPI/interface/core/PointWithNormal.ice rename to source/RobotAPI/interface/core/OrientedPoint.ice index 46311439bdc97c6b76855ae96367ba69cb1f462e..28bbdfba3b6e4dc4f79d4c2e8d3561c1a3d9f724 100644 --- a/source/RobotAPI/interface/core/PointWithNormal.ice +++ b/source/RobotAPI/interface/core/OrientedPoint.ice @@ -31,7 +31,7 @@ module armarx /** * [PointsWithNormalBase] defines a 3D point with normal. */ - class PointWithNormalBase extends VariantDataClass + class OrientedPointBase extends VariantDataClass { float px = zeroInt; float py = zeroInt; @@ -43,13 +43,13 @@ module armarx }; /** - * [FramedPointWithNormalBase] defines a PointWithNormal with regard to an agent and a frame within the agent. - * If agent is empty and frame is set to armarx::GlobalFrame, PointWithNormal is defined in global frame. + * [FramedOrientedPointBase] defines a OrientedPoint with regard to an agent and a frame within the agent. + * If agent is empty and frame is set to armarx::GlobalFrame, OrientedPoint is defined in global frame. * @param frame Name of frame. * @param frame Name of agent. */ ["cpp:virtual"] - class FramedPointWithNormalBase extends PointWithNormalBase + class FramedOrientedPointBase extends OrientedPointBase { string frame; string agent; diff --git a/source/RobotAPI/libraries/core/CMakeLists.txt b/source/RobotAPI/libraries/core/CMakeLists.txt index c2d56b38db79dd9829c81e202607712783625fed..05a4af6d9f1f88c93349ee33c25da9464368053a 100644 --- a/source/RobotAPI/libraries/core/CMakeLists.txt +++ b/source/RobotAPI/libraries/core/CMakeLists.txt @@ -25,8 +25,8 @@ set(LIB_FILES Pose.cpp FramedPose.cpp LinkedPose.cpp - PointWithNormal.cpp - FramedPointWithNormal.cpp + OrientedPoint.cpp + FramedOrientedPoint.cpp RobotStatechartContext.cpp checks/ConditionCheckMagnitudeChecks.cpp observerfilters/PoseMedianOffsetFilter.cpp @@ -42,8 +42,8 @@ set(LIB_HEADERS Pose.h FramedPose.h LinkedPose.h - PointWithNormal.h - FramedPointWithNormal.h + OrientedPoint.h + FramedOrientedPoint.h RobotStatechartContext.h observerfilters/PoseMedianFilter.h observerfilters/PoseMedianOffsetFilter.h diff --git a/source/RobotAPI/libraries/core/FramedOrientedPoint.cpp b/source/RobotAPI/libraries/core/FramedOrientedPoint.cpp new file mode 100644 index 0000000000000000000000000000000000000000..411c8ea9717228e633165e5eb1dc3f6e36169f21 --- /dev/null +++ b/source/RobotAPI/libraries/core/FramedOrientedPoint.cpp @@ -0,0 +1,188 @@ +/* +* 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/>. +* +* @author Martin Miller (martin dot miller at student dot kit dot edu) +* @copyright http://www.gnu.org/licenses/gpl-2.0.txt +* GNU General Public License +*/ + +#include "FramedOrientedPoint.h" + +#include <VirtualRobot/Robot.h> +#include <VirtualRobot/LinkedCoordinate.h> +#include <VirtualRobot/LinkedCoordinate.h> +#include <VirtualRobot/VirtualRobot.h> + +#include <RobotAPI/libraries/core/remoterobot/RemoteRobot.h> + +using namespace armarx; + + + +FramedOrientedPoint::FramedOrientedPoint() +{ +} + +FramedOrientedPoint::FramedOrientedPoint(const FramedOrientedPoint& source) : + IceUtil::Shared(source), + OrientedPointBase(source), + FramedOrientedPointBase(source) +{ +} + +FramedOrientedPoint::FramedOrientedPoint(const Eigen::Vector3f& position, const Eigen::Vector3f& normal, const std::string& frame, const std::string& agent) : + OrientedPoint(position, normal) +{ + this->frame = frame; + this->agent = agent; + +} + +FramedOrientedPoint::FramedOrientedPoint(const OrientedPoint& pointWithNormal, const std::string& frame, const std::string& agent) : + FramedOrientedPoint(pointWithNormal.positionToEigen(), pointWithNormal.normalToEigen(), frame, agent) +{ +} + +FramedOrientedPoint::FramedOrientedPoint(Ice::Float px, ::Ice::Float py, ::Ice::Float pz, Ice::Float nx, ::Ice::Float ny, ::Ice::Float nz, const std::string& frame, const std::string& agent) : + OrientedPoint(px, py, pz, nx, ny, nz) +{ + this->frame = frame; + this->agent = agent; +} + +std::string FramedOrientedPoint::getFrame() const +{ + return frame; +} + + +void FramedOrientedPoint::changeFrame(const VirtualRobot::RobotPtr& robot, const std::string& newFrame) +{ + FramedPosition framedPos(positionToEigen(), frame, agent); + FramedDirection framedDir(normalToEigen(), frame, agent); + + framedPos.changeFrame(robot, newFrame); + framedDir.changeFrame(robot, newFrame); + this->px = framedPos.x; + this->py = framedPos.y; + this->pz = framedPos.z; + + this->nx = framedDir.x; + this->ny = framedDir.y; + this->nz = framedDir.z; +} + +void FramedOrientedPoint::changeToGlobal(const SharedRobotInterfacePrx& referenceRobot) +{ + VirtualRobot::RobotPtr sharedRobot(new RemoteRobot(referenceRobot)); + changeFrame(sharedRobot, GlobalFrame); +} + +void FramedOrientedPoint::changeToGlobal(const VirtualRobot::RobotPtr& referenceRobot) +{ + changeFrame(referenceRobot, GlobalFrame); +} + +Eigen::Vector3f FramedOrientedPoint::positionToGlobalEigen(const SharedRobotInterfacePrx& referenceRobot) const +{ + return getFramedPosition().toGlobalEigen(referenceRobot); +} + +Eigen::Vector3f FramedOrientedPoint::normalToGlobalEigen(const SharedRobotInterfacePrx& referenceRobot) const +{ + return getFramedNormal().toGlobalEigen(referenceRobot); +} + +Eigen::Vector3f FramedOrientedPoint::positionToGlobalEigen(const VirtualRobot::RobotPtr& referenceRobot) const +{ + return getFramedPosition().toGlobalEigen(referenceRobot); +} + +Eigen::Vector3f FramedOrientedPoint::normalToGlobalEigen(const VirtualRobot::RobotPtr& referenceRobot) const +{ + return getFramedNormal().toGlobalEigen(referenceRobot); +} + + +FramedOrientedPointPtr FramedOrientedPoint::toRootFrame(const SharedRobotInterfacePrx& referenceRobot) const +{ + return new FramedOrientedPoint(positionToRootEigen(referenceRobot), normalToRootEigen(referenceRobot), frame, agent); +} + +FramedOrientedPointPtr FramedOrientedPoint::toRootFrame(const VirtualRobot::RobotPtr& referenceRobot) const +{ + return new FramedOrientedPoint(positionToRootEigen(referenceRobot), normalToRootEigen(referenceRobot), frame, agent); +} + +Eigen::Vector3f FramedOrientedPoint::positionToRootEigen(const SharedRobotInterfacePrx& referenceRobot) const +{ + return getFramedPosition().toRootEigen(referenceRobot); +} + +Eigen::Vector3f FramedOrientedPoint::normalToRootEigen(const SharedRobotInterfacePrx& referenceRobot) const +{ + return getFramedNormal().toRootEigen(referenceRobot); +} + +Eigen::Vector3f FramedOrientedPoint::positionToRootEigen(const VirtualRobot::RobotPtr& referenceRobot) const +{ + return getFramedPosition().toRootEigen(referenceRobot); +} + +Eigen::Vector3f FramedOrientedPoint::normalToRootEigen(const VirtualRobot::RobotPtr& referenceRobot) const +{ + return getFramedNormal().toRootEigen(referenceRobot); +} + +FramedPosition FramedOrientedPoint::getFramedPosition() const +{ + return FramedPosition(positionToEigen(), frame, agent); +} + +FramedDirection FramedOrientedPoint::getFramedNormal() const +{ + return FramedDirection(normalToEigen(), frame, agent); +} + + +std::string FramedOrientedPoint::output(const Ice::Current& c) const +{ + std::stringstream s; + s << OrientedPoint::output(c) << std::endl << "frame: " << getFrame() << (agent.empty() ? "" : (" agent: " + agent)); + return s.str(); +} + + +void FramedOrientedPoint::serialize(const ObjectSerializerBasePtr& serializer, const Ice::Current&) const +{ + AbstractObjectSerializerPtr obj = AbstractObjectSerializerPtr::dynamicCast(serializer); + OrientedPoint::serialize(serializer); + obj->setString("frame", frame); + obj->setString("agent", agent); + +} + +void FramedOrientedPoint::deserialize(const ObjectSerializerBasePtr& serializer, const Ice::Current&) +{ + AbstractObjectSerializerPtr obj = AbstractObjectSerializerPtr::dynamicCast(serializer); + OrientedPoint::deserialize(serializer); + frame = obj->getString("frame"); + + if (obj->hasElement("agent")) + { + agent = obj->getString("agent"); + } +} + diff --git a/source/RobotAPI/libraries/core/FramedPointWithNormal.h b/source/RobotAPI/libraries/core/FramedOrientedPoint.h similarity index 65% rename from source/RobotAPI/libraries/core/FramedPointWithNormal.h rename to source/RobotAPI/libraries/core/FramedOrientedPoint.h index a1e60b9b170041f6bc90588da08928acc03b3399..f22149196e3ae8399166c1fac45c6882a27d3bed 100644 --- a/source/RobotAPI/libraries/core/FramedPointWithNormal.h +++ b/source/RobotAPI/libraries/core/FramedOrientedPoint.h @@ -18,11 +18,11 @@ * GNU General Public License */ -#ifndef ARMARX_RobotAPI_FramedPointWithNormal_H -#define ARMARX_RobotAPI_FramedPointWithNormal_H +#ifndef ARMARX_RobotAPI_FramedOrientedPoint_H +#define ARMARX_RobotAPI_FramedOrientedPoint_H -#include "PointWithNormal.h" +#include "OrientedPoint.h" #include <VirtualRobot/Robot.h> #include <VirtualRobot/LinkedCoordinate.h> @@ -37,36 +37,36 @@ namespace armarx namespace VariantType { // variant types - const VariantTypeId FramedPointWithNormal = Variant::addTypeName("::armarx::FramedPointWithNormalBase"); + const VariantTypeId FramedOrientedPoint = Variant::addTypeName("::armarx::FramedOrientedPointBase"); } - class FramedPointWithNormal; - typedef IceInternal::Handle<FramedPointWithNormal> FramedPointWithNormalPtr; + class FramedOrientedPoint; + typedef IceInternal::Handle<FramedOrientedPoint> FramedOrientedPointPtr; - class FramedPointWithNormal : - virtual public FramedPointWithNormalBase, - virtual public PointWithNormal + class FramedOrientedPoint : + virtual public FramedOrientedPointBase, + virtual public OrientedPoint { public: - FramedPointWithNormal(); - FramedPointWithNormal(const FramedPointWithNormal& source); - FramedPointWithNormal(const Eigen::Vector3f& position, const Eigen::Vector3f& normal, const std::string& frame, const std::string& agent); - FramedPointWithNormal(const PointWithNormal& pointWithNormal, const std::string& frame, const std::string& agent); - FramedPointWithNormal(Ice::Float px, ::Ice::Float py, ::Ice::Float pz, Ice::Float nx, ::Ice::Float ny, ::Ice::Float nz, const std::string& frame, const std::string& agent); + FramedOrientedPoint(); + FramedOrientedPoint(const FramedOrientedPoint& source); + FramedOrientedPoint(const Eigen::Vector3f& position, const Eigen::Vector3f& normal, const std::string& frame, const std::string& agent); + FramedOrientedPoint(const OrientedPoint& pointWithNormal, const std::string& frame, const std::string& agent); + FramedOrientedPoint(Ice::Float px, ::Ice::Float py, ::Ice::Float pz, Ice::Float nx, ::Ice::Float ny, ::Ice::Float nz, const std::string& frame, const std::string& agent); std::string getFrame() const; void changeFrame(const VirtualRobot::RobotPtr& robot, const std::string& newFrame); void changeToGlobal(const SharedRobotInterfacePrx& referenceRobot); void changeToGlobal(const VirtualRobot::RobotPtr& referenceRobot); - FramedPointWithNormalPtr toGlobal(const SharedRobotInterfacePrx& referenceRobot) const; - FramedPointWithNormalPtr toGlobal(const VirtualRobot::RobotPtr& referenceRobot) const; + FramedOrientedPointPtr toGlobal(const SharedRobotInterfacePrx& referenceRobot) const; + FramedOrientedPointPtr toGlobal(const VirtualRobot::RobotPtr& referenceRobot) const; Eigen::Vector3f positionToGlobalEigen(const SharedRobotInterfacePrx& referenceRobot) const; Eigen::Vector3f normalToGlobalEigen(const SharedRobotInterfacePrx& referenceRobot) const; Eigen::Vector3f positionToGlobalEigen(const VirtualRobot::RobotPtr& referenceRobot) const; Eigen::Vector3f normalToGlobalEigen(const VirtualRobot::RobotPtr& referenceRobot) const; - FramedPointWithNormalPtr toRootFrame(const SharedRobotInterfacePrx& referenceRobot) const; - FramedPointWithNormalPtr toRootFrame(const VirtualRobot::RobotPtr& referenceRobot) const; + FramedOrientedPointPtr toRootFrame(const SharedRobotInterfacePrx& referenceRobot) const; + FramedOrientedPointPtr toRootFrame(const VirtualRobot::RobotPtr& referenceRobot) const; Eigen::Vector3f positionToRootEigen(const SharedRobotInterfacePrx& referenceRobot) const; Eigen::Vector3f normalToRootEigen(const SharedRobotInterfacePrx& referenceRobot) const; Eigen::Vector3f positionToRootEigen(const VirtualRobot::RobotPtr& referenceRobot) const; @@ -82,21 +82,21 @@ namespace armarx } VariantDataClassPtr clone(const Ice::Current& c = ::Ice::Current()) const { - return new FramedPointWithNormal(*this); + return new FramedOrientedPoint(*this); } std::string output(const Ice::Current& c = ::Ice::Current()) const; VariantTypeId getType(const Ice::Current& c = ::Ice::Current()) const { - return VariantType::FramedPointWithNormal; + return VariantType::FramedOrientedPoint; } bool validate(const Ice::Current& c = ::Ice::Current()) { return true; } - friend std::ostream& operator<<(std::ostream& stream, const FramedPointWithNormal& rhs) + friend std::ostream& operator<<(std::ostream& stream, const FramedOrientedPoint& rhs) { - stream << "FramedPointWithNormal: " << std::endl << rhs.output() << std::endl; + stream << "FramedOrientedPoint: " << std::endl << rhs.output() << std::endl; return stream; } @@ -107,4 +107,4 @@ namespace armarx }; } -#endif // armarx_core_FramedPointWithNormal +#endif // armarx_core_FramedOrientedPoint diff --git a/source/RobotAPI/libraries/core/FramedPointWithNormal.cpp b/source/RobotAPI/libraries/core/FramedPointWithNormal.cpp deleted file mode 100644 index 6c68805760a75192c404b8d96a82126e78da895a..0000000000000000000000000000000000000000 --- a/source/RobotAPI/libraries/core/FramedPointWithNormal.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* -* 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/>. -* -* @author Martin Miller (martin dot miller at student dot kit dot edu) -* @copyright http://www.gnu.org/licenses/gpl-2.0.txt -* GNU General Public License -*/ - -#include "FramedPointWithNormal.h" - -#include <VirtualRobot/Robot.h> -#include <VirtualRobot/LinkedCoordinate.h> -#include <VirtualRobot/LinkedCoordinate.h> -#include <VirtualRobot/VirtualRobot.h> - -#include <RobotAPI/libraries/core/remoterobot/RemoteRobot.h> - -using namespace armarx; - - - -FramedPointWithNormal::FramedPointWithNormal() -{ -} - -FramedPointWithNormal::FramedPointWithNormal(const FramedPointWithNormal& source) : - IceUtil::Shared(source), - PointWithNormalBase(source), - FramedPointWithNormalBase(source) -{ -} - -FramedPointWithNormal::FramedPointWithNormal(const Eigen::Vector3f& position, const Eigen::Vector3f& normal, const std::string& frame, const std::string& agent) : - PointWithNormal(position, normal) -{ - this->frame = frame; - this->agent = agent; - -} - -FramedPointWithNormal::FramedPointWithNormal(const PointWithNormal& pointWithNormal, const std::string& frame, const std::string& agent) : - FramedPointWithNormal(pointWithNormal.positionToEigen(), pointWithNormal.normalToEigen(), frame, agent) -{ -} - -FramedPointWithNormal::FramedPointWithNormal(Ice::Float px, ::Ice::Float py, ::Ice::Float pz, Ice::Float nx, ::Ice::Float ny, ::Ice::Float nz, const std::string& frame, const std::string& agent) : - PointWithNormal(px, py, pz, nx, ny, nz) -{ - this->frame = frame; - this->agent = agent; -} - -std::string FramedPointWithNormal::getFrame() const -{ - return frame; -} - - -void FramedPointWithNormal::changeFrame(const VirtualRobot::RobotPtr& robot, const std::string& newFrame) -{ - FramedPosition framedPos(positionToEigen(), frame, agent); - FramedDirection framedDir(normalToEigen(), frame, agent); - - framedPos.changeFrame(robot, newFrame); - framedDir.changeFrame(robot, newFrame); - this->px = framedPos.x; - this->py = framedPos.y; - this->pz = framedPos.z; - - this->nx = framedDir.x; - this->ny = framedDir.y; - this->nz = framedDir.z; -} - -void FramedPointWithNormal::changeToGlobal(const SharedRobotInterfacePrx& referenceRobot) -{ - VirtualRobot::RobotPtr sharedRobot(new RemoteRobot(referenceRobot)); - changeFrame(sharedRobot, GlobalFrame); -} - -void FramedPointWithNormal::changeToGlobal(const VirtualRobot::RobotPtr& referenceRobot) -{ - changeFrame(referenceRobot, GlobalFrame); -} - -Eigen::Vector3f FramedPointWithNormal::positionToGlobalEigen(const SharedRobotInterfacePrx& referenceRobot) const -{ - return getFramedPosition().toGlobalEigen(referenceRobot); -} - -Eigen::Vector3f FramedPointWithNormal::normalToGlobalEigen(const SharedRobotInterfacePrx& referenceRobot) const -{ - return getFramedNormal().toGlobalEigen(referenceRobot); -} - -Eigen::Vector3f FramedPointWithNormal::positionToGlobalEigen(const VirtualRobot::RobotPtr& referenceRobot) const -{ - return getFramedPosition().toGlobalEigen(referenceRobot); -} - -Eigen::Vector3f FramedPointWithNormal::normalToGlobalEigen(const VirtualRobot::RobotPtr& referenceRobot) const -{ - return getFramedNormal().toGlobalEigen(referenceRobot); -} - - -FramedPointWithNormalPtr FramedPointWithNormal::toRootFrame(const SharedRobotInterfacePrx& referenceRobot) const -{ - return new FramedPointWithNormal(positionToRootEigen(referenceRobot), normalToRootEigen(referenceRobot), frame, agent); -} - -FramedPointWithNormalPtr FramedPointWithNormal::toRootFrame(const VirtualRobot::RobotPtr& referenceRobot) const -{ - return new FramedPointWithNormal(positionToRootEigen(referenceRobot), normalToRootEigen(referenceRobot), frame, agent); -} - -Eigen::Vector3f FramedPointWithNormal::positionToRootEigen(const SharedRobotInterfacePrx& referenceRobot) const -{ - return getFramedPosition().toRootEigen(referenceRobot); -} - -Eigen::Vector3f FramedPointWithNormal::normalToRootEigen(const SharedRobotInterfacePrx& referenceRobot) const -{ - return getFramedNormal().toRootEigen(referenceRobot); -} - -Eigen::Vector3f FramedPointWithNormal::positionToRootEigen(const VirtualRobot::RobotPtr& referenceRobot) const -{ - return getFramedPosition().toRootEigen(referenceRobot); -} - -Eigen::Vector3f FramedPointWithNormal::normalToRootEigen(const VirtualRobot::RobotPtr& referenceRobot) const -{ - return getFramedNormal().toRootEigen(referenceRobot); -} - -FramedPosition FramedPointWithNormal::getFramedPosition() const -{ - return FramedPosition(positionToEigen(), frame, agent); -} - -FramedDirection FramedPointWithNormal::getFramedNormal() const -{ - return FramedDirection(normalToEigen(), frame, agent); -} - - -std::string FramedPointWithNormal::output(const Ice::Current& c) const -{ - std::stringstream s; - s << PointWithNormal::output(c) << std::endl << "frame: " << getFrame() << (agent.empty() ? "" : (" agent: " + agent)); - return s.str(); -} - - -void FramedPointWithNormal::serialize(const ObjectSerializerBasePtr& serializer, const Ice::Current&) const -{ - AbstractObjectSerializerPtr obj = AbstractObjectSerializerPtr::dynamicCast(serializer); - PointWithNormal::serialize(serializer); - obj->setString("frame", frame); - obj->setString("agent", agent); - -} - -void FramedPointWithNormal::deserialize(const ObjectSerializerBasePtr& serializer, const Ice::Current&) -{ - AbstractObjectSerializerPtr obj = AbstractObjectSerializerPtr::dynamicCast(serializer); - PointWithNormal::deserialize(serializer); - frame = obj->getString("frame"); - - if (obj->hasElement("agent")) - { - agent = obj->getString("agent"); - } -} - diff --git a/source/RobotAPI/libraries/core/PointWithNormal.cpp b/source/RobotAPI/libraries/core/OrientedPoint.cpp similarity index 76% rename from source/RobotAPI/libraries/core/PointWithNormal.cpp rename to source/RobotAPI/libraries/core/OrientedPoint.cpp index c72a02eca8d29dff15f3b30d4712c8bf8b8550b4..7d4654a44dbc1ea7bcc9179ff5e611ff4e02934d 100644 --- a/source/RobotAPI/libraries/core/PointWithNormal.cpp +++ b/source/RobotAPI/libraries/core/OrientedPoint.cpp @@ -18,12 +18,12 @@ * GNU General Public License */ -#include "PointWithNormal.h" +#include "OrientedPoint.h" using namespace armarx; using namespace Eigen; -PointWithNormal::PointWithNormal() +OrientedPoint::OrientedPoint() { px = 0; py = 0; @@ -34,7 +34,7 @@ PointWithNormal::PointWithNormal() nz = 0; } -PointWithNormal::PointWithNormal(const Vector3f& position, const Vector3f& normal) +OrientedPoint::OrientedPoint(const Vector3f& position, const Vector3f& normal) { px = position(0); py = position(1); @@ -46,7 +46,7 @@ PointWithNormal::PointWithNormal(const Vector3f& position, const Vector3f& norma } -PointWithNormal::PointWithNormal(::Ice::Float px, ::Ice::Float py, ::Ice::Float pz, ::Ice::Float nx, ::Ice::Float ny, ::Ice::Float nz) +OrientedPoint::OrientedPoint(::Ice::Float px, ::Ice::Float py, ::Ice::Float pz, ::Ice::Float nx, ::Ice::Float ny, ::Ice::Float nz) { this->px = px; this->py = py; @@ -57,14 +57,14 @@ PointWithNormal::PointWithNormal(::Ice::Float px, ::Ice::Float py, ::Ice::Float this->nz = nz; } -Vector3f PointWithNormal::positionToEigen() const +Vector3f OrientedPoint::positionToEigen() const { Vector3f p; p << this->px, this->py, this->pz; return p; } -Vector3f PointWithNormal::normalToEigen() const +Vector3f OrientedPoint::normalToEigen() const { Vector3f n; n << this->nx, this->ny, this->nz; @@ -72,7 +72,7 @@ Vector3f PointWithNormal::normalToEigen() const } -std::string PointWithNormal::output(const Ice::Current& c) const +std::string OrientedPoint::output(const Ice::Current& c) const { Eigen::IOFormat vecfmt(Eigen::FullPrecision, 0, "", ", ", "", "", "(", ")"); std::stringstream s; @@ -80,7 +80,7 @@ std::string PointWithNormal::output(const Ice::Current& c) const return s.str(); } -void PointWithNormal::serialize(const ObjectSerializerBasePtr& serializer, const ::Ice::Current&) const +void OrientedPoint::serialize(const ObjectSerializerBasePtr& serializer, const ::Ice::Current&) const { AbstractObjectSerializerPtr obj = AbstractObjectSerializerPtr::dynamicCast(serializer); @@ -93,7 +93,7 @@ void PointWithNormal::serialize(const ObjectSerializerBasePtr& serializer, const obj->setFloat("nz", nz); } -void PointWithNormal::deserialize(const ObjectSerializerBasePtr& serializer, const ::Ice::Current& c) +void OrientedPoint::deserialize(const ObjectSerializerBasePtr& serializer, const ::Ice::Current& c) { AbstractObjectSerializerPtr obj = AbstractObjectSerializerPtr::dynamicCast(serializer); diff --git a/source/RobotAPI/libraries/core/PointWithNormal.h b/source/RobotAPI/libraries/core/OrientedPoint.h similarity index 72% rename from source/RobotAPI/libraries/core/PointWithNormal.h rename to source/RobotAPI/libraries/core/OrientedPoint.h index f295e69f65f55b85f7ef5787ff054b9c92695880..facef186ba63bc04a06b081a415fe74a15ed20a3 100644 --- a/source/RobotAPI/libraries/core/PointWithNormal.h +++ b/source/RobotAPI/libraries/core/OrientedPoint.h @@ -18,11 +18,11 @@ * GNU General Public License */ -#ifndef ARMARX_RobotAPI_PointWithNormal_H -#define ARMARX_RobotAPI_PointWithNormal_H +#ifndef ARMARX_RobotAPI_OrientedPoint_H +#define ARMARX_RobotAPI_OrientedPoint_H -#include <RobotAPI/interface/core/PointWithNormal.h> +#include <RobotAPI/interface/core/OrientedPoint.h> #include <ArmarXCore/observers/variant/Variant.h> #include <ArmarXCore/observers/AbstractObjectSerializer.h> @@ -36,17 +36,17 @@ namespace armarx namespace VariantType { // variant types - const VariantTypeId PointWithNormal = Variant::addTypeName("::armarx::PointWithNormalBase"); + const VariantTypeId OrientedPoint = Variant::addTypeName("::armarx::OrientedPointBase"); } - class PointWithNormal: - public virtual PointWithNormalBase + class OrientedPoint: + public virtual OrientedPointBase { public: - PointWithNormal(); - PointWithNormal(const Eigen::Vector3f& position, const Eigen::Vector3f& normal); - PointWithNormal(::Ice::Float px, ::Ice::Float py, ::Ice::Float pz, ::Ice::Float nx, ::Ice::Float ny, ::Ice::Float nz); + OrientedPoint(); + OrientedPoint(const Eigen::Vector3f& position, const Eigen::Vector3f& normal); + OrientedPoint(::Ice::Float px, ::Ice::Float py, ::Ice::Float pz, ::Ice::Float nx, ::Ice::Float ny, ::Ice::Float nz); virtual Eigen::Vector3f positionToEigen() const; virtual Eigen::Vector3f normalToEigen() const; @@ -58,21 +58,21 @@ namespace armarx } VariantDataClassPtr clone(const Ice::Current& c = ::Ice::Current()) const { - return new PointWithNormal(*this); + return new OrientedPoint(*this); } std::string output(const Ice::Current& c = ::Ice::Current()) const; VariantTypeId getType(const Ice::Current& c = ::Ice::Current()) const { - return VariantType::PointWithNormal; + return VariantType::OrientedPoint; } bool validate(const Ice::Current& c = ::Ice::Current()) { return true; } - friend std::ostream& operator<<(std::ostream& stream, const PointWithNormal& rhs) + friend std::ostream& operator<<(std::ostream& stream, const OrientedPoint& rhs) { - stream << "PointWithNormal: " << std::endl << rhs.output() << std::endl; + stream << "OrientedPoint: " << std::endl << rhs.output() << std::endl; return stream; } @@ -82,4 +82,4 @@ namespace armarx }; } -#endif // armarx_core_PointWithNormal +#endif // armarx_core_OrientedPoint diff --git a/source/RobotAPI/libraries/core/RobotAPIObjectFactories.h b/source/RobotAPI/libraries/core/RobotAPIObjectFactories.h index cfcbe2d9e761e3d0816a99e66fb6a449ef172f76..81ff0980712a4ffe79d12c7b2a4d0a91cdcd7a17 100644 --- a/source/RobotAPI/libraries/core/RobotAPIObjectFactories.h +++ b/source/RobotAPI/libraries/core/RobotAPIObjectFactories.h @@ -33,6 +33,8 @@ #include <RobotAPI/libraries/core/observerfilters/OffsetFilter.h> #include <RobotAPI/libraries/core/observerfilters/MatrixFilters.h> #include <RobotAPI/libraries/core/observerfilters/PoseMedianOffsetFilter.h> +#include <RobotAPI/libraries/core/OrientedPoint.h> +#include <RobotAPI/libraries/core/FramedOrientedPoint.h> namespace armarx { @@ -169,6 +171,9 @@ namespace armarx map.insert(std::make_pair(armarx::FramedPositionBase::ice_staticId(), new FramedPositionObjectFactory)); map.insert(std::make_pair(armarx::LinkedPoseBase::ice_staticId(), new LinkedPoseObjectFactory)); + add<armarx::OrientedPointBase, armarx::OrientedPoint>(map); + add<armarx::FramedOrientedPointBase, armarx::FramedOrientedPoint>(map); + add<armarx::PoseMedianFilterBase, armarx::filters::PoseMedianFilter>(map); add<armarx::PoseMedianOffsetFilterBase, armarx::filters::PoseMedianOffsetFilter>(map); add<armarx::OffsetFilterBase, armarx::filters::OffsetFilter>(map);