Simbody  3.8
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 
39 
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;
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 
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);
228 ~CableObstacle() {clear();}
229 
239 const CablePath& getCablePath() const;
250 
254 bool isDisabledByDefault() const;
255 
259 CableObstacle& setDisabledByDefault(bool shouldBeDisabled);
260 
264 
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&);
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&);
365 class Impl;
366 };
367 
368 
369 } // namespace SimTK
370 
371 #endif // SimTK_SIMBODY_CABLE_PATH_H_
Every Simbody header and source file should include this header before any other Simbody header.
#define SimTK_SIMBODY_EXPORT
Definition: Simbody/include/simbody/internal/common.h:68
This is a unique integer type for identifying obstacles comprising a particular cable path.
This obstacle is a solid object represented by a ContactGeometry surface.
Definition: CablePath.h:320
Surface(CablePath &path, const MobilizedBody &mobod, const Transform &X_BS, const ContactGeometry &surface)
Create a new wrapping surface obstacle and insert it into the given CablePath.
Surface & setContactPointHints(const Vec3 &startHint, const Vec3 &endHint)
Optionally provide some hints for the initialization algorithm to use as starting guesses for the con...
static bool isInstance(const CableObstacle &)
Return true if the given CableObstacle is a Surface.
static const Surface & downcast(const CableObstacle &)
Cast the given CableObstacle to a const Surface; will throw an exception if the obstacle is not a sur...
Surface()
Default constructor creates an empty handle.
Definition: CablePath.h:323
static Surface & updDowncast(CableObstacle &)
Cast the given CableObstacle to a writable Surface; will throw an exception if the obstacle is not a ...
Surface & setNearPoint(const Vec3 &point)
Optionally provide a "near point" that can be used during path initialization to disambiguate when th...
Surface & setDecorativeGeometry(const DecorativeGeometry &viz)
Provide visualization geometry to be used to display this obstacle.
Definition: CablePath.h:335
This is a point through which the cable must pass.
Definition: CablePath.h:294
ViaPoint()
Default constructor creates an empty handle.
Definition: CablePath.h:297
static const ViaPoint & downcast(const CableObstacle &)
Cast the given CableObstacle to a const ViaPoint; will throw an exception if the obstacle is not a vi...
ViaPoint(CablePath &path, const MobilizedBody &viaMobod, const Vec3 &defaultStation)
Insert a via point obstacle to the given cable path.
static bool isInstance(const CableObstacle &)
Return true if the given CableObstacle is a ViaPoint.
static ViaPoint & updDowncast(CableObstacle &)
Cast the given CableObstacle to a writable ViaPoint; will throw an exception if the obstacle is not a...
An obstacle is any significant object along the cable path – one of the end points,...
Definition: CablePath.h:210
const Impl & getImpl() const
Definition: CablePath.h:279
CableObstacle & operator=(const CableObstacle &source)
Copy assignment is shallow and reference-counted; this handle will point to the same object as does t...
void clear()
Clear this handle, deleting the referenced object if this was the last reference.
const MobilizedBody & getMobilizedBody() const
Get a reference to the Mobilized body to which this obstacle is fixed.
CableObstacle()
Create an empty obstacle handle that can refer to any type of obstacle.
Definition: CablePath.h:216
CableObstacle & setDecorativeGeometry(const DecorativeGeometry &viz)
Replace the decorative geometry used for automatically-generated visualization of this obstacle when ...
CableObstacle(Impl *impl)
CableObstacle(const CableObstacle &source)
Copy constructor is shallow and reference-counted; this handle will point to the same object as does ...
CableObstacleIndex getObstacleIndex() const
Return the obstacle index within this obstacle's CablePath.
const DecorativeGeometry & getDecorativeGeometry() const
Return decorative geometry that can be used to display this obstacle.
CableObstacle & setDisabledByDefault(bool shouldBeDisabled)
Set the "disabled by default" flag.
CableObstacle(CablePath &path)
Insert this obstacle into the given cable path.
CableObstacle & setDefaultTransform(const Transform &X_BS)
Replace the default transform for this obstacle; this is usually set in the constructor.
DecorativeGeometry & updDecorativeGeometry()
Obtain writable access to the decorative geometry stored with this obstacle so you can modify it.
const Transform & getDefaultTransform() const
Return the default pose X_BS of the obstacle S on its body B.
bool isDisabledByDefault() const
Is this obstacle disabled by default? Note that this does not tell you whether it is currently disabl...
~CableObstacle()
Destructor clears the handle, deleting the referenced object if this was the last reference.
Definition: CablePath.h:228
bool isEmpty() const
See if this handle is empty.
Definition: CablePath.h:275
Impl & updImpl()
Definition: CablePath.h:280
const CablePath & getCablePath() const
Return a reference to the CablePath in which this obstacle resides.
This class represents the path of a frictionless cable from an origin point fixed to a body,...
Definition: CablePath.h:92
CablePath(CableTrackerSubsystem &cables, const MobilizedBody &originBody, const MobilizedBody &terminationBody)
Constructor taking only the origin and terminal bodies with the expectation that you'll set the end p...
Real getCableLengthDot(const State &state) const
Return the cable rate (time derivative of cable length) that was calculated for the configuration and...
void setIntegratedCableLengthDot(State &state, Real value) const
(Advanced) Initialize the integral of the cable length rate.
Real getCableLength(const State &state) const
Return the total length of the cable that was calculated for the configuration supplied in state.
Impl & updImpl()
Definition: CablePath.h:196
int getNumObstacles() const
Return the total number of obstacles (origin point, surfaces and via points, and termination point) t...
void applyBodyForces(const State &state, Real tension, Vector_< SpatialVec > &bodyForcesInG) const
Given a tension > 0 acting uniformly along this cable, apply the resulting forces to the bodies it to...
CablePath()
Default constructor creates an empty cable path not associated with any subsystem; don't use this.
Definition: CablePath.h:193
Real calcCablePower(const State &state, Real tension) const
Calculate the power this cable would apply or dissipate at the given tension (>0) value,...
CablePath & operator=(const CablePath &source)
Copy assignment is shallow and reference counted.
CablePath(CableTrackerSubsystem &cables, const MobilizedBody &originBody, const Vec3 &defaultOriginPoint, const MobilizedBody &terminationBody, const Vec3 &defaultTerminationPoint)
Create a straight-line cable path connecting a point fixed on one body with one fixed on another body...
CablePath(const CablePath &source)
Copy constructor is shallow and reference counted.
const Impl & getImpl() const
Definition: CablePath.h:195
~CablePath()
Delete the cable path if this handle was the last reference to it.
Definition: CablePath.h:118
const CableObstacle & getObstacle(CableObstacleIndex obstacleIx) const
Return a const reference to one of the obstacles along this path, given by its index starting at zero...
Real getIntegratedCableLengthDot(const State &state) const
(Advanced) Get the time integral of cable length dot.
void solveForInitialCablePath(State &state) const
TODO: Calculate the initial cable path, without using any prior solution.
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:111
This is the client-side interface to an implementation-independent representation of "Decorations" su...
Definition: DecorativeGeometry.h:86
A MobilizedBody is Simbody's fundamental body-and-joint object used to parameterize a system's motion...
Definition: MobilizedBody.h:169
This object is intended to contain all state information for a SimTK::System, except topological info...
Definition: State.h:280
This is the vector class intended to appear in user code for large, variable size column vectors.
Definition: Vector_.h:50
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
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:607
SimTK_DEFINE_UNIQUE_INDEX_TYPE(AssemblyConditionIndex)