Simbody  3.7
CablePath.h
Go to the documentation of this file.
1 #ifndef SimTK_SIMBODY_CABLE_PATH_H_
2 #define SimTK_SIMBODY_CABLE_PATH_H_
3 
4 /* -------------------------------------------------------------------------- *
5  * Simbody(tm) *
6  * -------------------------------------------------------------------------- *
7  * This is part of the SimTK biosimulation toolkit originating from *
8  * Simbios, the NIH National Center for Physics-Based Simulation of *
9  * Biological Structures at Stanford, funded under the NIH Roadmap for *
10  * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. *
11  * *
12  * Portions copyright (c) 2012 Stanford University and the Authors. *
13  * Authors: Michael Sherman, Ian Stavness *
14  * Contributors: Andreas Scholz *
15  * *
16  * Licensed under the Apache License, Version 2.0 (the "License"); you may *
17  * not use this file except in compliance with the License. You may obtain a *
18  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
19  * *
20  * Unless required by applicable law or agreed to in writing, software *
21  * distributed under the License is distributed on an "AS IS" BASIS, *
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
23  * See the License for the specific language governing permissions and *
24  * limitations under the License. *
25  * -------------------------------------------------------------------------- */
26 
30 #include "SimTKmath.h"
32 
33 namespace SimTK {
34 
38 SimTK_DEFINE_UNIQUE_INDEX_TYPE(CableObstacleIndex);
39 
40 class CableTrackerSubsystem;
41 class MobilizedBody;
42 class CableObstacle;
43 
44 //==============================================================================
45 // CABLE PATH
46 //==============================================================================
93 public:
94 
99  const MobilizedBody& originBody,
100  const Vec3& defaultOriginPoint,
101  const MobilizedBody& terminationBody,
102  const Vec3& defaultTerminationPoint);
103 
108  const MobilizedBody& originBody,
109  const MobilizedBody& terminationBody);
110 
112 CablePath(const CablePath& source);
113 
115 CablePath& operator=(const CablePath& source);
116 
118 ~CablePath() {clear();}
119 
141 void solveForInitialCablePath(State& state) const;
142 
146 int getNumObstacles() const;
149 const CableObstacle& getObstacle(CableObstacleIndex obstacleIx) const;
150 
154 Real getCableLength(const State& state) const;
155 
161 Real getCableLengthDot(const State& state) const;
162 
168 void applyBodyForces(const State& state, Real tension,
169  Vector_<SpatialVec>& bodyForcesInG) const;
170 
177 Real calcCablePower(const State& state, Real tension) const;
178 
182 Real getIntegratedCableLengthDot(const State& state) const;
183 
188 void setIntegratedCableLengthDot(State& state, Real value) const;
189 
190 
193 CablePath() : impl(0) {}
194 class Impl;
195 const Impl& getImpl() const {assert(impl); return *impl;}
196 Impl& updImpl() {assert(impl); return *impl;}
197 //--------------------------------------------------------------------------
198 private:
199 void clear();
200 Impl* impl;
201 };
202 
203 
204 //==============================================================================
205 // CABLE OBSTACLE
206 //==============================================================================
211 public:
212 class ViaPoint; // also used for end points
213 class Surface;
214 
216 CableObstacle() : impl(0) {}
217 
219 explicit CableObstacle(CablePath& path);
222 CableObstacle(const CableObstacle& source);
225 CableObstacle& operator=(const CableObstacle& source);
228 ~CableObstacle() {clear();}
229 
233 const Transform& getDefaultTransform() const;
237 const MobilizedBody& getMobilizedBody() const;
239 const CablePath& getCablePath() const;
241 CableObstacleIndex getObstacleIndex() const;
245 const DecorativeGeometry& getDecorativeGeometry() const;
249 DecorativeGeometry& updDecorativeGeometry();
250 
254 bool isDisabledByDefault() const;
255 
259 CableObstacle& setDisabledByDefault(bool shouldBeDisabled);
260 
263 CableObstacle& setDefaultTransform(const Transform& X_BS);
264 
269 CableObstacle& setDecorativeGeometry(const DecorativeGeometry& viz);
270 
273 void clear();
275 bool isEmpty() const {return impl==0;}
276 
277 //--------------------------------------------------------------------------
278 class Impl;
279 const Impl& getImpl() const {assert(impl); return *impl;}
280 Impl& updImpl() {assert(impl); return *impl;}
281 
282 protected:
283 explicit CableObstacle(Impl* impl);
284 
285 private:
286 Impl* impl; // opaque pointer to reference-counted implementation object
287 };
288 
289 
290 //==============================================================================
291 // CABLE OBSTACLE :: VIA POINT
292 //==============================================================================
295 public:
299 ViaPoint(CablePath& path, const MobilizedBody& viaMobod,
300  const Vec3& defaultStation);
301 
303 static bool isInstance(const CableObstacle&);
306 static const ViaPoint& downcast(const CableObstacle&);
309 static ViaPoint& updDowncast(CableObstacle&);
310 
311 class Impl;
312 };
313 
314 //==============================================================================
315 // CABLE OBSTACLE :: SURFACE
316 //==============================================================================
321 public:
324 
329 Surface(CablePath& path, const MobilizedBody& mobod,
330  const Transform& X_BS, const ContactGeometry& surface);
331 
336 { CableObstacle::setDecorativeGeometry(viz); return *this; }
337 
348 Surface& setNearPoint(const Vec3& point);
349 
354 Surface& setContactPointHints(const Vec3& startHint,
355  const Vec3& endHint);
356 
358 static bool isInstance(const CableObstacle&);
361 static const Surface& downcast(const CableObstacle&);
364 static Surface& updDowncast(CableObstacle&);
365 class Impl;
366 };
367 
368 
369 } // namespace SimTK
370 
371 #endif // SimTK_SIMBODY_CABLE_PATH_H_
SimTK_DEFINE_UNIQUE_INDEX_TYPE(AssemblyConditionIndex)
This is the vector class intended to appear in user code for large, variable size column vectors...
Definition: BigMatrix.h:171
Surface & setDecorativeGeometry(const DecorativeGeometry &viz)
Provide visualization geometry to be used to display this obstacle.
Definition: CablePath.h:335
This is a unique integer type for identifying obstacles comprising a particular cable path...
CableObstacle & setDecorativeGeometry(const DecorativeGeometry &viz)
Replace the decorative geometry used for automatically-generated visualization of this obstacle when ...
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
Impl & updImpl()
Definition: CablePath.h:280
const Impl & getImpl() const
Definition: CablePath.h:279
~CablePath()
Delete the cable path if this handle was the last reference to it.
Definition: CablePath.h:118
Every Simbody header and source file should include this header before any other Simbody header...
This is a point through which the cable must pass.
Definition: CablePath.h:294
SimTK_Real Real
This is the default compiled-in floating point type for SimTK, either float or double.
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:606
This object is intended to contain all state information for a SimTK::System, except topological info...
Definition: State.h:280
Impl & updImpl()
Definition: CablePath.h:196
bool isEmpty() const
See if this handle is empty.
Definition: CablePath.h:275
This subsystem tracks the paths of massless, frictionless cables that take the shortest route between...
Definition: CableTrackerSubsystem.h:68
A ContactGeometry object describes the shape of all or part of the boundary of a solid object...
Definition: ContactGeometry.h:110
CablePath()
Default constructor creates an empty cable path not associated with any subsystem; don&#39;t use this...
Definition: CablePath.h:193
const Impl & getImpl() const
Definition: CablePath.h:195
~CableObstacle()
Destructor clears the handle, deleting the referenced object if this was the last reference...
Definition: CablePath.h:228
This is the client-side interface to an implementation-independent representation of "Decorations" su...
Definition: DecorativeGeometry.h:86
#define SimTK_SIMBODY_EXPORT
Definition: Simbody/include/simbody/internal/common.h:68
A MobilizedBody is Simbody&#39;s fundamental body-and-joint object used to parameterize a system&#39;s motion...
Definition: MobilizedBody.h:168
ViaPoint()
Default constructor creates an empty handle.
Definition: CablePath.h:297
An obstacle is any significant object along the cable path – one of the end points, a via point, or a surface.
Definition: CablePath.h:210
This class represents the path of a frictionless cable from an origin point fixed to a body...
Definition: CablePath.h:92
Surface()
Default constructor creates an empty handle.
Definition: CablePath.h:323
This obstacle is a solid object represented by a ContactGeometry surface.
Definition: CablePath.h:320
CableObstacle()
Create an empty obstacle handle that can refer to any type of obstacle.
Definition: CablePath.h:216