Simbody  3.8
CableSpan.h
Go to the documentation of this file.
1 #ifndef SimTK_SIMBODY_CABLE_SPAN_H_
2 #define SimTK_SIMBODY_CABLE_SPAN_H_
3 
4 /*-----------------------------------------------------------------------------
5  Simbody(tm)
6 -------------------------------------------------------------------------------
7  Copyright (c) 2024 Authors.
8  Authors: Pepijn van den Bos
9  Contributors:
10 
11  Licensed under the Apache License, Version 2.0 (the "License"); you may
12  not use this file except in compliance with the License. You may obtain a
13  copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
14 
15  Unless required by applicable law or agreed to in writing, software
16  distributed under the License is distributed on an "AS IS" BASIS,
17  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  See the License for the specific language governing permissions and
19  limitations under the License.
20  ----------------------------------------------------------------------------*/
21 
24 
25 namespace SimTK
26 {
27 
32 
37 
44 {
60  Scholz2015,
115 };
116 
117 class MultibodySystem;
118 class CableSubsystem;
119 class CableSubsystemTestHelper;
120 
121 //==============================================================================
168 public:
172  ~CableSpan() noexcept = default;
174  CableSpan(const CableSpan&) = default;
176  CableSpan& operator=(const CableSpan& source) = default;
177  CableSpan(CableSpan&&) noexcept = default;
178  CableSpan& operator=(CableSpan&&) noexcept = default;
179 
182 
196  CableSubsystem& subsystem,
197  MobilizedBodyIndex originBody,
198  const Vec3& originStation,
199  MobilizedBodyIndex terminationBody,
200  const Vec3& terminationStation);
201 
210  MobilizedBodyIndex obstacleBody,
211  const Transform& X_BS,
212  std::shared_ptr<const ContactGeometry> obstacleGeometry);
213 
227  MobilizedBodyIndex obstacleBody,
228  const Transform& X_BS,
229  std::shared_ptr<const ContactGeometry> obstacleGeometry,
230  const Vec3& contactPointHint_S);
231 
233  int getNumObstacles() const;
234 
236 
239 
242  MobilizedBodyIndex getOriginBodyIndex() const;
243 
246  void setOriginBodyIndex(MobilizedBodyIndex originBody);
247 
250  MobilizedBodyIndex getTerminationBodyIndex() const;
251 
254  void setTerminationBodyIndex(MobilizedBodyIndex terminationBody);
255 
257  Vec3 getOriginStation() const;
258 
260  void setOriginStation(const Vec3& originStation);
261 
264  Vec3 getTerminationStation() const;
265 
268  void setTerminationStation(const Vec3& terminationStation);
269 
271 
274 
279  const MobilizedBodyIndex& getObstacleMobilizedBodyIndex(
280  CableSpanObstacleIndex ix) const;
281 
286  void setObstacleMobilizedBodyIndex(
288  MobilizedBodyIndex body);
289 
295  const Transform& getObstacleTransformSurfaceToBody(
296  CableSpanObstacleIndex ix) const;
297 
303  void setObstacleTransformSurfaceToBody(
305  const Transform& X_BS);
306 
310  const ContactGeometry& getObstacleContactGeometry(
311  CableSpanObstacleIndex ix) const;
312 
316  void setObstacleContactGeometry(
318  std::shared_ptr<const ContactGeometry> obstacleGeometry);
319 
323  Vec3 getObstacleContactPointHint(CableSpanObstacleIndex ix) const;
324 
332  void setObstacleContactPointHint(
334  Vec3 contactPointHint_S);
335 
337 
340 
345  Real getCurveSegmentAccuracy() const;
346 
351  void setCurveSegmentAccuracy(Real accuracy);
352 
355  int getSolverMaxIterations() const;
356 
359  void setSolverMaxIterations(int maxIterations);
360 
365  int getNumSolverIterations(const State& state) const;
366 
373  Real getSmoothnessTolerance() const;
374 
378  void setSmoothnessTolerance(Real tolerance);
379 
383  Real getSmoothness(const State& state) const;
384 
386  void setAlgorithm(CableSpanAlgorithm algorithm);
387 
389 
392 
397  Real calcLength(const State& state) const;
398 
403  Real calcLengthDot(const State& state) const;
404 
411  void applyBodyForces(
412  const State& state,
413  Real tension,
414  Vector_<SpatialVec>& bodyForcesInG) const;
415 
421  Real calcCablePower(const State& state, Real tension) const;
422 
428  void calcDecorativePathPoints(
429  const State& state,
430  const std::function<void(Vec3 point_G)>& sink) const;
431 
433 
436 
441  bool isInContactWithObstacle(const State& state, CableSpanObstacleIndex ix)
442  const;
443 
454  Transform calcCurveSegmentInitialFrenetFrame(
455  const State& state,
456  CableSpanObstacleIndex ix) const;
457 
468  Transform calcCurveSegmentFinalFrenetFrame(
469  const State& state,
470  CableSpanObstacleIndex ix) const;
471 
478  Real calcCurveSegmentArcLength(
479  const State& state,
480  CableSpanObstacleIndex ix) const;
481 
501  void calcCurveSegmentResampledPoints(
502  const State& state,
504  int numSamples,
505  const std::function<void(Vec3 point_G)>& sink) const;
506 
508  // Hide from Doxygen.
510  class Impl;
511 
512 private:
513  const Impl& getImpl() const
514  {
515  return *m_impl;
516  }
517 
518  Impl& updImpl()
519  {
520  return *m_impl;
521  }
522 
523  std::shared_ptr<Impl> m_impl;
524 
525  friend CableSubsystem;
526 
527  // Befriend the helper class for testing the implementation.
528  friend CableSubsystemTestHelper;
530 };
531 
532 //==============================================================================
542 public:
544 
546 
551  int getNumCables() const;
552 
555 
558  // Hide from Doxygen.
561 
562  class Impl;
563  Impl& updImpl();
564  const Impl& getImpl() const;
565 
566  // Befriend the helper class for testing the implementation.
567  friend CableSubsystemTestHelper;
569 };
570  // Hide from Doxygen.
572 //==============================================================================
602 class SimTK_SIMBODY_EXPORT CableSubsystemTestHelper {
603 public:
606  CableSubsystemTestHelper();
607  ~CableSubsystemTestHelper() noexcept;
608  CableSubsystemTestHelper(const CableSubsystemTestHelper&);
609  CableSubsystemTestHelper& operator=(const CableSubsystemTestHelper&);
610  CableSubsystemTestHelper(CableSubsystemTestHelper&&) noexcept = default;
611  CableSubsystemTestHelper& operator=(CableSubsystemTestHelper&&) noexcept =
612  default;
613 
621  void testCurrentPath(
622  const State& state,
623  const CableSubsystem& subsystem,
624  std::ostream& testReport) const;
625 
626  class Impl;
627 
628 private:
629  std::unique_ptr<Impl> m_impl;
630 };
633 } // namespace SimTK
634 
635 #endif
This defines the MobilizedBody class, which associates a new body (the "child", "outboard",...
#define SimTK_PIMPL_DOWNCAST(Derived, Parent)
Similar to the above but for private implementation abstract classes, that is, abstract class hierarc...
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:594
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 quickly identifying specific cables for fast lookup purposes.
This is a unique integer type for identifying obstacles comprising a particular CableSpan.
This class represents the path of a frictionless cable from an origin point fixed to a body,...
Definition: CableSpan.h:167
CableSpan()
Construct a new cable that can be configured later.
~CableSpan() noexcept=default
Delete the cable if this handle was the last reference to it.
This subsystem manages cables spanning between two points in a system.
Definition: CableSpan.h:541
int getNumCables() const
Get the number of cables being managed by this subsystem.
const CableSpan & getCable(CableSpanIndex ix) const
Get const access to a particular cable.
CableSpan & updCable(CableSpanIndex ix)
Get writeable access to a particular cable.
const MultibodySystem & getMultibodySystem() const
CableSubsystem(MultibodySystem &)
A ContactGeometry object describes the shape of all or part of the boundary of a solid object,...
Definition: ContactGeometry.h:111
This is for arrays indexed by mobilized body number within a subsystem (typically the SimbodyMatterSu...
The job of the MultibodySystem class is to coordinate the activities of various subsystems which can ...
Definition: MultibodySystem.h:48
This object is intended to contain all state information for a SimTK::System, except topological info...
Definition: State.h:280
A Subsystem is expected to be part of a larger System and to have interdependencies with other subsys...
Definition: Subsystem.h:55
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
CableSpanAlgorithm
Definition: CableSpan.h:44
@ Scholz2015
This is the original algorithm as described in:
@ MinimumLength
The Minimal length algorithm finds the optimal path by minimizing the total cable length directly,...
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)