RobotNameHelper.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T),
5  * Karlsruhe Institute of Technology (KIT), all rights reserved.
6  *
7  * ArmarX is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.
10  *
11  * ArmarX is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * @author Simon Ottenhaus (simon dot ottenhaus at kit dot edu)
20  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
21  * GNU General Public License
22  */
23 
24 #pragma once
25 
26 #include <RobotAPI/interface/core/RobotState.h>
27 
28 #include <VirtualRobot/Robot.h>
29 #include <VirtualRobot/VirtualRobot.h>
30 #include <VirtualRobot/Visualization/TriMeshModel.h>
31 
32 namespace armarx
33 {
34  using RobotNameHelperPtr = std::shared_ptr<class RobotNameHelper>;
35  using StatechartProfilePtr = std::shared_ptr<class StatechartProfile>;
36 
37  class RapidXmlReaderNode;
38 
39  struct RobotArm;
40 
41  struct Arm
42  {
43  friend class RobotNameHelper;
44 
45  public:
46 
47  std::string getSide() const;
48 
49  std::string getKinematicChain() const;
50 
51  std::string getTorsoKinematicChain() const;
52 
53  std::string getTCP() const;
54 
55  std::string getForceTorqueSensor() const;
56 
57  std::string getForceTorqueSensorFrame() const;
58 
59  std::string getEndEffector() const;
60 
61  std::string getMemoryHandName() const;
62 
63  std::string getHandControllerName() const;
64 
65  std::string getHandRootNode() const;
66 
67  std::string getHandUnitName() const;
68 
69  std::string getHandModelPath() const;
70 
71  std::string getAbsoluteHandModelPath() const;
72 
73  std::string getHandModelPackage() const;
74 
75  std::string getPalmCollisionModel() const;
76 
77  std::string getFullHandCollisionModel() const;
78 
79  RobotArm addRobot(const VirtualRobot::RobotPtr& robot) const;
80 
81  Arm(const std::shared_ptr<const RobotNameHelper>& rnh, const std::string& side);
82 
83  Arm() = default;
84 
85  Arm(Arm&&) = default;
86 
87  Arm(const Arm&) = default;
88 
89  Arm& operator=(Arm&&) = default;
90 
91  Arm& operator=(const Arm&) = default;
92 
93  std::shared_ptr<const RobotNameHelper> getRobotNameHelper() const;
94 
95  std::string select(const std::string& path) const;
96 
97  private:
98 
99  std::shared_ptr<const RobotNameHelper> rnh;
100  std::string side;
101  };
102 
103  struct RobotArm
104  {
105  friend class RobotNameHelper;
106 
107  friend struct Arm;
108  public:
109  std::string getSide() const;
110 
111  VirtualRobot::RobotNodeSetPtr getKinematicChain() const;
112 
113  VirtualRobot::RobotNodeSetPtr getTorsoKinematicChain() const;
114 
115  VirtualRobot::RobotNodePtr getTCP() const;
116 
117  VirtualRobot::RobotNodePtr getHandRootNode() const;
118 
119  VirtualRobot::RobotNodePtr getPalmCollisionModel() const;
120 
121  VirtualRobot::TriMeshModelPtr getFullHandCollisionModel() const;
122 
124 
125  const Arm& getArm() const;
126 
127  const VirtualRobot::RobotPtr& getRobot() const;
128 
129  RobotArm(const Arm& arm, const VirtualRobot::RobotPtr& robot);
130 
131  RobotArm() = default;
132 
133  RobotArm(RobotArm&&) = default;
134 
135  RobotArm(const RobotArm&) = default;
136 
137  RobotArm& operator=(RobotArm&&) = default;
138 
139  RobotArm& operator=(const RobotArm&) = default;
140 
141  private:
142 
143  Arm arm;
145  };
146 
147  class RobotNameHelper : public std::enable_shared_from_this<RobotNameHelper>
148  {
149  public:
150  static void
151  writeRobotInfoNode(const RobotInfoNodePtr& n, std::ostream& str, std::size_t indent = 0, char indentChar = ' ');
152  using Arm = armarx::Arm;
154  class Node
155  {
156  public:
157  Node(const RobotInfoNodePtr& robotInfo);
158 
159  std::string value();
160 
161  Node select(const std::string& name, const std::vector<std::string>& profiles);
162 
163  bool isValid();
164 
165  void checkValid();
166 
167  private:
168  RobotInfoNodePtr robotInfo;
169  };
170 
171  static const std::string LocationLeft;
172  static const std::string LocationRight;
173 
174  std::string select(const std::string& path) const;
175 
176  static RobotNameHelperPtr Create(const RobotInfoNodePtr& robotInfo, const StatechartProfilePtr& profile);
177 
178  static RobotNameHelperPtr
179  Create(const std::string& robotXmlFilename, const StatechartProfilePtr& profile = nullptr);
180 
181  RobotNameHelper(const RobotInfoNodePtr& robotInfo, const StatechartProfilePtr& profile = nullptr);
182 
183  RobotNameHelper(RobotNameHelper&&) = default;
184 
185  RobotNameHelper(const RobotNameHelper&) = default;
186 
188 
189  RobotNameHelper& operator=(const RobotNameHelper&) = default;
190 
191  Arm getArm(const std::string& side) const;
192 
193  RobotArm getRobotArm(const std::string& side, const VirtualRobot::RobotPtr& robot) const;
194 
195  const std::vector<std::string>& getProfiles() const;
196 
197  const RobotInfoNodePtr& getRobotInfoNodePtr() const;
198 
199  private:
200 
201  static RobotInfoNodePtr readRobotInfo(const RapidXmlReaderNode& infoNode);
202 
203  RobotNameHelper& self()
204  {
205  return *this;
206  }
207 
208  Node root;
209  std::vector<std::string> profiles;
210  RobotInfoNodePtr robotInfo;
211  };
212 }
armarx::RobotNameHelper::LocationLeft
static const std::string LocationLeft
Definition: RobotNameHelper.h:171
armarx::RobotNameHelper::Node::select
Node select(const std::string &name, const std::vector< std::string > &profiles)
Definition: RobotNameHelper.cpp:157
str
std::string str(const T &t)
Definition: UserAssistedSegmenterGuiWidgetController.cpp:42
armarx::Arm::getMemoryHandName
std::string getMemoryHandName() const
Definition: RobotNameHelper.cpp:241
armarx::Arm::getFullHandCollisionModel
std::string getFullHandCollisionModel() const
Definition: RobotNameHelper.cpp:290
armarx::Arm::getAbsoluteHandModelPath
std::string getAbsoluteHandModelPath() const
Definition: RobotNameHelper.cpp:271
armarx::Arm::addRobot
RobotArm addRobot(const VirtualRobot::RobotPtr &robot) const
Definition: RobotNameHelper.cpp:297
armarx::RobotArm::RobotArm
RobotArm()=default
armarx::Arm::getPalmCollisionModel
std::string getPalmCollisionModel() const
Definition: RobotNameHelper.cpp:284
armarx::Arm::getHandRootNode
std::string getHandRootNode() const
Definition: RobotNameHelper.cpp:259
armarx::Arm::getHandModelPackage
std::string getHandModelPackage() const
Definition: RobotNameHelper.cpp:278
armarx::RobotArm::getSide
std::string getSide() const
Definition: RobotNameHelper.cpp:315
armarx::RobotNameHelper
Definition: RobotNameHelper.h:147
armarx::Arm::getHandUnitName
std::string getHandUnitName() const
Definition: RobotNameHelper.cpp:253
armarx::StatechartProfilePtr
std::shared_ptr< class StatechartProfile > StatechartProfilePtr
Definition: StatechartContext.h:52
armarx::RobotNameHelper::Node::Node
Node(const RobotInfoNodePtr &robotInfo)
Definition: RobotNameHelper.cpp:149
armarx::RobotNameHelper::LocationRight
static const std::string LocationRight
Definition: RobotNameHelper.h:172
armarx::RobotArm::getTorsoKinematicChain
VirtualRobot::RobotNodeSetPtr getTorsoKinematicChain() const
Definition: RobotNameHelper.cpp:328
armarx::RobotNameHelper::getProfiles
const std::vector< std::string > & getProfiles() const
Definition: RobotNameHelper.cpp:391
armarx::RobotArm::getFullHandCollisionModel
VirtualRobot::TriMeshModelPtr getFullHandCollisionModel() const
Definition: RobotNameHelper.cpp:349
armarx::RobotNameHelper::select
std::string select(const std::string &path) const
Definition: RobotNameHelper.cpp:78
armarx::Arm::getTCP
std::string getTCP() const
Definition: RobotNameHelper.cpp:217
armarx::RobotNameHelper::writeRobotInfoNode
static void writeRobotInfoNode(const RobotInfoNodePtr &n, std::ostream &str, std::size_t indent=0, char indentChar=' ')
Definition: RobotNameHelper.cpp:39
armarx::RobotNameHelper::getRobotArm
RobotArm getRobotArm(const std::string &side, const VirtualRobot::RobotPtr &robot) const
Definition: RobotNameHelper.cpp:139
armarx::Arm::getTorsoKinematicChain
std::string getTorsoKinematicChain() const
Definition: RobotNameHelper.cpp:211
armarx::RobotNameHelper::operator=
RobotNameHelper & operator=(RobotNameHelper &&)=default
armarx::Arm::getForceTorqueSensor
std::string getForceTorqueSensor() const
Definition: RobotNameHelper.cpp:223
armarx::Arm::getEndEffector
std::string getEndEffector() const
Definition: RobotNameHelper.cpp:235
armarx::RobotArm::getHandRootNode
VirtualRobot::RobotNodePtr getHandRootNode() const
Definition: RobotNameHelper.cpp:358
armarx::RobotNameHelper::getRobotInfoNodePtr
const RobotInfoNodePtr & getRobotInfoNodePtr() const
Definition: RobotNameHelper.cpp:56
armarx::RobotNameHelperPtr
std::shared_ptr< class RobotNameHelper > RobotNameHelperPtr
Definition: RobotNameHelper.h:34
armarx::RobotArm::getTCP
VirtualRobot::RobotNodePtr getTCP() const
Definition: RobotNameHelper.cpp:335
armarx::RobotArm::getTcp2HandRootTransform
Eigen::Matrix4f getTcp2HandRootTransform() const
Definition: RobotNameHelper.cpp:365
armarx::Arm::getRobotNameHelper
std::shared_ptr< const RobotNameHelper > getRobotNameHelper() const
Definition: RobotNameHelper.cpp:144
armarx::RobotNameHelper::Node::isValid
bool isValid()
Definition: RobotNameHelper.cpp:183
armarx::RobotArm::getPalmCollisionModel
VirtualRobot::RobotNodePtr getPalmCollisionModel() const
Definition: RobotNameHelper.cpp:342
armarx::RobotArm::getKinematicChain
VirtualRobot::RobotNodeSetPtr getKinematicChain() const
Definition: RobotNameHelper.cpp:321
armarx::Arm::Arm
Arm()=default
armarx::RapidXmlReaderNode
Definition: RapidXmlReader.h:68
armarx::RobotNameHelper::Node::value
std::string value()
Definition: RobotNameHelper.cpp:151
armarx::Arm::getKinematicChain
std::string getKinematicChain() const
Definition: RobotNameHelper.cpp:205
armarx::Arm::getHandModelPath
std::string getHandModelPath() const
Definition: RobotNameHelper.cpp:265
armarx::RobotArm
Definition: RobotNameHelper.h:103
armarx::RobotNameHelper::RobotNameHelper
RobotNameHelper(const RobotInfoNodePtr &robotInfo, const StatechartProfilePtr &profile=nullptr)
Definition: RobotNameHelper.cpp:64
armarx::RobotArm::operator=
RobotArm & operator=(RobotArm &&)=default
armarx::RobotArm::getRobot
const VirtualRobot::RobotPtr & getRobot() const
Definition: RobotNameHelper.cpp:375
GfxTL::Matrix4f
MatrixXX< 4, 4, float > Matrix4f
Definition: MatrixXX.h:601
armarx::Arm::select
std::string select(const std::string &path) const
Definition: RobotNameHelper.cpp:309
armarx::Arm::getSide
std::string getSide() const
Definition: RobotNameHelper.cpp:200
armarx::RobotNameHelper::Create
static RobotNameHelperPtr Create(const RobotInfoNodePtr &robotInfo, const StatechartProfilePtr &profile)
Definition: RobotNameHelper.cpp:96
armarx::Arm
Definition: RobotNameHelper.h:41
armarx::RobotNameHelper::Node
Definition: RobotNameHelper.h:154
armarx::RobotArm::getArm
const Arm & getArm() const
Definition: RobotNameHelper.cpp:380
armarx::Arm::getForceTorqueSensorFrame
std::string getForceTorqueSensorFrame() const
Definition: RobotNameHelper.cpp:229
armarx::RobotNameHelper::Node::checkValid
void checkValid()
Definition: RobotNameHelper.cpp:188
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::Arm::operator=
Arm & operator=(Arm &&)=default
VirtualRobot::RobotPtr
std::shared_ptr< class Robot > RobotPtr
Definition: Bus.h:18
armarx::RobotNameHelper::getArm
Arm getArm(const std::string &side) const
Definition: RobotNameHelper.cpp:133
armarx::Arm::getHandControllerName
std::string getHandControllerName() const
Definition: RobotNameHelper.cpp:247