Simbody 3.9
Loading...
Searching...
No Matches
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: Nicholas Bianco
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
25namespace SimTK
26{
27
32
37
42
49{
120};
121
122class MultibodySystem;
123class CableSubsystem;
124class CableSubsystemTestHelper;
125
126//==============================================================================
183public:
187 ~CableSpan() noexcept = default;
189 CableSpan(const CableSpan&) = default;
191 CableSpan& operator=(const CableSpan& source) = default;
192 CableSpan(CableSpan&&) noexcept = default;
193 CableSpan& operator=(CableSpan&&) noexcept = default;
194
197
211 CableSubsystem& subsystem,
212 MobilizedBodyIndex originBody,
213 const Vec3& originStation,
214 MobilizedBodyIndex terminationBody,
215 const Vec3& terminationStation);
216
225 MobilizedBodyIndex obstacleBody,
226 const Transform& X_BS,
227 std::shared_ptr<const ContactGeometry> obstacleGeometry);
228
244 MobilizedBodyIndex obstacleBody,
245 const Transform& X_BS,
246 std::shared_ptr<const ContactGeometry> obstacleGeometry,
247 const Vec3& contactPointHint_S);
248
250 int getNumObstacles() const;
251
257 MobilizedBodyIndex viaPointBody,
258 const Vec3& station_B);
259
261 int getNumViaPoints() const;
262
264 CableSpanIndex getIndex() const;
265
267
270
273 MobilizedBodyIndex getOriginBodyIndex() const;
274
277 void setOriginBodyIndex(MobilizedBodyIndex originBody);
278
281 MobilizedBodyIndex getTerminationBodyIndex() const;
282
285 void setTerminationBodyIndex(MobilizedBodyIndex terminationBody);
286
288 Vec3 getOriginStation() const;
289
291 void setOriginStation(const Vec3& originStation);
292
294 Vec3 getTerminationStation() const;
295
297 void setTerminationStation(const Vec3& terminationStation);
298
300
303
309 UnitVec3 calcOriginTangentDirection(const State& state) const;
310
320 void calcOriginUnitForce(
321 const State& state,
322 SpatialVec& unitForce_G) const;
323
329 UnitVec3 calcTerminationTangentDirection(const State& state) const;
330
340 void calcTerminationUnitForce(
341 const State& state,
342 SpatialVec& unitForce_G) const;
343
345
348
353 const MobilizedBodyIndex& getObstacleMobilizedBodyIndex(
354 CableSpanObstacleIndex ix) const;
355
360 void setObstacleMobilizedBodyIndex(
362 MobilizedBodyIndex body);
363
369 const Transform& getObstacleTransformSurfaceToBody(
370 CableSpanObstacleIndex ix) const;
371
377 void setObstacleTransformSurfaceToBody(
379 const Transform& X_BS);
380
384 const ContactGeometry& getObstacleContactGeometry(
385 CableSpanObstacleIndex ix) const;
386
390 void setObstacleContactGeometry(
392 std::shared_ptr<const ContactGeometry> obstacleGeometry);
393
397 Vec3 getObstacleContactPointHint(CableSpanObstacleIndex ix) const;
398
408 void setObstacleContactPointHint(
410 Vec3 contactPointHint_S);
411
413
416
421 const MobilizedBodyIndex& getViaPointMobilizedBodyIndex(
422 CableSpanViaPointIndex ix) const;
423
428 void setViaPointMobilizedBodyIndex(
430 MobilizedBodyIndex body);
431
435 Vec3 getViaPointStation(CableSpanViaPointIndex ix) const;
436
440 void setViaPointStation(
442 const Vec3& station_B);
443
445
448
453 Real getCurveSegmentAccuracy() const;
454
459 void setCurveSegmentAccuracy(Real accuracy);
460
463 int getSolverMaxIterations() const;
464
467 void setSolverMaxIterations(int maxIterations);
468
475 int getNumSolverIterations(const State& state) const;
476
483 Real getSmoothnessTolerance() const;
484
488 void setSmoothnessTolerance(Real tolerance);
489
495 Real getSmoothness(const State& state) const;
496
498 void setAlgorithm(CableSpanAlgorithm algorithm);
499
506 bool getUseWarmStart() const;
507
513 void setUseWarmStart(bool useWarmStart);
514
516
519
524 Real calcLength(const State& state) const;
525
530 Real calcLengthDot(const State& state) const;
531
538 void applyBodyForces(
539 const State& state,
540 Real tension,
541 Vector_<SpatialVec>& bodyForcesInG) const;
542
548 Real calcCablePower(const State& state, Real tension) const;
549
555 void calcDecorativePathPoints(
556 const State& state,
557 const std::function<void(Vec3 point_G)>& sink) const;
558
574 void calcResampledDecorativePathPoints(
575 const State& state,
576 int numCurveSegmentSamples,
577 const std::function<void(Vec3 point_G)>& sink) const;
578
580
583
588 bool isInContactWithObstacle(const State& state, CableSpanObstacleIndex ix)
589 const;
590
601 Transform calcCurveSegmentInitialFrenetFrame(
602 const State& state,
603 CableSpanObstacleIndex ix) const;
604
615 Transform calcCurveSegmentFinalFrenetFrame(
616 const State& state,
617 CableSpanObstacleIndex ix) const;
618
625 Real calcCurveSegmentArcLength(
626 const State& state,
627 CableSpanObstacleIndex ix) const;
628
650 void calcCurveSegmentResampledPoints(
651 const State& state,
653 int numSamples,
654 const std::function<void(Vec3 point_G)>& sink) const;
655
663 void calcCurveSegmentUnitForce(
664 const State& state,
666 SpatialVec& unitForce_G) const;
667
669
672
678 Vec3 calcViaPointLocation(
679 const State& state,
680 CableSpanViaPointIndex ix) const;
681
689 void calcViaPointUnitForce(
690 const State& state,
692 SpatialVec& unitForce_G) const;
693
699 UnitVec3 calcViaPointIncomingTangentDirection(
700 const State& state,
701 CableSpanViaPointIndex ix) const;
702
709 UnitVec3 calcViaPointOutgoingTangentDirection(
710 const State& state,
711 CableSpanViaPointIndex ix) const;
712
714
// Hide from Doxygen.
716 class Impl;
717
718private:
719 const Impl& getImpl() const
720 {
721 return *m_impl;
722 }
723
724 Impl& updImpl()
725 {
726 return *m_impl;
727 }
728
729 std::shared_ptr<Impl> m_impl;
730
731 friend CableSubsystem;
732
733 // Befriend the helper class for testing the implementation.
734 friend CableSubsystemTestHelper;
736};
737
738//==============================================================================
748public:
750
752
757 int getNumCables() const;
758
761
764
// Hide from Doxygen.
767
768 class Impl;
769 Impl& updImpl();
770 const Impl& getImpl() const;
771
772 // Befriend the helper class for testing the implementation.
773 friend CableSubsystemTestHelper;
775};
776
// Hide from Doxygen.
778//==============================================================================
808class SimTK_SIMBODY_EXPORT CableSubsystemTestHelper {
809public:
812 CableSubsystemTestHelper();
813 ~CableSubsystemTestHelper() noexcept;
814 CableSubsystemTestHelper(const CableSubsystemTestHelper&);
815 CableSubsystemTestHelper& operator=(const CableSubsystemTestHelper&);
816 CableSubsystemTestHelper(CableSubsystemTestHelper&&) noexcept;
817 CableSubsystemTestHelper& operator=(CableSubsystemTestHelper&&) noexcept;
818
826 void testCurrentPath(
827 const State& state,
828 const CableSubsystem& subsystem,
829 std::ostream& testReport) const;
830
831 class Impl;
832
833private:
834 std::unique_ptr<Impl> m_impl;
835};
838} // namespace SimTK
839
840#endif
This defines the MobilizedBody class, which associates a new body (the "child", "outboard",...
#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:445
#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:613
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 within a particular CableSpan.
This is a unique integer type for identifying via points within a particular CableSpan.
This class represents the path of a frictionless cable from an origin point fixed to a body,...
Definition CableSpan.h:182
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:747
const MultibodySystem & getMultibodySystem() const
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.
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:52
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition Assembler.h:37
CableSpanAlgorithm
These are the different solver options for computing the optimal path of a CableSpan.
Definition CableSpan.h:49
@ 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:626