Simbody  3.6
SimbodyMatterSubsystem.h
Go to the documentation of this file.
1 #ifndef SimTK_SIMBODY_MATTER_SUBSYSTEM_H_
2 #define SimTK_SIMBODY_MATTER_SUBSYSTEM_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) 2006-15 Stanford University and the Authors. *
13  * Authors: Michael Sherman *
14  * Contributors: Paul Mitiguy *
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 
27 #include "SimTKcommon.h"
30 
31 #include <cassert>
32 #include <vector>
33 #include <iostream>
34 
35 class SimbodyMatterSubsystemRep;
36 
37 namespace SimTK {
38 
39 class MobilizedBody;
40 class MultibodySystem;
41 class Constraint;
42 
43 class UnilateralContact;
44 class StateLimitedFriction;
45 
134 public:
135 
136 //==============================================================================
161 ~SimbodyMatterSubsystem() {} // invokes ~Subsystem()
162 
167 const MobilizedBody& getMobilizedBody(MobilizedBodyIndex) const;
168 
173 MobilizedBody& updMobilizedBody(MobilizedBodyIndex);
174 
177 const MobilizedBody::Ground& getGround() const;
181 MobilizedBody::Ground& updGround();
188 MobilizedBody::Ground& Ground() {return updGround();}
189 
193 const Constraint& getConstraint(ConstraintIndex) const;
194 
198 Constraint& updConstraint(ConstraintIndex);
199 
203 void setShowDefaultGeometry(bool show);
206 bool getShowDefaultGeometry() const;
207 
225 int getNumBodies() const;
226 
230 int getNumConstraints() const;
231 
234 int getNumMobilities() const;
235 
238 int getTotalQAlloc() const;
239 
252 MobilizedBodyIndex adoptMobilizedBody(MobilizedBodyIndex parent,
253  MobilizedBody& child);
254 
265 ConstraintIndex adoptConstraint(Constraint&);
266 
268 UnilateralContactIndex adoptUnilateralContact(UnilateralContact*);
269 int getNumUnilateralContacts() const;
270 const UnilateralContact& getUnilateralContact(UnilateralContactIndex) const;
271 UnilateralContact& updUnilateralContact(UnilateralContactIndex);
273 StateLimitedFrictionIndex adoptStateLimitedFriction(StateLimitedFriction*);
274 int getNumStateLimitedFrictions() const;
276 getStateLimitedFriction(StateLimitedFrictionIndex) const;
278 updStateLimitedFriction(StateLimitedFrictionIndex);
279 
284 { Subsystem::operator=(ss); return *this; }
285 
286 
287 //==============================================================================
302 void setUseEulerAngles(State& state, bool useEulerAngles) const;
303 
306 bool getUseEulerAngles(const State& state) const;
307 
312 int getNumQuaternionsInUse(const State& state) const;
313 
318 bool isUsingQuaternion(const State& state, MobilizedBodyIndex mobodIx) const;
319 
325 QuaternionPoolIndex getQuaternionPoolIndex(const State& state,
326  MobilizedBodyIndex mobodIx) const;
327 
334 void setConstraintIsDisabled(State& state,
335  ConstraintIndex constraintIx,
336  bool shouldDisableConstraint) const;
337 
341 bool isConstraintDisabled(const State&, ConstraintIndex constraint) const;
342 
349 void convertToEulerAngles(const State& inputState, State& outputState) const;
350 
357 void convertToQuaternions(const State& inputState, State& outputState) const;
358 
366 void normalizeQuaternions(State& state) const;
367 
371 //==============================================================================
385 Real calcSystemMass(const State& s) const;
386 
391 Vec3 calcSystemMassCenterLocationInGround(const State& s) const;
392 
397 MassProperties calcSystemMassPropertiesInGround(const State& s) const;
398 
403 Inertia calcSystemCentralInertiaInGround(const State& s) const;
404 
409 Vec3 calcSystemMassCenterVelocityInGround(const State& s) const;
410 
415 Vec3 calcSystemMassCenterAccelerationInGround(const State& s) const;
416 
423 SpatialVec calcSystemMomentumAboutGroundOrigin(const State& s) const;
424 
432 SpatialVec calcSystemCentralMomentum(const State& s) const;
433 
438 Real calcKineticEnergy(const State& state) const;
441 //==============================================================================
554 void multiplyBySystemJacobian( const State& state,
555  const Vector& u,
556  Vector_<SpatialVec>& Ju) const;
557 
585 void calcBiasForSystemJacobian(const State& state,
586  Vector_<SpatialVec>& JDotu) const;
587 
588 
592 void calcBiasForSystemJacobian(const State& state,
593  Vector& JDotu) const;
594 
646 void multiplyBySystemJacobianTranspose( const State& state,
647  const Vector_<SpatialVec>& F_G,
648  Vector& f) const;
649 
650 
683 void calcSystemJacobian(const State& state,
684  Matrix_<SpatialVec>& J_G) const; // nb X nu
685 
690 void calcSystemJacobian(const State& state,
691  Matrix& J_G) const; // 6 nb X nu
692 
693 
739 void multiplyByStationJacobian(const State& state,
740  const Array_<MobilizedBodyIndex>& onBodyB,
741  const Array_<Vec3>& stationPInB,
742  const Vector& u,
743  Vector_<Vec3>& JSu) const;
744 
748  MobilizedBodyIndex onBodyB,
749  const Vec3& stationPInB,
750  const Vector& u) const
751 {
752  ArrayViewConst_<MobilizedBodyIndex> bodies(&onBodyB, &onBodyB+1);
753  ArrayViewConst_<Vec3> stations(&stationPInB, &stationPInB+1);
754  Vector_<Vec3> JSu(1);
755  multiplyByStationJacobian(state, bodies, stations, u, JSu);
756  return JSu[0];
757 }
758 
759 
772 void multiplyByStationJacobianTranspose
773  (const State& state,
774  const Array_<MobilizedBodyIndex>& onBodyB,
775  const Array_<Vec3>& stationPInB,
776  const Vector_<Vec3>& f_GP,
777  Vector& f) const;
778 
780 void multiplyByStationJacobianTranspose
781  (const State& state,
782  MobilizedBodyIndex onBodyB,
783  const Vec3& stationPInB,
784  const Vec3& f_GP,
785  Vector& f) const
786 {
787  ArrayViewConst_<MobilizedBodyIndex> bodies(&onBodyB, &onBodyB+1);
788  ArrayViewConst_<Vec3> stations(&stationPInB, &stationPInB+1);
789  Vector_<Vec3> forces(1, f_GP);
790  multiplyByStationJacobianTranspose(state, bodies, stations, forces, f);
791 }
792 
833 void calcStationJacobian(const State& state,
834  const Array_<MobilizedBodyIndex>& onBodyB,
835  const Array_<Vec3>& stationPInB,
836  Matrix_<Vec3>& JS) const;
837 
839 void calcStationJacobian(const State& state,
840  MobilizedBodyIndex onBodyB,
841  const Vec3& stationPInB,
842  RowVector_<Vec3>& JS) const
843 {
844  ArrayViewConst_<MobilizedBodyIndex> bodies(&onBodyB, &onBodyB+1);
845  ArrayViewConst_<Vec3> stations(&stationPInB, &stationPInB+1);
846  calcStationJacobian(state, bodies, stations, JS);
847 }
848 
852 void calcStationJacobian(const State& state,
853  const Array_<MobilizedBodyIndex>& onBodyB,
854  const Array_<Vec3>& stationPInB,
855  Matrix& JS) const;
856 
858 void calcStationJacobian(const State& state,
859  MobilizedBodyIndex onBodyB,
860  const Vec3& stationPInB,
861  Matrix& JS) const
862 {
863  ArrayViewConst_<MobilizedBodyIndex> bodies(&onBodyB, &onBodyB+1);
864  ArrayViewConst_<Vec3> stations(&stationPInB, &stationPInB+1);
865  calcStationJacobian(state, bodies, stations, JS);
866 }
867 
868 
905 void calcBiasForStationJacobian(const State& state,
906  const Array_<MobilizedBodyIndex>& onBodyB,
907  const Array_<Vec3>& stationPInB,
908  Vector_<Vec3>& JSDotu) const;
909 
913 void calcBiasForStationJacobian(const State& state,
914  const Array_<MobilizedBodyIndex>& onBodyB,
915  const Array_<Vec3>& stationPInB,
916  Vector& JSDotu) const;
917 
921  MobilizedBodyIndex onBodyB,
922  const Vec3& stationPInB) const
923 {
924  ArrayViewConst_<MobilizedBodyIndex> bodies(&onBodyB, &onBodyB+1);
925  ArrayViewConst_<Vec3> stations(&stationPInB, &stationPInB+1);
926  Vector_<Vec3> JSDotu(1);
927  calcBiasForStationJacobian(state, bodies, stations, JSDotu);
928  return JSDotu[0];
929 }
930 
931 
988 void multiplyByFrameJacobian
989  (const State& state,
990  const Array_<MobilizedBodyIndex>& onBodyB,
991  const Array_<Vec3>& originAoInB,
992  const Vector& u,
993  Vector_<SpatialVec>& JFu) const;
994 
999  MobilizedBodyIndex onBodyB,
1000  const Vec3& originAoInB,
1001  const Vector& u) const
1002 {
1003  ArrayViewConst_<MobilizedBodyIndex> bodies(&onBodyB, &onBodyB+1);
1004  ArrayViewConst_<Vec3> stations(&originAoInB, &originAoInB+1);
1005  Vector_<SpatialVec> JFu(1);
1006  multiplyByFrameJacobian(state, bodies, stations, u, JFu);
1007  return JFu[0];
1008 }
1009 
1010 
1053 void multiplyByFrameJacobianTranspose
1054  (const State& state,
1055  const Array_<MobilizedBodyIndex>& onBodyB,
1056  const Array_<Vec3>& originAoInB,
1057  const Vector_<SpatialVec>& F_GAo,
1058  Vector& f) const;
1059 
1063  MobilizedBodyIndex onBodyB,
1064  const Vec3& originAoInB,
1065  const SpatialVec& F_GAo,
1066  Vector& f) const
1067 {
1068  ArrayViewConst_<MobilizedBodyIndex> bodies(&onBodyB, &onBodyB+1);
1069  ArrayViewConst_<Vec3> stations(&originAoInB, &originAoInB+1);
1070  const Vector_<SpatialVec> forces(1, F_GAo);
1071  multiplyByFrameJacobianTranspose(state, bodies, stations, forces, f);
1072 }
1073 
1074 
1075 
1120 void calcFrameJacobian(const State& state,
1121  const Array_<MobilizedBodyIndex>& onBodyB,
1122  const Array_<Vec3>& originAoInB,
1123  Matrix_<SpatialVec>& JF) const;
1124 
1127 void calcFrameJacobian(const State& state,
1128  MobilizedBodyIndex onBodyB,
1129  const Vec3& originAoInB,
1130  RowVector_<SpatialVec>& JF) const
1131 {
1132  ArrayViewConst_<MobilizedBodyIndex> bodies(&onBodyB, &onBodyB+1);
1133  ArrayViewConst_<Vec3> stations(&originAoInB, &originAoInB+1);
1134  calcFrameJacobian(state, bodies, stations, JF);
1135 }
1136 
1140 void calcFrameJacobian(const State& state,
1141  const Array_<MobilizedBodyIndex>& onBodyB,
1142  const Array_<Vec3>& originAoInB,
1143  Matrix& JF) const;
1144 
1147 void calcFrameJacobian(const State& state,
1148  MobilizedBodyIndex onBodyB,
1149  const Vec3& originAoInB,
1150  Matrix& JF) const
1151 {
1152  ArrayViewConst_<MobilizedBodyIndex> bodies(&onBodyB, &onBodyB+1);
1153  ArrayViewConst_<Vec3> stations(&originAoInB, &originAoInB+1);
1154  calcFrameJacobian(state, bodies, stations, JF);
1155 }
1156 
1199 void calcBiasForFrameJacobian
1200  (const State& state,
1201  const Array_<MobilizedBodyIndex>& onBodyB,
1202  const Array_<Vec3>& originAoInB,
1203  Vector_<SpatialVec>& JFDotu) const;
1204 
1208 void calcBiasForFrameJacobian(const State& state,
1209  const Array_<MobilizedBodyIndex>& onBodyB,
1210  const Array_<Vec3>& originAoInB,
1211  Vector& JFDotu) const;
1212 
1217  MobilizedBodyIndex onBodyB,
1218  const Vec3& originAoInB) const
1219 {
1220  ArrayViewConst_<MobilizedBodyIndex> bodies(&onBodyB, &onBodyB+1);
1221  ArrayViewConst_<Vec3> stations(&originAoInB, &originAoInB+1);
1222  Vector_<SpatialVec> JFDotu(1);
1223  calcBiasForFrameJacobian(state, bodies, stations, JFDotu);
1224  return JFDotu[0];
1225 }
1226 
1229 //==============================================================================
1262 void multiplyByM(const State& state, const Vector& a, Vector& Ma) const;
1263 
1343 void multiplyByMInv(const State& state,
1344  const Vector& v,
1345  Vector& MinvV) const;
1346 
1360 void calcM(const State&, Matrix& M) const;
1361 
1379 void calcMInv(const State&, Matrix& MInv) const;
1380 
1428 void calcProjectedMInv(const State& s,
1429  Matrix& GMInvGt) const;
1430 
1475 void solveForConstraintImpulses(const State& state,
1476  const Vector& deltaV,
1477  Vector& impulse) const;
1478 
1479 
1503 void multiplyByG(const State& state,
1504  const Vector& ulike,
1505  Vector& Gulike) const {
1506  Vector bias;
1507  calcBiasForMultiplyByG(state, bias);
1508  multiplyByG(state, ulike, bias, Gulike);
1509 }
1510 
1511 
1515 void multiplyByG(const State& state,
1516  const Vector& ulike,
1517  const Vector& bias,
1518  Vector& Gulike) const;
1519 
1545 void calcBiasForMultiplyByG(const State& state,
1546  Vector& bias) const;
1547 
1561 void calcG(const State& state, Matrix& G) const;
1562 
1563 
1598 void calcBiasForAccelerationConstraints(const State& state,
1599  Vector& bias) const;
1600 
1601 
1635 void multiplyByGTranspose(const State& state,
1636  const Vector& lambda,
1637  Vector& f) const;
1638 
1650 void calcGTranspose(const State&, Matrix& Gt) const;
1651 
1652 
1703 void multiplyByPq(const State& state,
1704  const Vector& qlike,
1705  Vector& PqXqlike) const {
1706  Vector biasp;
1707  calcBiasForMultiplyByPq(state, biasp);
1708  multiplyByPq(state, qlike, biasp, PqXqlike);
1709 }
1710 
1711 
1715 void multiplyByPq(const State& state,
1716  const Vector& qlike,
1717  const Vector& biasp,
1718  Vector& PqXqlike) const;
1719 
1736 void calcBiasForMultiplyByPq(const State& state,
1737  Vector& biasp) const;
1738 
1766 void calcPq(const State& state, Matrix& Pq) const;
1767 
1768 
1801 void multiplyByPqTranspose(const State& state,
1802  const Vector& lambdap,
1803  Vector& f) const;
1804 
1832 void calcPqTranspose(const State& state, Matrix& Pqt) const;
1833 
1850 void calcP(const State& state, Matrix& P) const;
1851 
1855 void calcPt(const State& state, Matrix& Pt) const;
1856 
1857 
1866 void multiplyByN(const State& s, bool transpose,
1867  const Vector& in, Vector& out) const;
1868 
1877 void multiplyByNInv(const State& s, bool transpose,
1878  const Vector& in, Vector& out) const;
1879 
1889 void multiplyByNDot(const State& s, bool transpose,
1890  const Vector& in, Vector& out) const;
1891 
1895 //==============================================================================
1960 void calcAcceleration
1961  (const State& state,
1962  const Vector& appliedMobilityForces,
1963  const Vector_<SpatialVec>& appliedBodyForces,
1964  Vector& udot, // output only; no prescribed motions
1965  Vector_<SpatialVec>& A_GB) const;
1966 
1990 void calcAccelerationIgnoringConstraints
1991  (const State& state,
1992  const Vector& appliedMobilityForces,
1993  const Vector_<SpatialVec>& appliedBodyForces,
1994  Vector& udot,
1995  Vector_<SpatialVec>& A_GB) const;
1996 
1997 
1998 
2053 void calcResidualForceIgnoringConstraints
2054  (const State& state,
2055  const Vector& appliedMobilityForces,
2056  const Vector_<SpatialVec>& appliedBodyForces,
2057  const Vector& knownUdot,
2058  Vector& residualMobilityForces) const;
2059 
2060 
2123 void calcResidualForce
2124  (const State& state,
2125  const Vector& appliedMobilityForces,
2126  const Vector_<SpatialVec>& appliedBodyForces,
2127  const Vector& knownUdot,
2128  const Vector& knownLambda,
2129  Vector& residualMobilityForces) const;
2130 
2131 
2142 void calcCompositeBodyInertias(const State& state,
2144 
2145 
2146 
2184 void calcBodyAccelerationFromUDot(const State& state,
2185  const Vector& knownUDot,
2186  Vector_<SpatialVec>& A_GB) const;
2187 
2188 
2211 void calcConstraintForcesFromMultipliers
2212  (const State& state,
2213  const Vector& multipliers,
2214  Vector_<SpatialVec>& bodyForcesInG,
2215  Vector& mobilityForces) const;
2216 
2299 void calcMobilizerReactionForces
2300  (const State& state,
2301  Vector_<SpatialVec>& forcesAtMInG) const;
2302 
2312 const Vector& getMotionMultipliers(const State& state) const;
2313 
2327 Vector calcMotionErrors(const State& state, const Stage& stage) const;
2328 
2337 void findMotionForces
2338  (const State& state,
2339  Vector& mobilityForces) const;
2340 
2350 const Vector& getConstraintMultipliers(const State& state) const;
2351 
2359 void findConstraintForces
2360  (const State& state,
2361  Vector_<SpatialVec>& bodyForcesInG,
2362  Vector& mobilityForces) const;
2363 
2382 Real calcMotionPower(const State& state) const;
2383 
2413 Real calcConstraintPower(const State& state) const;
2414 
2420 void calcTreeEquivalentMobilityForces(const State&,
2421  const Vector_<SpatialVec>& bodyForces,
2422  Vector& mobilityForces) const;
2423 
2424 
2429 void calcQDot(const State& s,
2430  const Vector& u,
2431  Vector& qdot) const;
2432 
2438 void calcQDotDot(const State& s,
2439  const Vector& udot,
2440  Vector& qdotdot) const;
2441 
2452 void addInStationForce(const State& state,
2453  MobilizedBodyIndex bodyB,
2454  const Vec3& stationOnB,
2455  const Vec3& forceInG,
2456  Vector_<SpatialVec>& bodyForcesInG) const;
2457 
2464 void addInBodyTorque(const State& state,
2465  MobilizedBodyIndex mobodIx,
2466  const Vec3& torqueInG,
2467  Vector_<SpatialVec>& bodyForcesInG) const;
2468 
2477 void addInMobilityForce(const State& state,
2478  MobilizedBodyIndex mobodIx,
2479  MobilizerUIndex which,
2480  Real f,
2481  Vector& mobilityForces) const;
2486 //==============================================================================
2511 void realizePositionKinematics(const State& state) const;
2512 
2525 void realizeVelocityKinematics(const State&) const;
2526 
2535 void realizeCompositeBodyInertias(const State&) const;
2536 
2550 void realizeArticulatedBodyInertias(const State&) const;
2551 
2580 void realizeArticulatedBodyVelocity(const State&) const;
2581 
2582 
2583  // INSTANCE STAGE responses and operators //
2584 
2589 const Array_<QIndex>& getFreeQIndex(const State& state) const;
2590 
2595 const Array_<UIndex>& getFreeUIndex(const State& state) const;
2596 
2602 const Array_<UIndex>& getFreeUDotIndex(const State& state) const;
2603 
2609 const Array_<UIndex>& getKnownUDotIndex(const State& state) const;
2610 
2617 void packFreeQ
2618  (const State& s, const Vector& allQ, Vector& packedFreeQ) const;
2619 
2625 void unpackFreeQ
2626  (const State& s, const Vector& packedFreeQ, Vector& unpackedFreeQ) const;
2627 
2634 void packFreeU
2635  (const State& s, const Vector& allU, Vector& packedFreeU) const;
2636 
2642 void unpackFreeU
2643  (const State& s, const Vector& packedFreeU, Vector& unpackedFreeU) const;
2644 
2645 
2646  // POSITION STAGE responses //
2647 
2662 const SpatialInertia&
2663 getCompositeBodyInertia(const State& state, MobilizedBodyIndex mbx) const;
2664 
2686 const ArticulatedInertia&
2687 getArticulatedBodyInertia(const State& state, MobilizedBodyIndex mbx) const;
2688 
2689 
2690  // VELOCITY STAGE responses //
2691 
2696 const SpatialVec&
2697 getGyroscopicForce(const State& state, MobilizedBodyIndex mbx) const;
2698 
2706 const SpatialVec&
2707 getMobilizerCoriolisAcceleration(const State& state,
2708  MobilizedBodyIndex mbx) const;
2709 
2718 const SpatialVec&
2719 getTotalCoriolisAcceleration(const State& state, MobilizedBodyIndex mbx) const;
2720 
2721 
2730 const SpatialVec&
2731 getTotalCentrifugalForces(const State& state, MobilizedBodyIndex mbx) const;
2736 //==============================================================================
2767 void calcMobilizerReactionForcesUsingFreebodyMethod
2768  (const State& state,
2769  Vector_<SpatialVec>& forcesAtMInG) const;
2770 
2778 void invalidatePositionKinematics(const State& state) const;
2779 
2784 bool isPositionKinematicsRealized(const State&) const;
2785 
2794 void invalidateVelocityKinematics(const State& state) const;
2795 
2801 bool isVelocityKinematicsRealized(const State&) const;
2802 
2806 void invalidateCompositeBodyInertias(const State& state) const;
2807 
2812 bool isCompositeBodyInertiasRealized(const State&) const;
2813 
2821 void invalidateArticulatedBodyInertias(const State& state) const;
2822 
2827 bool isArticulatedBodyInertiasRealized(const State&) const;
2828 
2836 void invalidateArticulatedBodyVelocity(const State& state) const;
2837 
2843 bool isArticulatedBodyVelocityRealized(const State&) const;
2847 //==============================================================================
2858 int getNumParticles() const;
2860 
2861 // The generalized coordinates for a particle are always the three measure numbers
2862 // (x,y,z) of the particle's Ground-relative Cartesian location vector. The generalized
2863 // speeds are always the three corresponding measure numbers of the particle's
2864 // Ground-relative Cartesian velocity. The generalized applied forces are
2865 // always the three measure numbers of a Ground-relative force vector.
2866 const Vector_<Vec3>& getAllParticleLocations (const State&) const;
2867 const Vector_<Vec3>& getAllParticleVelocities (const State&) const;
2868 
2869 const Vec3& getParticleLocation(const State& s, ParticleIndex p) const {
2870  return getAllParticleLocations(s)[p];
2871 }
2872 const Vec3& getParticleVelocity(const State& s, ParticleIndex p) const {
2873  return getAllParticleVelocities(s)[p];
2874 }
2875 
2876 Vector& updAllParticleMasses(State& s) const;
2877 
2878 void setAllParticleMasses(State& s, const Vector& masses) const {
2879  updAllParticleMasses(s) = masses;
2880 }
2881 
2882 // Note that particle generalized coordinates, speeds, and applied forces
2883 // are defined to be the particle Cartesian locations, velocities, and
2884 // applied force vectors, so can be set directly at Stage::Model or higher.
2885 
2886 // These are the only routines that must be provided by the concrete MatterSubsystem.
2887 Vector_<Vec3>& updAllParticleLocations(State&) const;
2888 Vector_<Vec3>& updAllParticleVelocities(State&) const;
2889 
2890 // The following inline routines are provided by the generic MatterSubsystem
2891 // class for convenience.
2892 
2893 Vec3& updParticleLocation(State& s, ParticleIndex p) const {
2894  return updAllParticleLocations(s)[p];
2895 }
2896 Vec3& updParticleVelocity(State& s, ParticleIndex p) const {
2897  return updAllParticleVelocities(s)[p];
2898 }
2899 
2900 void setParticleLocation(State& s, ParticleIndex p, const Vec3& r) const {
2901  updAllParticleLocations(s)[p] = r;
2902 }
2903 void setParticleVelocity(State& s, ParticleIndex p, const Vec3& v) const {
2904  updAllParticleVelocities(s)[p] = v;
2905 }
2906 
2907 void setAllParticleLocations(State& s, const Vector_<Vec3>& r) const {
2908  updAllParticleLocations(s) = r;
2909 }
2911  updAllParticleVelocities(s) = v;
2912 }
2913 
2914 const Vector& getAllParticleMasses(const State&) const;
2915 
2916 const Vector_<Vec3>& getAllParticleAccelerations(const State&) const;
2917 
2918 const Vec3& getParticleAcceleration(const State& s, ParticleIndex p) const {
2919  return getAllParticleAccelerations(s)[p];
2920 }
2923 //==============================================================================
2932 // Internally this is now called getArticulatedBodyCentrifugalForces().
2935 DEPRECATED_14("do you really need this? see getTotalCentrifugalForces() instead")
2936 const SpatialVec&
2937 getMobilizerCentrifugalForces(const State& state, MobilizedBodyIndex mbx) const;
2941 //==============================================================================
2942 // Bookkeeping methods and internal types -- hide from Doxygen
2944 public:
2945 class Subtree; // used for working with a connected subgraph of the MobilizedBody tree
2946 class SubtreeResults;
2947 
2948 
2950 const SimbodyMatterSubsystemRep& getRep() const;
2951 SimbodyMatterSubsystemRep& updRep();
2954 private:
2955 };
2956 
2960 SimTK_SIMBODY_EXPORT std::ostream&
2961 operator<<(std::ostream&, const SimbodyMatterSubsystem&);
2962 
2963 
2964 } // namespace SimTK
2965 
2966 #endif // SimTK_SIMBODY_MATTER_SUBSYSTEM_H_
PhiMatrixTranspose transpose(const PhiMatrix &phi)
Definition: SpatialAlgebra.h:720
A Subsystem is expected to be part of a larger System and to have interdependencies with other subsys...
Definition: Subsystem.h:55
Vec3 & updParticleLocation(State &s, ParticleIndex p) const
TODO: total number of particles.
Definition: SimbodyMatterSubsystem.h:2893
This is for arrays indexed by mobilized body number within a subsystem (typically the SimbodyMatterSu...
void setAllParticleMasses(State &s, const Vector &masses) const
TODO: total number of particles.
Definition: SimbodyMatterSubsystem.h:2878
This is a special type of "mobilized" body generated automatically by Simbody as a placeholder for Gr...
Definition: MobilizedBody_Ground.h:45
void calcStationJacobian(const State &state, MobilizedBodyIndex onBodyB, const Vec3 &stationPInB, Matrix &JS) const
Alternate signature for when you just have a single station task.
Definition: SimbodyMatterSubsystem.h:858
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
This class is basically a glorified enumerated type, type-safe and range checked but permitting conve...
Definition: Stage.h:66
Vec3 & updParticleVelocity(State &s, ParticleIndex p) const
TODO: total number of particles.
Definition: SimbodyMatterSubsystem.h:2896
Vec3 calcBiasForStationJacobian(const State &state, MobilizedBodyIndex onBodyB, const Vec3 &stationPInB) const
Alternate signature for when you just have a single station task.
Definition: SimbodyMatterSubsystem.h:920
Every Simbody header and source file should include this header before any other Simbody header...
void setParticleVelocity(State &s, ParticleIndex p, const Vec3 &v) const
TODO: total number of particles.
Definition: SimbodyMatterSubsystem.h:2903
void multiplyByFrameJacobianTranspose(const State &state, MobilizedBodyIndex onBodyB, const Vec3 &originAoInB, const SpatialVec &F_GAo, Vector &f) const
Simplified signature for when you just have a single frame task.
Definition: SimbodyMatterSubsystem.h:1062
This class contains the mass, center of mass, and unit inertia matrix of a rigid body B...
Definition: MassProperties.h:85
Vec3 multiplyByStationJacobian(const State &state, MobilizedBodyIndex onBodyB, const Vec3 &stationPInB, const Vector &u) const
Alternate signature for when you just have a single station task.
Definition: SimbodyMatterSubsystem.h:747
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
This is for arrays indexed by constraint number within a subsystem (typically the SimbodyMatterSubsys...
#define DEPRECATED_14(MSG)
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:289
(Experimental – API will change – use at your own risk) A unilateral contact constraint uses a sing...
Definition: ConditionalConstraint.h:120
void setAllParticleVelocities(State &s, const Vector_< Vec3 > &v) const
TODO: total number of particles.
Definition: SimbodyMatterSubsystem.h:2910
TODO: not implemented yet.
Definition: ConditionalConstraint.h:289
Includes internal headers providing declarations for the basic SimTK Core classes, including Simmatrix.
The Array_<T> container class is a plug-compatible replacement for the C++ standard template library ...
Definition: Array.h:53
SpatialVec multiplyByFrameJacobian(const State &state, MobilizedBodyIndex onBodyB, const Vec3 &originAoInB, const Vector &u) const
Simplified signature for when you just have a single frame task; see the main signature for documenta...
Definition: SimbodyMatterSubsystem.h:998
void multiplyByPq(const State &state, const Vector &qlike, Vector &PqXqlike) const
Calculate in O(n) time the product Pq*qlike where Pq is the mp X nq position (holonomic) constraint J...
Definition: SimbodyMatterSubsystem.h:1703
The job of the MultibodySystem class is to coordinate the activities of various subsystems which can ...
Definition: MultibodySystem.h:48
SimbodyMatterSubsystem & operator=(const SimbodyMatterSubsystem &ss)
Copy assignment is not very useful.
Definition: SimbodyMatterSubsystem.h:283
const Vec3 & getParticleVelocity(const State &s, ParticleIndex p) const
TODO: total number of particles.
Definition: SimbodyMatterSubsystem.h:2872
This is the matrix class intended to appear in user code for large, variable size matrices...
Definition: BigMatrix.h:168
std::ostream & operator<<(std::ostream &o, const ContactForce &f)
Definition: CompliantContactSubsystem.h:387
void calcStationJacobian(const State &state, MobilizedBodyIndex onBodyB, const Vec3 &stationPInB, RowVector_< Vec3 > &JS) const
Alternate signature for when you just have a single station task.
Definition: SimbodyMatterSubsystem.h:839
SpatialVec calcBiasForFrameJacobian(const State &state, MobilizedBodyIndex onBodyB, const Vec3 &originAoInB) const
Simplified signature for when you just have a single frame task.
Definition: SimbodyMatterSubsystem.h:1216
The physical meaning of an inertia is the distribution of a rigid body&#39;s mass about a particular poin...
Definition: MassProperties.h:82
MobilizedBody::Ground & Ground()
This is a synonym for updGround() that makes for nicer-looking examples.
Definition: SimbodyMatterSubsystem.h:188
This defines the MobilizedBody class, which associates a new body (the "child", "outboard", or "successor" body) with a mobilizer and a reference frame on an existing body (the "parent", "inboard", or "predecessor" body) that is already part of a SimbodyMatterSubsystem.
This Array_ helper class is the base class for ArrayView_ which is the base class for Array_; here we...
Definition: Array.h:51
void setAllParticleLocations(State &s, const Vector_< Vec3 > &r) const
TODO: total number of particles.
Definition: SimbodyMatterSubsystem.h:2907
#define SimTK_SIMBODY_EXPORT
Definition: Simbody/include/simbody/internal/common.h:68
SimbodyMatterSubsystem(const SimbodyMatterSubsystem &ss)
Copy constructor is not very useful.
Definition: SimbodyMatterSubsystem.h:281
A MobilizedBody is Simbody&#39;s fundamental body-and-joint object used to parameterize a system&#39;s motion...
Definition: MobilizedBody.h:168
This is the base class for all Constraint classes, which is just a handle for the underlying hidden i...
Definition: Constraint.h:66
~SimbodyMatterSubsystem()
The destructor destroys the subsystem implementation object only if this handle is the last reference...
Definition: SimbodyMatterSubsystem.h:161
Represents a variable size row vector; much less common than the column vector type Vector_...
Definition: BigMatrix.h:174
A spatial inertia contains the mass, center of mass point, and inertia matrix for a rigid body...
Definition: MassProperties.h:83
const Vec3 & getParticleAcceleration(const State &s, ParticleIndex p) const
TODO: total number of particles.
Definition: SimbodyMatterSubsystem.h:2918
An articulated body inertia (ABI) matrix P(q) contains the spatial inertia properties that a body app...
Definition: MassProperties.h:84
void calcFrameJacobian(const State &state, MobilizedBodyIndex onBodyB, const Vec3 &originAoInB, Matrix &JF) const
Simplified signature for when you just have a single frame task.
Definition: SimbodyMatterSubsystem.h:1147
This subsystem contains the bodies ("matter") in the multibody system, the mobilizers (joints) that d...
Definition: SimbodyMatterSubsystem.h:133
void setParticleLocation(State &s, ParticleIndex p, const Vec3 &r) const
TODO: total number of particles.
Definition: SimbodyMatterSubsystem.h:2900
void calcFrameJacobian(const State &state, MobilizedBodyIndex onBodyB, const Vec3 &originAoInB, RowVector_< SpatialVec > &JF) const
Simplified signature for when you just have a single frame task.
Definition: SimbodyMatterSubsystem.h:1127
const Vec3 & getParticleLocation(const State &s, ParticleIndex p) const
TODO: total number of particles.
Definition: SimbodyMatterSubsystem.h:2869
#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:593
void multiplyByG(const State &state, const Vector &ulike, Vector &Gulike) const
Returns Gulike = G*ulike, the product of the mXn acceleration constraint Jacobian G and a "u-like" (m...
Definition: SimbodyMatterSubsystem.h:1503
The Mobilizer associated with each MobilizedBody, once modeled, has a specific number of generalized ...
Subsystem & operator=(const Subsystem &)
Copy assignment deletes the Subsystem::Guts object if there is one and then behaves like the copy con...