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 
29 namespace armarx
30 {
32 
34  IceUtil::Shared(source),
35  armarx::Serializable(source),
36  OrientedPointBase(source),
37  FramedOrientedPointBase(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
RemoteRobot.h
FramedOrientedPoint.h
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:919
armarx::OrientedPoint::deserialize
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: OrientedPoint.cpp:104
armarx::FramedOrientedPoint::getFramedPosition
FramedPosition getFramedPosition() const
Definition: FramedOrientedPoint.cpp:176
armarx::OrientedPoint::positionToEigen
virtual Eigen::Vector3f positionToEigen() const
Definition: OrientedPoint.cpp:65
armarx::FramedOrientedPoint::getFrame
std::string getFrame() const
Definition: FramedOrientedPoint.cpp:77
armarx::GlobalFrame
const std::string GlobalFrame
Definition: FramedPose.h:65
armarx::OrientedPoint
Definition: OrientedPoint.h:42
armarx::FramedDirection::toRootEigen
Eigen::Vector3f toRootEigen(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedPose.cpp:284
armarx::FramedOrientedPoint::deserialize
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: FramedOrientedPoint.cpp:207
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::FramedPosition::toRootEigen
Eigen::Vector3f toRootEigen(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedPose.cpp:924
armarx::FramedOrientedPoint::changeFrame
void changeFrame(const VirtualRobot::RobotPtr &robot, const std::string &newFrame)
Definition: FramedOrientedPoint.cpp:83
IceUtil
Definition: Instance.h:21
armarx::FramedPosition::toGlobalEigen
Eigen::Vector3f toGlobalEigen(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedPose.cpp:880
armarx::FramedOrientedPoint
Definition: FramedOrientedPoint.h:43
armarx::FramedOrientedPoint::output
std::string output(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: FramedOrientedPoint.cpp:188
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::FramedDirection::toGlobalEigen
Eigen::Vector3f toGlobalEigen(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedPose.cpp:240
armarx::FramedOrientedPoint::normalToGlobalEigen
Eigen::Vector3f normalToGlobalEigen(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedOrientedPoint.cpp:120
armarx::FramedOrientedPoint::FramedOrientedPoint
FramedOrientedPoint()
armarx::FramedOrientedPoint::changeToGlobal
void changeToGlobal(const SharedRobotInterfacePrx &referenceRobot)
Definition: FramedOrientedPoint.cpp:101
armarx::FramedPosition
The FramedPosition class.
Definition: FramedPose.h:157
armarx::FramedOrientedPoint::getFramedNormal
FramedDirection getFramedNormal() const
Definition: FramedOrientedPoint.cpp:182
armarx::FramedPosition::changeFrame
void changeFrame(const SharedRobotInterfacePrx &referenceRobot, const std::string &newFrame)
Definition: FramedPose.cpp:742
boost::source
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:661
armarx::FramedOrientedPoint::positionToGlobalEigen
Eigen::Vector3f positionToGlobalEigen(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedOrientedPoint.cpp:114
armarx::OrientedPoint::serialize
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: OrientedPoint.cpp:90
armarx::OrientedPoint::output
std::string output(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: OrientedPoint.cpp:81
armarx::FramedOrientedPoint::toRootFrame
FramedOrientedPointPtr toRootFrame(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedOrientedPoint.cpp:138
armarx::RemoteRobot
Mimics the behaviour of the VirtualRobot::Robot class while redirecting everything to an Ice proxy.
Definition: RemoteRobot.h:144
armarx::FramedDirection
FramedDirection is a 3 dimensional direction vector with a reference frame. The reference frame can b...
Definition: FramedPose.h:86
armarx::VariantType::FramedDirection
const VariantTypeId FramedDirection
Definition: FramedPose.h:37
armarx::FramedOrientedPoint::positionToRootEigen
Eigen::Vector3f positionToRootEigen(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedOrientedPoint.cpp:152
IceInternal::ProxyHandle<::IceProxy::armarx::SharedRobotInterface >
armarx::FramedOrientedPoint::serialize
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: FramedOrientedPoint.cpp:197
armarx::FramedDirection::changeFrame
void changeFrame(const VirtualRobot::RobotPtr &robot, const std::string &newFrame)
Definition: FramedPose.cpp:132
armarx::VariantType::FramedPosition
const VariantTypeId FramedPosition
Definition: FramedPose.h:38
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx::OrientedPoint::normalToEigen
virtual Eigen::Vector3f normalToEigen() const
Definition: OrientedPoint.cpp:73
armarx::FramedOrientedPoint::normalToRootEigen
Eigen::Vector3f normalToRootEigen(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedOrientedPoint.cpp:158
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:19