FramedOrientedPoint.cpp
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* ArmarX is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License version 2 as
6* published by the Free Software Foundation.
7*
8* ArmarX is distributed in the hope that it will be useful, but
9* WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program. If not, see <http://www.gnu.org/licenses/>.
15*
16* @author Martin Miller (martin dot miller at student dot kit dot edu)
17* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
18* GNU General Public License
19*/
20
21#include "FramedOrientedPoint.h"
22
23#include <VirtualRobot/LinkedCoordinate.h>
24#include <VirtualRobot/Robot.h>
25#include <VirtualRobot/VirtualRobot.h>
26
28
29namespace armarx
30{
32
34 IceUtil::Shared(source),
35 armarx::Serializable(source),
36 OrientedPointBase(source),
37 FramedOrientedPointBase(source),
38 OrientedPoint(source)
39 {
40 }
41
42 FramedOrientedPoint::FramedOrientedPoint(const Eigen::Vector3f& position,
43 const Eigen::Vector3f& normal,
44 const std::string& frame,
45 const std::string& agent) :
46 OrientedPoint(position, normal)
47 {
48 this->frame = frame;
49 this->agent = agent;
50 }
51
53 const std::string& frame,
54 const std::string& agent) :
55 FramedOrientedPoint(pointWithNormal.positionToEigen(),
56 pointWithNormal.normalToEigen(),
57 frame,
58 agent)
59 {
60 }
61
63 ::Ice::Float py,
64 ::Ice::Float pz,
65 Ice::Float nx,
66 ::Ice::Float ny,
67 ::Ice::Float nz,
68 const std::string& frame,
69 const std::string& agent) :
70 OrientedPoint(px, py, pz, nx, ny, nz)
71 {
72 this->frame = frame;
73 this->agent = agent;
74 }
75
76 std::string
78 {
79 return frame;
80 }
81
82 void
84 const std::string& newFrame)
85 {
86 FramedPosition framedPos(positionToEigen(), frame, agent);
87 FramedDirection framedDir(normalToEigen(), frame, agent);
88
89 framedPos.changeFrame(robot, newFrame);
90 framedDir.changeFrame(robot, newFrame);
91 this->px = framedPos.x;
92 this->py = framedPos.y;
93 this->pz = framedPos.z;
94
95 this->nx = framedDir.x;
96 this->ny = framedDir.y;
97 this->nz = framedDir.z;
98 }
99
100 void
102 {
103 VirtualRobot::RobotPtr sharedRobot(new RemoteRobot(referenceRobot));
104 changeFrame(sharedRobot, GlobalFrame);
105 }
106
107 void
109 {
110 changeFrame(referenceRobot, GlobalFrame);
111 }
112
113 Eigen::Vector3f
115 {
116 return getFramedPosition().toGlobalEigen(referenceRobot);
117 }
118
119 Eigen::Vector3f
121 {
122 return getFramedNormal().toGlobalEigen(referenceRobot);
123 }
124
125 Eigen::Vector3f
127 {
128 return getFramedPosition().toGlobalEigen(referenceRobot);
129 }
130
131 Eigen::Vector3f
133 {
134 return getFramedNormal().toGlobalEigen(referenceRobot);
135 }
136
139 {
140 return new FramedOrientedPoint(
141 positionToRootEigen(referenceRobot), normalToRootEigen(referenceRobot), frame, agent);
142 }
143
146 {
147 return new FramedOrientedPoint(
148 positionToRootEigen(referenceRobot), normalToRootEigen(referenceRobot), frame, agent);
149 }
150
151 Eigen::Vector3f
153 {
154 return getFramedPosition().toRootEigen(referenceRobot);
155 }
156
157 Eigen::Vector3f
159 {
160 return getFramedNormal().toRootEigen(referenceRobot);
161 }
162
163 Eigen::Vector3f
165 {
166 return getFramedPosition().toRootEigen(referenceRobot);
167 }
168
169 Eigen::Vector3f
171 {
172 return getFramedNormal().toRootEigen(referenceRobot);
173 }
174
177 {
178 return FramedPosition(positionToEigen(), frame, agent);
179 }
180
183 {
184 return FramedDirection(normalToEigen(), frame, agent);
185 }
186
187 std::string
188 FramedOrientedPoint::output(const Ice::Current& c) const
189 {
190 std::stringstream s;
191 s << OrientedPoint::output(c) << std::endl
192 << "frame: " << getFrame() << (agent.empty() ? "" : (" agent: " + agent));
193 return s.str();
194 }
195
196 void
197 FramedOrientedPoint::serialize(const ObjectSerializerBasePtr& serializer,
198 const Ice::Current&) const
199 {
200 AbstractObjectSerializerPtr obj = AbstractObjectSerializerPtr::dynamicCast(serializer);
201 OrientedPoint::serialize(serializer);
202 obj->setString("frame", frame);
203 obj->setString("agent", agent);
204 }
205
206 void
207 FramedOrientedPoint::deserialize(const ObjectSerializerBasePtr& serializer, const Ice::Current&)
208 {
209 AbstractObjectSerializerPtr obj = AbstractObjectSerializerPtr::dynamicCast(serializer);
210 OrientedPoint::deserialize(serializer);
211 frame = obj->getString("frame");
212
213 if (obj->hasElement("agent"))
214 {
215 agent = obj->getString("agent");
216 }
217 }
218} // namespace armarx
constexpr T c
FramedDirection is a 3 dimensional direction vector with a reference frame.
Definition FramedPose.h:87
Eigen::Vector3f toGlobalEigen(const SharedRobotInterfacePrx &referenceRobot) const
Eigen::Vector3f toRootEigen(const SharedRobotInterfacePrx &referenceRobot) const
void changeFrame(const VirtualRobot::RobotConstPtr &robot, const std::string &newFrame)
Eigen::Vector3f positionToGlobalEigen(const SharedRobotInterfacePrx &referenceRobot) const
std::string output(const Ice::Current &c=Ice::emptyCurrent) const override
FramedPosition getFramedPosition() const
FramedDirection getFramedNormal() const
Eigen::Vector3f normalToRootEigen(const SharedRobotInterfacePrx &referenceRobot) const
FramedOrientedPointPtr toRootFrame(const SharedRobotInterfacePrx &referenceRobot) const
Eigen::Vector3f normalToGlobalEigen(const SharedRobotInterfacePrx &referenceRobot) const
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
void changeToGlobal(const SharedRobotInterfacePrx &referenceRobot)
Eigen::Vector3f positionToRootEigen(const SharedRobotInterfacePrx &referenceRobot) const
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
void changeFrame(const VirtualRobot::RobotPtr &robot, const std::string &newFrame)
The FramedPosition class.
Definition FramedPose.h:158
Eigen::Vector3f toGlobalEigen(const SharedRobotInterfacePrx &referenceRobot) const
Eigen::Vector3f toRootEigen(const SharedRobotInterfacePrx &referenceRobot) const
void changeFrame(const SharedRobotInterfacePrx &referenceRobot, const std::string &newFrame)
std::string output(const Ice::Current &c=Ice::emptyCurrent) const override
virtual Eigen::Vector3f normalToEigen() const
virtual Eigen::Vector3f positionToEigen() const
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
Mimics the behaviour of the VirtualRobot::Robot class while redirecting everything to an Ice proxy.
std::string const GlobalFrame
Variable of the global coordinate system.
Definition FramedPose.h:65
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< AbstractObjectSerializer > AbstractObjectSerializerPtr
::IceInternal::ProxyHandle<::IceProxy::armarx::SharedRobotInterface > SharedRobotInterfacePrx
Definition FramedPose.h:59
IceInternal::Handle< FramedOrientedPoint > FramedOrientedPointPtr