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
36namespace 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;
163 IceUtil::Time updateTimestamp;
165 RobotStateListenerInterfacePrx robotStateListenerPrx;
166 };
167
169} // namespace armarx
constexpr T c
void ref(const Ice::Current &c=Ice::emptyCurrent) override
void unref(const Ice::Current &c=Ice::emptyCurrent) override
void destroy(const Ice::Current &c=Ice::emptyCurrent) override
FramedPoseBasePtr getGlobalPose(const Ice::Current &current=Ice::emptyCurrent) const override
VirtualRobot::RobotNodePtr _node
float getMass(const Ice::Current &current=Ice::emptyCurrent) const override
JointType getType(const Ice::Current &current=Ice::emptyCurrent) const override
std::string getName(const Ice::Current &current=Ice::emptyCurrent) const override
float getJointValueOffest(const Ice::Current &current=Ice::emptyCurrent) const override
SharedRobotNodeServant(VirtualRobot::RobotNodePtr node)
Vector3BasePtr getCoM(const Ice::Current &current=Ice::emptyCurrent) const override
NameList getChildren(const Ice::Current &current=Ice::emptyCurrent) const override
float getJointLimitLow(const Ice::Current &current=Ice::emptyCurrent) const override
Ice::FloatSeq getInertia(const Ice::Current &current=Ice::emptyCurrent) const override
PoseBasePtr getLocalTransformation(const Ice::Current &current=Ice::emptyCurrent) const override
Vector3BasePtr getJointRotationAxis(const Ice::Current &current=Ice::emptyCurrent) const override
NameList getAllParents(const std::string &name, const Ice::Current &current=Ice::emptyCurrent) const override
float getJointLimitHigh(const Ice::Current &current=Ice::emptyCurrent) const override
FramedPoseBasePtr getPoseInRootFrame(const Ice::Current &current=Ice::emptyCurrent) const override
Vector3BasePtr getJointTranslationDirection(const Ice::Current &current=Ice::emptyCurrent) const override
bool hasChild(const std::string &name, bool recursive, const Ice::Current &current=Ice::emptyCurrent) const override
float getJointValue(const Ice::Current &current=Ice::emptyCurrent) const override
std::string getParent(const Ice::Current &current=Ice::emptyCurrent) const override
SharedRobotNodeInterfacePrx getRootNode(const Ice::Current &current=Ice::emptyCurrent) override
TimestampBasePtr getTimestamp(const Ice::Current &=Ice::emptyCurrent) const override
std::string getType(const Ice::Current &current=Ice::emptyCurrent) override
RobotStateComponentInterfacePrx robotStateComponent
float getScaling(const Ice::Current &=Ice::emptyCurrent) override
PoseBasePtr getGlobalPose(const Ice::Current &current=Ice::emptyCurrent) override
std::string getName(const Ice::Current &current=Ice::emptyCurrent) override
void setGlobalPose(const PoseBasePtr &pose, const Ice::Current &current=Ice::emptyCurrent) override
RobotStateComponentInterfacePrx getRobotStateComponent(const Ice::Current &) const override
SharedRobotNodeInterfacePrx getRobotNode(const std::string &name, const Ice::Current &current=Ice::emptyCurrent) override
bool hasRobotNodeSet(const std::string &name, const Ice::Current &current=Ice::emptyCurrent) override
std::map< std::string, SharedRobotNodeInterfacePrx > _cachedNodes
NameValueMap getConfig(const Ice::Current &current=Ice::emptyCurrent) override
SharedRobotServant(VirtualRobot::RobotPtr robot, RobotStateComponentInterfacePrx robotStateComponent, RobotStateListenerInterfacePrx robotStateListenerPrx)
bool hasRobotNode(const std::string &name, const Ice::Current &current=Ice::emptyCurrent) override
NameList getRobotNodeSets(const Ice::Current &current=Ice::emptyCurrent) override
NameList getRobotNodes(const Ice::Current &current=Ice::emptyCurrent) override
NameValueMap getConfigAndPose(PoseBasePtr &globalPose, const Ice::Current &current=Ice::emptyCurrent) override
VirtualRobot::RobotPtr _robot
RobotNodeSetInfoPtr getRobotNodeSet(const std::string &name, const Ice::Current &current=Ice::emptyCurrent) override
void setRobotStateComponent(RobotStateComponentInterfacePrx robotStateComponent)
RobotStateListenerInterfacePrx robotStateListenerPrx
void setTimestamp(const IceUtil::Time &updateTime)
VirtualRobot::RobotPtr getRobot() const
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file offers overloads of toIce() and fromIce() functions for STL container types.
::IceInternal::ProxyHandle<::IceProxy::armarx::RobotStateComponentInterface > RobotStateComponentInterfacePrx
IceInternal::Handle< SharedRobotServant > SharedRobotServantPtr