SharedRobotServants.h
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 #pragma once
25 
26 #include <mutex>
27 
28 #include <VirtualRobot/VirtualRobot.h>
29 
32 
33 #include <RobotAPI/interface/core/RobotState.h>
35 
36 namespace armarx
37 {
38  // Zugriff muss mutex geschuetzt werden!
39 
40  /**
41  * @brief The base class for remote objects on the ice server
42  *
43  */
44 
45  class SharedObjectBase : virtual public SharedObjectInterface
46  {
47  public:
48  void ref(const Ice::Current& c = Ice::emptyCurrent) override;
49  void unref(const Ice::Current& c = Ice::emptyCurrent) override;
50  void destroy(const Ice::Current& c = Ice::emptyCurrent) override;
52 
53  private:
54  unsigned int _referenceCount;
55  std::mutex _counterMutex;
56  };
57 
58  /**
59  * @brief The SharedRobotNodeServant class is a remote representation of a Simox VirtualRobot::Robot
60  * @ingroup Component-RobotStateComponent
61  * @details This class is used only internally by the the RobotStateComponent. Other classes such as the LinkedPose, RemoteRobot,
62  * TCPControlUnit and HeadIKUnit classes address this class by the SharedRobotNodeInterface and SharedRobotNodeInterfacePrx generated by
63  * Ice.
64  */
65  class SharedRobotNodeServant : virtual public SharedRobotNodeInterface, public SharedObjectBase
66  {
67  public:
69  VirtualRobot::RobotNodePtr node /*,const Ice::Current & current = Ice::emptyCurrent*/);
70  ~SharedRobotNodeServant() override;
71 
72  float getJointValue(const Ice::Current& current = Ice::emptyCurrent) const override;
73  std::string getName(const Ice::Current& current = Ice::emptyCurrent) const override;
74 
75  PoseBasePtr
76  getLocalTransformation(const Ice::Current& current = Ice::emptyCurrent) const override;
77  FramedPoseBasePtr
78  getGlobalPose(const Ice::Current& current = Ice::emptyCurrent) const override;
79  FramedPoseBasePtr
80  getPoseInRootFrame(const Ice::Current& current = Ice::emptyCurrent) const override;
81 
82  JointType getType(const Ice::Current& current = Ice::emptyCurrent) const override;
83  Vector3BasePtr getJointTranslationDirection(
84  const Ice::Current& current = Ice::emptyCurrent) const override;
85  Vector3BasePtr
86  getJointRotationAxis(const Ice::Current& current = Ice::emptyCurrent) const override;
87 
88  bool hasChild(const std::string& name,
89  bool recursive,
90  const Ice::Current& current = Ice::emptyCurrent) const override;
91  std::string getParent(const Ice::Current& current = Ice::emptyCurrent) const override;
92  NameList getChildren(const Ice::Current& current = Ice::emptyCurrent) const override;
93  NameList getAllParents(const std::string& name,
94  const Ice::Current& current = Ice::emptyCurrent) const override;
95 
96  float getJointValueOffest(const Ice::Current& current = Ice::emptyCurrent) const override;
97  float getJointLimitHigh(const Ice::Current& current = Ice::emptyCurrent) const override;
98  float getJointLimitLow(const Ice::Current& current = Ice::emptyCurrent) const override;
99 
100  Vector3BasePtr getCoM(const Ice::Current& current = Ice::emptyCurrent) const override;
101  Ice::FloatSeq getInertia(const Ice::Current& current = Ice::emptyCurrent) const override;
102  float getMass(const Ice::Current& current = Ice::emptyCurrent) const override;
103 
104 
105  protected:
106  VirtualRobot::RobotNodePtr _node;
107  };
108 
109  /**
110  * @ingroup Component-RobotStateComponent
111  * @brief The SharedRobotNodeServant class is a remote represenation of a Simox VirtualRobot::Robot
112  *
113  * @details This class is used only internally by the the RobotStateComponent. The RemoteRobot class SharedRobotInterface and SharedRobotInterfacePrx
114  * classes generated by Ice.
115  */
116 
117  class SharedRobotServant : public virtual SharedRobotInterface, public SharedObjectBase
118  {
119  public:
122  RobotStateListenerInterfacePrx robotStateListenerPrx);
123  ~SharedRobotServant() override;
125  SharedRobotNodeInterfacePrx
126  getRobotNode(const std::string& name,
127  const Ice::Current& current = Ice::emptyCurrent) override;
128  SharedRobotNodeInterfacePrx
129  getRootNode(const Ice::Current& current = Ice::emptyCurrent) override;
130  bool hasRobotNode(const std::string& name,
131  const Ice::Current& current = Ice::emptyCurrent) override;
132 
133  NameList getRobotNodes(const Ice::Current& current = Ice::emptyCurrent) override;
134  RobotNodeSetInfoPtr
135  getRobotNodeSet(const std::string& name,
136  const Ice::Current& current = Ice::emptyCurrent) override;
137  NameList getRobotNodeSets(const Ice::Current& current = Ice::emptyCurrent) override;
138  bool hasRobotNodeSet(const std::string& name,
139  const Ice::Current& current = Ice::emptyCurrent) override;
140 
141  std::string getName(const Ice::Current& current = Ice::emptyCurrent) override;
142  std::string getType(const Ice::Current& current = Ice::emptyCurrent) override;
143 
144  PoseBasePtr getGlobalPose(const Ice::Current& current = Ice::emptyCurrent) override;
145  NameValueMap getConfig(const Ice::Current& current = Ice::emptyCurrent) override;
146  NameValueMap getConfigAndPose(PoseBasePtr& globalPose,
147  const Ice::Current& current = Ice::emptyCurrent) override;
148  void setGlobalPose(const PoseBasePtr& pose,
149  const Ice::Current& current = Ice::emptyCurrent) override;
150 
151  float getScaling(const Ice::Current& = Ice::emptyCurrent) override;
152 
154 
155  void setTimestamp(const IceUtil::Time& updateTime);
156  TimestampBasePtr getTimestamp(const Ice::Current& = Ice::emptyCurrent) const override;
157  RobotStateComponentInterfacePrx getRobotStateComponent(const Ice::Current&) const override;
158 
159  protected:
161  std::recursive_mutex m;
162  std::map<std::string, SharedRobotNodeInterfacePrx> _cachedNodes;
165  RobotStateListenerInterfacePrx robotStateListenerPrx;
166  };
167 
169 } // namespace armarx
armarx::SharedRobotServant::_robot
VirtualRobot::RobotPtr _robot
Definition: SharedRobotServants.h:160
armarx::SharedRobotNodeServant::getJointTranslationDirection
Vector3BasePtr getJointTranslationDirection(const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:191
armarx::SharedObjectBase::destroy
void destroy(const Ice::Current &c=Ice::emptyCurrent) override
Definition: SharedRobotServants.cpp:97
armarx::SharedRobotServant::getGlobalPose
PoseBasePtr getGlobalPose(const Ice::Current &current=Ice::emptyCurrent) override
Definition: SharedRobotServants.cpp:487
armarx::SharedRobotNodeServant::getGlobalPose
FramedPoseBasePtr getGlobalPose(const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:156
armarx::SharedRobotNodeServant
The SharedRobotNodeServant class is a remote representation of a Simox VirtualRobot::Robot.
Definition: SharedRobotServants.h:65
armarx::SharedRobotNodeServant::getType
JointType getType(const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:172
armarx::SharedRobotServant::getName
std::string getName(const Ice::Current &current=Ice::emptyCurrent) override
Definition: SharedRobotServants.cpp:468
armarx::SharedRobotServant::setRobotStateComponent
void setRobotStateComponent(RobotStateComponentInterfacePrx robotStateComponent)
Definition: SharedRobotServants.cpp:360
armarx::SharedRobotServant::_cachedNodes
std::map< std::string, SharedRobotNodeInterfacePrx > _cachedNodes
Definition: SharedRobotServants.h:162
armarx::SharedRobotServant::getTimestamp
TimestampBasePtr getTimestamp(const Ice::Current &=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:516
armarx::SharedRobotServant::getRootNode
SharedRobotNodeInterfacePrx getRootNode(const Ice::Current &current=Ice::emptyCurrent) override
Definition: SharedRobotServants.cpp:396
armarx::SharedRobotServant::~SharedRobotServant
~SharedRobotServant() override
Definition: SharedRobotServants.cpp:340
armarx::SharedRobotServant::getRobotStateComponent
RobotStateComponentInterfacePrx getRobotStateComponent(const Ice::Current &) const override
Definition: SharedRobotServants.cpp:522
armarx::SharedRobotServant
The SharedRobotNodeServant class is a remote represenation of a Simox VirtualRobot::Robot.
Definition: SharedRobotServants.h:117
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:46
armarx::SharedRobotNodeServant::getInertia
Ice::FloatSeq getInertia(const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:303
armarx::SharedRobotServant::getRobotNodeSets
NameList getRobotNodeSets(const Ice::Current &current=Ice::emptyCurrent) override
Definition: SharedRobotServants.cpp:449
armarx::SharedRobotNodeServant::getJointValue
float getJointValue(const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:135
armarx::SharedRobotServant::getConfig
NameValueMap getConfig(const Ice::Current &current=Ice::emptyCurrent) override
Definition: SharedRobotServants.cpp:494
armarx::SharedRobotNodeServant::getJointLimitLow
float getJointLimitLow(const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:289
armarx::SharedRobotNodeServant::getMass
float getMass(const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:318
IceInternal::Handle< SharedRobotServant >
armarx::SharedRobotNodeServant::getLocalTransformation
PoseBasePtr getLocalTransformation(const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:149
armarx::SharedRobotNodeServant::getAllParents
NameList getAllParents(const std::string &name, const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:260
armarx::SharedRobotServant::getRobotNodeSet
RobotNodeSetInfoPtr getRobotNodeSet(const std::string &name, const Ice::Current &current=Ice::emptyCurrent) override
Definition: SharedRobotServants.cpp:423
armarx::SharedRobotServant::m
std::recursive_mutex m
Definition: SharedRobotServants.h:161
FramedPose.h
armarx::SharedObjectBase::unref
void unref(const Ice::Current &c=Ice::emptyCurrent) override
Definition: SharedRobotServants.cpp:81
armarx::SharedRobotServant::getRobotNode
SharedRobotNodeInterfacePrx getRobotNode(const std::string &name, const Ice::Current &current=Ice::emptyCurrent) override
Definition: SharedRobotServants.cpp:366
armarx::SharedRobotNodeServant::~SharedRobotNodeServant
~SharedRobotNodeServant() override
Definition: SharedRobotServants.cpp:126
armarx::SharedRobotServant::SharedRobotServant
SharedRobotServant(VirtualRobot::RobotPtr robot, RobotStateComponentInterfacePrx robotStateComponent, RobotStateListenerInterfacePrx robotStateListenerPrx)
Definition: SharedRobotServants.cpp:328
armarx::SharedRobotServant::setGlobalPose
void setGlobalPose(const PoseBasePtr &pose, const Ice::Current &current=Ice::emptyCurrent) override
Definition: SharedRobotServants.cpp:528
armarx::SharedRobotNodeServant::getChildren
NameList getChildren(const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:247
armarx::SharedRobotNodeServant::getParent
std::string getParent(const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:233
armarx::SharedRobotServant::getRobotNodes
NameList getRobotNodes(const Ice::Current &current=Ice::emptyCurrent) override
Definition: SharedRobotServants.cpp:411
armarx::SharedRobotNodeServant::getName
std::string getName(const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:142
armarx::SharedRobotServant::setTimestamp
void setTimestamp(const IceUtil::Time &updateTime)
Definition: SharedRobotServants.cpp:481
armarx::SharedObjectBase
The base class for remote objects on the ice server.
Definition: SharedRobotServants.h:45
armarx::armem::Time
armarx::core::time::DateTime Time
Definition: forward_declarations.h:13
armarx::SharedObjectBase::SharedObjectBase
SharedObjectBase()
Definition: SharedRobotServants.cpp:60
Component.h
armarx::SharedRobotServant::updateTimestamp
IceUtil::Time updateTimestamp
Definition: SharedRobotServants.h:163
armarx::SharedRobotNodeServant::hasChild
bool hasChild(const std::string &name, bool recursive, const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:223
armarx::SharedRobotServant::robotStateComponent
RobotStateComponentInterfacePrx robotStateComponent
Definition: SharedRobotServants.h:164
armarx::SharedRobotNodeServant::getJointLimitHigh
float getJointLimitHigh(const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:282
armarx::control::njoint_controller::platform::platform_follower_controller::NameValueMap
std::map< std::string, float > NameValueMap
Definition: PlatformFollowerController.h:88
armarx::SharedObjectBase::ref
void ref(const Ice::Current &c=Ice::emptyCurrent) override
Definition: SharedRobotServants.cpp:69
armarx::SharedRobotServant::getScaling
float getScaling(const Ice::Current &=Ice::emptyCurrent) override
Definition: SharedRobotServants.cpp:544
armarx::SharedRobotNodeServant::SharedRobotNodeServant
SharedRobotNodeServant(VirtualRobot::RobotNodePtr node)
Definition: SharedRobotServants.cpp:118
armarx::SharedRobotServant::getRobot
VirtualRobot::RobotPtr getRobot() const
Definition: SharedRobotServants.cpp:550
IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface >
armarx::SharedRobotNodeServant::getJointRotationAxis
Vector3BasePtr getJointRotationAxis(const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:207
armarx::SharedRobotNodeServant::getJointValueOffest
float getJointValueOffest(const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:275
armarx::SharedRobotServant::getType
std::string getType(const Ice::Current &current=Ice::emptyCurrent) override
Definition: SharedRobotServants.cpp:475
armarx::SharedRobotServant::robotStateListenerPrx
RobotStateListenerInterfacePrx robotStateListenerPrx
Definition: SharedRobotServants.h:165
armarx::SharedRobotServant::getConfigAndPose
NameValueMap getConfigAndPose(PoseBasePtr &globalPose, const Ice::Current &current=Ice::emptyCurrent) override
Definition: SharedRobotServants.cpp:509
armarx::SharedRobotNodeServant::_node
VirtualRobot::RobotNodePtr _node
Definition: SharedRobotServants.h:106
armarx::SharedRobotServant::hasRobotNode
bool hasRobotNode(const std::string &name, const Ice::Current &current=Ice::emptyCurrent) override
Definition: SharedRobotServants.cpp:405
armarx::SharedRobotServant::hasRobotNodeSet
bool hasRobotNodeSet(const std::string &name, const Ice::Current &current=Ice::emptyCurrent) override
Definition: SharedRobotServants.cpp:462
armarx::SharedRobotNodeServant::getCoM
Vector3BasePtr getCoM(const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:296
armarx::SharedRobotNodeServant::getPoseInRootFrame
FramedPoseBasePtr getPoseInRootFrame(const Ice::Current &current=Ice::emptyCurrent) const override
Definition: SharedRobotServants.cpp:163
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
ImportExportComponent.h