Simbody
3.4 (development)
|
00001 #ifndef SimTK_SIMBODY_MOBILIZED_BODY_PIN_H_ 00002 #define SimTK_SIMBODY_MOBILIZED_BODY_PIN_H_ 00003 00004 /* -------------------------------------------------------------------------- * 00005 * Simbody(tm) * 00006 * -------------------------------------------------------------------------- * 00007 * This is part of the SimTK biosimulation toolkit originating from * 00008 * Simbios, the NIH National Center for Physics-Based Simulation of * 00009 * Biological Structures at Stanford, funded under the NIH Roadmap for * 00010 * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. * 00011 * * 00012 * Portions copyright (c) 2007-13 Stanford University and the Authors. * 00013 * Authors: Michael Sherman * 00014 * Contributors: Paul Mitiguy, Peter Eastman * 00015 * * 00016 * Licensed under the Apache License, Version 2.0 (the "License"); you may * 00017 * not use this file except in compliance with the License. You may obtain a * 00018 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. * 00019 * * 00020 * Unless required by applicable law or agreed to in writing, software * 00021 * distributed under the License is distributed on an "AS IS" BASIS, * 00022 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 00023 * See the License for the specific language governing permissions and * 00024 * limitations under the License. * 00025 * -------------------------------------------------------------------------- */ 00026 00030 #include "simbody/internal/MobilizedBody.h" 00031 00032 namespace SimTK { 00033 00046 class SimTK_SIMBODY_EXPORT MobilizedBody::Pin : public MobilizedBody { 00047 public: 00050 Pin() {} 00051 00057 Pin(MobilizedBody& parent, const Transform& X_PF, 00058 const Body& bodyInfo, const Transform& X_BM, Direction=Forward); 00059 00062 Pin(MobilizedBody& parent, const Body& bodyInfo, Direction=Forward); 00063 00064 // SPECIALIZED INTERFACE FOR PIN MOBILIZER 00065 00068 Pin& setDefaultAngle(Real angleInRad) {return setDefaultQ(angleInRad);} 00070 Real getDefaultAngle() const {return getDefaultQ();} 00071 00072 // Friendly, mobilizer-specific access to generalized coords and speeds. 00073 00076 void setAngle(State& s, Real angleInRad) {setQ(s, angleInRad);} 00079 Real getAngle(const State& s) const {return getQ(s);} 00080 00083 void setRate(State& s, Real rateInRadPerTime) {setU(s, rateInRadPerTime);} 00086 Real getRate(const State& s) const {return getU(s);} 00087 00088 // Mobility forces are "u-like", that is, one per dof. 00091 Real getAppliedPinTorque(const State& s, const Vector& mobilityForces) const { 00092 return getMyPartU(s,mobilityForces); 00093 } 00096 void applyPinTorque(const State& s, Real torque, Vector& mobilityForces) const { 00097 updMyPartU(s,mobilityForces) += torque; 00098 } 00099 00100 // STANDARDIZED MOBILIZED BODY INTERFACE 00101 00102 00103 // access to generalized coordinates q and generalized speeds u 00104 Pin& setDefaultQ(Real); 00105 Real getDefaultQ() const; 00106 00107 Real getQ(const State&) const; 00108 Real getQDot(const State&) const; 00109 Real getQDotDot(const State&) const; 00110 Real getU(const State&) const; 00111 Real getUDot(const State&) const; 00112 00113 void setQ(State&, Real) const; 00114 void setU(State&, Real) const; 00115 00116 Real getMyPartQ(const State&, const Vector& qlike) const; 00117 Real getMyPartU(const State&, const Vector& ulike) const; 00118 00119 Real& updMyPartQ(const State&, Vector& qlike) const; 00120 Real& updMyPartU(const State&, Vector& ulike) const; 00121 00122 // specialize return type for convenience 00123 Pin& addBodyDecoration(const Transform& X_BD, const DecorativeGeometry& g) 00124 { (void)MobilizedBody::addBodyDecoration(X_BD,g); return *this; } 00125 Pin& addOutboardDecoration(const Transform& X_MD, const DecorativeGeometry& g) 00126 { (void)MobilizedBody::addOutboardDecoration(X_MD,g); return *this; } 00127 Pin& addInboardDecoration (const Transform& X_FD, const DecorativeGeometry& g) 00128 { (void)MobilizedBody::addInboardDecoration(X_FD,g); return *this; } 00129 Pin& setDefaultInboardFrame(const Transform& X_PF) 00130 { (void)MobilizedBody::setDefaultInboardFrame(X_PF); return *this; } 00131 Pin& setDefaultOutboardFrame(const Transform& X_BM) 00132 { (void)MobilizedBody::setDefaultOutboardFrame(X_BM); return *this; } 00133 // Don't let doxygen see this 00135 SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(Pin, PinImpl, MobilizedBody); 00137 }; 00138 00139 } // namespace SimTK 00140 00141 #endif // SimTK_SIMBODY_MOBILIZED_BODY_PIN_H_ 00142 00143 00144