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/Robot.h>
24 #include <VirtualRobot/LinkedCoordinate.h>
25 #include <VirtualRobot/LinkedCoordinate.h>
26 #include <VirtualRobot/VirtualRobot.h>
27 
29 
30 namespace armarx
31 {
33  = default;
34 
36  IceUtil::Shared(source),
37  armarx::Serializable(source),
38  OrientedPointBase(source),
39  FramedOrientedPointBase(source),
41  {
42  }
43 
44  FramedOrientedPoint::FramedOrientedPoint(const Eigen::Vector3f& position, const Eigen::Vector3f& normal, const std::string& frame, const std::string& agent) :
45  OrientedPoint(position, normal)
46  {
47  this->frame = frame;
48  this->agent = agent;
49 
50  }
51 
52  FramedOrientedPoint::FramedOrientedPoint(const OrientedPoint& pointWithNormal, const std::string& frame, const std::string& agent) :
53  FramedOrientedPoint(pointWithNormal.positionToEigen(), pointWithNormal.normalToEigen(), frame, agent)
54  {
55  }
56 
57  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) :
58  OrientedPoint(px, py, pz, nx, ny, nz)
59  {
60  this->frame = frame;
61  this->agent = agent;
62  }
63 
64  std::string FramedOrientedPoint::getFrame() const
65  {
66  return frame;
67  }
68 
69 
70  void FramedOrientedPoint::changeFrame(const VirtualRobot::RobotPtr& robot, const std::string& newFrame)
71  {
72  FramedPosition framedPos(positionToEigen(), frame, agent);
73  FramedDirection framedDir(normalToEigen(), frame, agent);
74 
75  framedPos.changeFrame(robot, newFrame);
76  framedDir.changeFrame(robot, newFrame);
77  this->px = framedPos.x;
78  this->py = framedPos.y;
79  this->pz = framedPos.z;
80 
81  this->nx = framedDir.x;
82  this->ny = framedDir.y;
83  this->nz = framedDir.z;
84  }
85 
87  {
88  VirtualRobot::RobotPtr sharedRobot(new RemoteRobot(referenceRobot));
89  changeFrame(sharedRobot, GlobalFrame);
90  }
91 
93  {
94  changeFrame(referenceRobot, GlobalFrame);
95  }
96 
97  Eigen::Vector3f FramedOrientedPoint::positionToGlobalEigen(const SharedRobotInterfacePrx& referenceRobot) const
98  {
99  return getFramedPosition().toGlobalEigen(referenceRobot);
100  }
101 
102  Eigen::Vector3f FramedOrientedPoint::normalToGlobalEigen(const SharedRobotInterfacePrx& referenceRobot) const
103  {
104  return getFramedNormal().toGlobalEigen(referenceRobot);
105  }
106 
107  Eigen::Vector3f FramedOrientedPoint::positionToGlobalEigen(const VirtualRobot::RobotPtr& referenceRobot) const
108  {
109  return getFramedPosition().toGlobalEigen(referenceRobot);
110  }
111 
112  Eigen::Vector3f FramedOrientedPoint::normalToGlobalEigen(const VirtualRobot::RobotPtr& referenceRobot) const
113  {
114  return getFramedNormal().toGlobalEigen(referenceRobot);
115  }
116 
117 
119  {
120  return new FramedOrientedPoint(positionToRootEigen(referenceRobot), normalToRootEigen(referenceRobot), frame, agent);
121  }
122 
124  {
125  return new FramedOrientedPoint(positionToRootEigen(referenceRobot), normalToRootEigen(referenceRobot), frame, agent);
126  }
127 
128  Eigen::Vector3f FramedOrientedPoint::positionToRootEigen(const SharedRobotInterfacePrx& referenceRobot) const
129  {
130  return getFramedPosition().toRootEigen(referenceRobot);
131  }
132 
133  Eigen::Vector3f FramedOrientedPoint::normalToRootEigen(const SharedRobotInterfacePrx& referenceRobot) const
134  {
135  return getFramedNormal().toRootEigen(referenceRobot);
136  }
137 
138  Eigen::Vector3f FramedOrientedPoint::positionToRootEigen(const VirtualRobot::RobotPtr& referenceRobot) const
139  {
140  return getFramedPosition().toRootEigen(referenceRobot);
141  }
142 
143  Eigen::Vector3f FramedOrientedPoint::normalToRootEigen(const VirtualRobot::RobotPtr& referenceRobot) const
144  {
145  return getFramedNormal().toRootEigen(referenceRobot);
146  }
147 
149  {
150  return FramedPosition(positionToEigen(), frame, agent);
151  }
152 
154  {
155  return FramedDirection(normalToEigen(), frame, agent);
156  }
157 
158 
159  std::string FramedOrientedPoint::output(const Ice::Current& c) const
160  {
161  std::stringstream s;
162  s << OrientedPoint::output(c) << std::endl << "frame: " << getFrame() << (agent.empty() ? "" : (" agent: " + agent));
163  return s.str();
164  }
165 
166 
167  void FramedOrientedPoint::serialize(const ObjectSerializerBasePtr& serializer, const Ice::Current&) const
168  {
169  AbstractObjectSerializerPtr obj = AbstractObjectSerializerPtr::dynamicCast(serializer);
170  OrientedPoint::serialize(serializer);
171  obj->setString("frame", frame);
172  obj->setString("agent", agent);
173 
174  }
175 
176  void FramedOrientedPoint::deserialize(const ObjectSerializerBasePtr& serializer, const Ice::Current&)
177  {
178  AbstractObjectSerializerPtr obj = AbstractObjectSerializerPtr::dynamicCast(serializer);
179  OrientedPoint::deserialize(serializer);
180  frame = obj->getString("frame");
181 
182  if (obj->hasElement("agent"))
183  {
184  agent = obj->getString("agent");
185  }
186  }
187 }
RemoteRobot.h
FramedOrientedPoint.h
armarx::VariantType::Float
const VariantTypeId Float
Definition: Variant.h:918
armarx::OrientedPoint::deserialize
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: OrientedPoint.cpp:96
armarx::FramedOrientedPoint::getFramedPosition
FramedPosition getFramedPosition() const
Definition: FramedOrientedPoint.cpp:148
armarx::OrientedPoint::positionToEigen
virtual Eigen::Vector3f positionToEigen() const
Definition: OrientedPoint.cpp:60
armarx::FramedOrientedPoint::getFrame
std::string getFrame() const
Definition: FramedOrientedPoint.cpp:64
armarx::GlobalFrame
const std::string GlobalFrame
Definition: FramedPose.h:62
armarx::OrientedPoint
Definition: OrientedPoint.h:41
armarx::FramedDirection::toRootEigen
Eigen::Vector3f toRootEigen(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedPose.cpp:248
armarx::FramedOrientedPoint::deserialize
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
Definition: FramedOrientedPoint.cpp:176
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::FramedPosition::toRootEigen
Eigen::Vector3f toRootEigen(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedPose.cpp:786
armarx::FramedOrientedPoint::changeFrame
void changeFrame(const VirtualRobot::RobotPtr &robot, const std::string &newFrame)
Definition: FramedOrientedPoint.cpp:70
IceUtil
Definition: Instance.h:21
armarx::FramedPosition::toGlobalEigen
Eigen::Vector3f toGlobalEigen(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedPose.cpp:752
armarx::FramedOrientedPoint
Definition: FramedOrientedPoint.h:45
armarx::FramedOrientedPoint::output
std::string output(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: FramedOrientedPoint.cpp:159
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::FramedDirection::toGlobalEigen
Eigen::Vector3f toGlobalEigen(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedPose.cpp:214
armarx::FramedOrientedPoint::normalToGlobalEigen
Eigen::Vector3f normalToGlobalEigen(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedOrientedPoint.cpp:102
armarx::FramedOrientedPoint::FramedOrientedPoint
FramedOrientedPoint()
armarx::FramedOrientedPoint::changeToGlobal
void changeToGlobal(const SharedRobotInterfacePrx &referenceRobot)
Definition: FramedOrientedPoint.cpp:86
armarx::FramedPosition
The FramedPosition class.
Definition: FramedPose.h:142
armarx::FramedOrientedPoint::getFramedNormal
FramedDirection getFramedNormal() const
Definition: FramedOrientedPoint.cpp:153
armarx::FramedPosition::changeFrame
void changeFrame(const SharedRobotInterfacePrx &referenceRobot, const std::string &newFrame)
Definition: FramedPose.cpp:637
boost::source
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
Definition: point_cloud_graph.h:681
armarx::FramedOrientedPoint::positionToGlobalEigen
Eigen::Vector3f positionToGlobalEigen(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedOrientedPoint.cpp:97
armarx::OrientedPoint::serialize
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: OrientedPoint.cpp:83
armarx::OrientedPoint::output
std::string output(const Ice::Current &c=Ice::emptyCurrent) const override
Definition: OrientedPoint.cpp:75
armarx::FramedOrientedPoint::toRootFrame
FramedOrientedPointPtr toRootFrame(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedOrientedPoint.cpp:118
armarx::RemoteRobot
Mimics the behaviour of the VirtualRobot::Robot class while redirecting everything to an Ice proxy.
Definition: RemoteRobot.h:139
armarx::FramedDirection
FramedDirection is a 3 dimensional direction vector with a reference frame. The reference frame can b...
Definition: FramedPose.h:83
armarx::VariantType::FramedDirection
const VariantTypeId FramedDirection
Definition: FramedPose.h:38
armarx::FramedOrientedPoint::positionToRootEigen
Eigen::Vector3f positionToRootEigen(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedOrientedPoint.cpp:128
IceInternal::ProxyHandle< ::IceProxy::armarx::SharedRobotInterface >
armarx::FramedOrientedPoint::serialize
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
Definition: FramedOrientedPoint.cpp:167
armarx::FramedDirection::changeFrame
void changeFrame(const VirtualRobot::RobotPtr &robot, const std::string &newFrame)
Definition: FramedPose.cpp:119
armarx::VariantType::FramedPosition
const VariantTypeId FramedPosition
Definition: FramedPose.h:39
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:67
armarx::FramedOrientedPoint::normalToRootEigen
Eigen::Vector3f normalToRootEigen(const SharedRobotInterfacePrx &referenceRobot) const
Definition: FramedOrientedPoint.cpp:133
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18