Simbody 3.7
Loading...
Searching...
No Matches
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
33namespace SimTK {
34
39
41class MobilizedBody;
42class CableObstacle;
43
44//==============================================================================
45// CABLE PATH
46//==============================================================================
93public:
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
112CablePath(const CablePath& source);
113
116
118~CablePath() {clear();}
119
142
146int getNumObstacles() const;
150
154Real getCableLength(const State& state) const;
155
161Real getCableLengthDot(const State& state) const;
162
168void applyBodyForces(const State& state, Real tension,
169 Vector_<SpatialVec>& bodyForcesInG) const;
170
177Real calcCablePower(const State& state, Real tension) const;
178
183
188void setIntegratedCableLengthDot(State& state, Real value) const;
189
190
193CablePath() : impl(0) {}
194class Impl;
195const Impl& getImpl() const {assert(impl); return *impl;}
196Impl& updImpl() {assert(impl); return *impl;}
197//--------------------------------------------------------------------------
198private:
199void clear();
200Impl* impl;
201};
202
203
204//==============================================================================
205// CABLE OBSTACLE
206//==============================================================================
211public:
212class ViaPoint; // also used for end points
213class Surface;
214
216CableObstacle() : impl(0) {}
217
219explicit CableObstacle(CablePath& path);
228~CableObstacle() {clear();}
229
239const CablePath& getCablePath() const;
250
255
259CableObstacle& setDisabledByDefault(bool shouldBeDisabled);
260
264
270
273void clear();
275bool isEmpty() const {return impl==0;}
276
277//--------------------------------------------------------------------------
278class Impl;
279const Impl& getImpl() const {assert(impl); return *impl;}
280Impl& updImpl() {assert(impl); return *impl;}
281
282protected:
283explicit CableObstacle(Impl* impl);
284
285private:
286Impl* impl; // opaque pointer to reference-counted implementation object
287};
288
289
290//==============================================================================
291// CABLE OBSTACLE :: VIA POINT
292//==============================================================================
295public:
299ViaPoint(CablePath& path, const MobilizedBody& viaMobod,
300 const Vec3& defaultStation);
301
303static bool isInstance(const CableObstacle&);
306static const ViaPoint& downcast(const CableObstacle&);
310
311class Impl;
312};
313
314//==============================================================================
315// CABLE OBSTACLE :: SURFACE
316//==============================================================================
321public:
324
329Surface(CablePath& path, const MobilizedBody& mobod,
330 const Transform& X_BS, const ContactGeometry& surface);
331
336{ CableObstacle::setDecorativeGeometry(viz); return *this; }
337
348Surface& setNearPoint(const Vec3& point);
349
355 const Vec3& endHint);
356
358static bool isInstance(const CableObstacle&);
361static const Surface& downcast(const CableObstacle&);
365class Impl;
366};
367
368
369} // namespace SimTK
370
371#endif // SimTK_SIMBODY_CABLE_PATH_H_
#define SimTK_DEFINE_UNIQUE_INDEX_TYPE(NAME)
Use this macro to define a unique "Index" type which is just a type-safe non-negative int,...
Definition SimTKcommon/include/SimTKcommon/internal/common.h:426
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.
static bool isInstance(const CableObstacle &)
Return true if the given CableObstacle is a Surface.
static Surface & updDowncast(CableObstacle &)
Cast the given CableObstacle to a writable Surface; will throw an exception if the obstacle is not a ...
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 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 & setNearPoint(const Vec3 &point)
Optionally provide a "near point" that can be used during path initialization to disambiguate when th...
Surface()
Default constructor creates an empty handle.
Definition CablePath.h:323
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...
static ViaPoint & updDowncast(CableObstacle &)
Cast the given CableObstacle to a writable ViaPoint; will throw an exception if the obstacle is not a...
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.
An obstacle is any significant object along the cable path – one of the end points,...
Definition CablePath.h:210
const CablePath & getCablePath() const
Return a reference to the CablePath in which this obstacle resides.
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
const Transform & getDefaultTransform() const
Return the default pose X_BS of the obstacle S on its body B.
DecorativeGeometry & updDecorativeGeometry()
Obtain writable access to the decorative geometry stored with this obstacle so you can modify it.
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.
CableObstacle & setDecorativeGeometry(const DecorativeGeometry &viz)
Replace the decorative geometry used for automatically-generated visualization of this obstacle when ...
const DecorativeGeometry & getDecorativeGeometry() const
Return decorative geometry that can be used to display this obstacle.
CableObstacle & operator=(const CableObstacle &source)
Copy assignment is shallow and reference-counted; this handle will point to the same object as does t...
const Impl & getImpl() const
Definition CablePath.h:279
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.
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
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.
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,...
const Impl & getImpl() const
Definition CablePath.h:195
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...
Impl & updImpl()
Definition CablePath.h:196
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.
~CablePath()
Delete the cable path if this handle was the last reference to it.
Definition CablePath.h:118
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:110
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:606