GCC Code Coverage Report


Directory: ./
File: src/robot.impl.hh
Date: 2024-12-13 15:50:05
Exec Total Coverage
Lines: 1 1 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 // Copyright (C) 2009, 2010 by Florent Lamiraux, Thomas Moulard, JRL.
2 //
3
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // 1. Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright
12 // notice, this list of conditions and the following disclaimer in the
13 // documentation and/or other materials provided with the distribution.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26 // DAMAGE.
27 //
28 // This software is provided "as is" without warranty of any kind,
29 // either expressed or implied, including but not limited to the
30 // implied warranties of fitness for a particular purpose.
31 //
32 // See the COPYING file for more information.
33
34 #ifndef HPP_CORBASERVER_ROBOT_IMPL_HH
35 #define HPP_CORBASERVER_ROBOT_IMPL_HH
36 #include <coal/BVH/BVH_model.h>
37
38 #include <map>
39 #include <string>
40 // # include <hpp/pinocchio/object-factory.hh>
41 #include "hpp/corbaserver/fwd.hh"
42 #include "hpp/corbaserver/object-map.hh"
43 #include "hpp/corbaserver/robot-idl.hh"
44 #include "hpp/core/problem-solver.hh"
45
46 namespace hpp {
47 namespace corbaServer {
48 namespace impl {
49 using CORBA::Long;
50 /**
51 Robots and obstacles are stored in object core::Planner.
52
53 The kinematic part of a robot is stored in a
54 CkppDeviceComponent object (see KineoWorks documentation).
55
56 \li To each \em joint is attached a \em body (CkwsBody).
57
58 \li Each \em body contains a list of CkcdObject (derived into
59 CkppKCDPolyhedron).
60
61 \li A \em polyhedron is defined by a set of \em vertices and a
62 set of \em facets.
63
64 Obstacles are stored in collision lists (CkcdCollisionList)
65 composed of polyhedra (CkppKCDPolyhedron).
66 */
67
68 /// \brief Implementation of corba interface hpp::Robot.
69 ///
70 /// The construction of a
71 class Robot : public virtual POA_hpp::corbaserver::Robot {
72 public:
73 Robot();
74
75 8 void setServer(ServerPlugin* server) { server_ = server; }
76
77 virtual void createRobot(const char* robotName);
78
79 virtual void loadRobotModel(const char* robotName, const char* rootJointType,
80 const char* urdfName, const char* srdfName);
81
82 virtual void loadHumanoidModel(const char* robotName,
83 const char* rootJointType,
84 const char* urdfName, const char* srdfName);
85
86 virtual void loadRobotModelFromString(const char* robotName,
87 const char* rootJointType,
88 const char* urdfString,
89 const char* srdfString);
90
91 virtual void loadHumanoidModelFromString(const char* robotName,
92 const char* rootJointType,
93 const char* urdfString,
94 const char* srdfString);
95
96 virtual char* getRobotName();
97
98 virtual Long getConfigSize();
99
100 virtual Long getNumberDof();
101
102 virtual void appendJoint(const char* parentName, const char* jointName,
103 const char* jointType, const Transform_ pos);
104
105 virtual Names_t* getJointNames();
106 virtual Names_t* getJointTypes();
107 virtual Names_t* getAllJointNames();
108 virtual Names_t* getChildJointNames(const char* jointName);
109 virtual char* getParentJointName(const char* jointName);
110 virtual hpp::floatSeq* getJointConfig(const char* jointName);
111 virtual void setJointConfig(const char* jointName, const floatSeq& cfg);
112 virtual char* getJointType(const char* jointName);
113 virtual floatSeq* jointIntegrate(const floatSeq& jointCfg,
114 const char* jointName, const floatSeq& dq,
115 bool saturate);
116 virtual hpp::floatSeqSeq* getCurrentTransformation(const char* jointName);
117 virtual Transform__slice* getJointPositionInParentFrame(
118 const char* jointName);
119 virtual Transform__slice* getJointPosition(const char* jointName);
120 virtual TransformSeq* getJointsPosition(const floatSeq& q,
121 const Names_t& jointNames);
122 virtual floatSeq* getJointVelocity(const char* jointName);
123 virtual floatSeq* getJointVelocityInLocalFrame(const char* jointName);
124
125 virtual Transform__slice* getRootJointPosition();
126
127 virtual void setRootJointPosition(const Transform_ position);
128
129 virtual void setJointPositionInParentFrame(const char* jointName,
130 const Transform_ position);
131
132 virtual Long getJointNumberDof(const char* jointName);
133 virtual Long getJointConfigSize(const char* jointName);
134
135 virtual hpp::floatSeq* getJointBounds(const char* jointName);
136 virtual void setJointBounds(const char* jointName,
137 const hpp::floatSeq& jointBound);
138
139 virtual Transform__slice* getLinkPosition(const char* linkName);
140
141 virtual TransformSeq* getLinksPosition(const floatSeq& q,
142 const Names_t& linkName);
143
144 virtual Names_t* getLinkNames(const char* jointName);
145
146 virtual void setDimensionExtraConfigSpace(ULong dimension);
147
148 virtual ULong getDimensionExtraConfigSpace();
149
150 virtual void setExtraConfigSpaceBounds(const hpp::floatSeq& bounds);
151
152 virtual void setCurrentConfig(const hpp::floatSeq& dofArray);
153
154 virtual hpp::floatSeq* shootRandomConfig();
155 virtual hpp::floatSeq* getCurrentConfig();
156
157 virtual void setCurrentVelocity(const hpp::floatSeq& qDot);
158 virtual hpp::floatSeq* getCurrentVelocity();
159
160 virtual Names_t* getJointInnerObjects(const char* bodyName);
161
162 virtual Names_t* getJointOuterObjects(const char* bodyName);
163
164 virtual void getObjectPosition(const char* objectName, Transform_ cfg);
165
166 virtual void isConfigValid(const hpp::floatSeq& dofArray, Boolean& validity,
167 CORBA::String_out report);
168
169 virtual void distancesToCollision(hpp::floatSeq_out distances,
170 Names_t_out innerObjects,
171 Names_t_out outerObjects,
172 hpp::floatSeqSeq_out innerPoints,
173 hpp::floatSeqSeq_out outerPoints);
174
175 virtual void autocollisionCheck(hpp::boolSeq_out collide);
176
177 virtual void autocollisionPairs(Names_t_out innerObjects,
178 Names_t_out outerObjects, boolSeq_out active);
179
180 virtual void setAutoCollision(const char* innerObject,
181 const char* outerObject, bool active);
182
183 virtual Double getMass();
184
185 virtual hpp::floatSeq* getCenterOfMass();
186
187 virtual hpp::floatSeq* getCenterOfMassVelocity();
188
189 virtual hpp::floatSeqSeq* getJacobianCenterOfMass();
190
191 virtual void createPolyhedron(const char* polyhedronName);
192
193 virtual void createBox(const char* name, Double x, Double y, Double z);
194
195 virtual void createSphere(const char* name, Double radius);
196
197 virtual void createCylinder(const char* name, Double radius, Double length);
198
199 virtual ULong addPoint(const char* polyhedronName, Double x, Double y,
200 Double z);
201
202 virtual ULong addTriangle(const char* polyhedronName, ULong pt1, ULong pt2,
203 ULong pt3);
204
205 virtual void addObjectToJoint(const char* jointName, const char* objectName,
206 const Transform_ config);
207
208 virtual void addPartialCom(const char* comName, const Names_t& jointNames);
209
210 virtual hpp::floatSeq* getPartialCom(const char* comName);
211
212 virtual hpp::floatSeqSeq* getJacobianPartialCom(const char* comName);
213
214 virtual hpp::floatSeq* getVelocityPartialCom(const char* comName);
215
216 hpp::pinocchio_idl::CenterOfMassComputation_ptr getCenterOfMassComputation(
217 const char* name);
218
219 virtual floatSeq* getRobotAABB();
220
221 private:
222 CollisionObjectConstPtr_t getObjectByName(const char* name);
223
224 ObjectMap objectMap_;
225
226 /// \brief Pointer to the ServerPlugin owning this object.
227 ServerPlugin* server_;
228
229 /// \brief Pointer to hpp::core::ProblemSolver object of ServerPlugin.
230 core::ProblemSolverPtr_t problemSolver();
231 };
232 } // end of namespace impl.
233 } // end of namespace corbaServer.
234 } // end of namespace hpp.
235
236 #endif
237