RemoteRobotNode.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package
19 * @author
20 * @date
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24#include <VirtualRobot/RobotNodeSet.h>
25#include <VirtualRobot/VirtualRobot.h>
26
29#include <ArmarXCore/interface/core/BasicTypes.h>
30
32
33#include "RemoteRobot.h"
34
35namespace armarx
36{
37
38 using namespace std;
39 using namespace VirtualRobot;
40 using namespace Eigen;
41
42 RobotNodePtr
43 RemoteRobot::createRemoteRobotNode(SharedRobotNodeInterfacePrx node, RobotPtr robot)
44 {
45 switch (node->getType())
46 {
47 case ePrismatic:
48 return RobotNodePtr(new RemoteRobotNode<RobotNodePrismatic>(node, robot));
49
50 case eRevolute:
51 return RobotNodePtr(new RemoteRobotNode<RobotNodeRevolute>(node, robot));
52
53 case eFixed:
54 return RobotNodePtr(new RemoteRobotNode<RobotNodeFixed>(node, robot));
55
56 default:
57 break; // thow an exception
58 }
59
60 return RobotNodePtr();
61 }
62
63 template <>
64 void
67 {
68 // set rotation axis
69 remoteNode->jointRotationAxis =
70 remoteNode->getGlobalPose().block<3, 3>(0, 0).inverse() *
71 Vector3Ptr::dynamicCast(remoteNode->_node->getJointRotationAxis())->toEigen();
72 }
73
74 template <>
75 void
78 {
79 // set translation direction
80 remoteNode->jointTranslationDirection =
81 remoteNode->getGlobalPose().block<3, 3>(0, 0).inverse() *
82 Vector3Ptr::dynamicCast(remoteNode->_node->getJointTranslationDirection())->toEigen();
83 }
84
85 template <>
86 void
92
93 template <class RobotNodeType>
95 {
96 try
97 {
98 _node->unref();
99 }
100 catch (std::exception& e)
101 {
102 ARMARX_DEBUG_S << "Unref of SharedRobotNode failed: " << e.what();
103 }
104 catch (...)
105 {
106 ARMARX_DEBUG_S << "Unref of SharedRobotNode failed: reason unknown";
107 }
108 }
109
110 template <class RobotNodeType>
111 float
113 {
114 return _node->getJointValue();
115 }
116
117 template <class RobotNodeType>
118 float
120 {
121 return _node->getJointLimitHigh();
122 }
123
124 template <class RobotNodeType>
125 float
127 {
128 return _node->getJointLimitLow();
129 }
130
131 /*
132 template<class RobotNodeType>
133 Eigen::Matrix4f RemoteRobotNode<RobotNodeType>::getPostJointTransformation(){
134 return PosePtr::dynamicCast(_node->getPostJointTransformation())->toEigen();
135 }*/
136
137 template <class RobotNodeType>
138 Eigen::Matrix4f
140 {
141 return PosePtr::dynamicCast(_node->getLocalTransformation())->toEigen();
142 }
143
144 template <class RobotNodeType>
145 Eigen::Matrix4f
147 {
148 return FramedPosePtr::dynamicCast(_node->getGlobalPose())->toEigen();
149 }
150
151 template <class RobotNodeType>
152 Eigen::Matrix4f
154 {
155 return FramedPosePtr::dynamicCast(_node->getPoseInRootFrame())->toEigen();
156 }
157
158 template <class RobotNodeType>
159 Eigen::Vector3f
161 {
162 Vector3Ptr pos = Vector3Ptr::dynamicCast(_node->getPoseInRootFrame()->position);
164 return pos->toEigen();
165 }
166
167 template <class RobotNodeType>
168 bool
169 RemoteRobotNode<RobotNodeType>::hasChildNode(const RobotNodePtr child, bool recursive) const
170 {
171 return false;
172 }
173
174 template <class RobotNodeType>
175 bool
176 RemoteRobotNode<RobotNodeType>::hasChildNode(const std::string& child, bool recursive) const
177 {
178 return _node->hasChild(child, recursive);
179 }
180
181 template <class RobotNodeType>
182 void
186
187 template <class RobotNodeType>
188 vector<RobotNodePtr>
190 {
191 NameList nodes = _node->getAllParents(rns->getName());
192 vector<RobotNodePtr> result;
193 RobotPtr robot = this->robot.lock();
194
195 for (std::string const& name : nodes)
196 {
197 result.push_back(robot->getRobotNode(name));
198 }
199 return result;
200 }
201
202 template <class RobotNodeType>
203 SceneObjectPtr
205 {
206 return this->robot.lock()->getRobotNode(_node->getParent());
207 }
208
209 /*
210 template<class RobotNodeType>
211 void RemoteRobotNode<RobotNodeType>::setPostJointTransformation(const Eigen::Matrix4f &trafo){
212 }*/
213 template <class RobotNodeType>
214 void
216 {
217 }
218
219 template <class RobotNodeType>
220 std::vector<std::string>
222 {
223 return _node->getChildren();
224 }
225
226 template <class RobotNodeType>
227 std::string
229 {
230 return _node->getParent();
231 }
232
233 template <class RobotNodeType>
234 std::vector<SceneObjectPtr>
236 {
237 NameList nodes = _node->getChildren();
238 vector<SceneObjectPtr> result;
239 for (string const& name : nodes)
240 {
241 result.push_back(this->robot.lock()->getRobotNode(name));
242 }
243 return result;
244 }
245
246 template <class RobotNodeType>
247 void
251
252 template <class RobotNodeType>
253 void
255 {
256 }
257
258 template <class RobotNodeType>
259 void
261 {
262 }
263
264 template <class RobotNodeType>
265 bool
266 RemoteRobotNode<RobotNodeType>::initialize(RobotNodePtr parent, bool initializeChildren)
267 {
268 return false;
269 }
270
271 template <class RobotNodeType>
272 void
276
277 template <class RobotNodeType>
278 void
280 {
281 }
282
283 template <class RobotNodeType>
284 void
286 bool updateTransformations,
287 bool clampToLimits)
288 {
289 }
290
291} // namespace armarx
#define lo(x)
#define hi(x)
Mimics the behaviour of robot nodes while redirecting everything to Ice proxies.
Definition RemoteRobot.h:73
Eigen::Matrix4f getPoseInRootFrame() const override
SharedRobotNodeInterfacePrx _node
Eigen::Vector3f getPositionInRootFrame() const override
void setJointLimits(float lo, float hi) override
void setGlobalPose(const Eigen::Matrix4f &pose) override
virtual float getJointLimitHi() const
virtual std::vector< std::string > getChildrenNames() const
virtual void setLocalTransformation(const Eigen::Matrix4f &trafo)
virtual void addChildNode(VirtualRobot::RobotNodePtr child)
virtual bool initialize(VirtualRobot::RobotNodePtr parent, bool initializeChildren=false)
virtual void setJointValue(float q, bool updateTransformations=true, bool clampToLimits=true)
virtual bool hasChildNode(const std::string &child, bool recursive=false) const
std::vector< VirtualRobot::RobotNodePtr > getAllParents(VirtualRobot::RobotNodeSetPtr rns) override
virtual std::string getParentName() const
virtual VirtualRobot::SceneObjectPtr getParent()
float getJointValue() const override
std::vector< VirtualRobot::SceneObjectPtr > getChildren() const override
void updateTransformationMatrices() override
virtual float getJointLimitLo() const
Eigen::Matrix4f getGlobalPose() const override
Eigen::Matrix4f getLocalTransformation() override
static VirtualRobot::RobotNodePtr createRemoteRobotNode(SharedRobotNodeInterfacePrx, VirtualRobot::RobotPtr)
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
#define ARMARX_DEBUG_S
The logging level for output that is only interesting while debugging.
Definition Logging.h:205
#define q
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< Vector3 > Vector3Ptr
Definition Pose.h:165
static void initialize(RemoteRobotNode< VirtualRobotNodeType > *remoteNode)