1 #ifndef __Delp1990Muscle_Deprecated_h__ 2 #define __Delp1990Muscle_Deprecated_h__ 3 /* -------------------------------------------------------------------------- * 4 * OpenSim: Delp1990Muscle_Deprecated.h * 5 * -------------------------------------------------------------------------- * 6 * The OpenSim API is a toolkit for musculoskeletal modeling and simulation. * 7 * See http://opensim.stanford.edu and the NOTICE file for more information. * 8 * OpenSim is developed at Stanford University and supported by the US * 9 * National Institutes of Health (U54 GM072970, R24 HD065690) and by DARPA * 10 * through the Warrior Web program. * 11 * * 12 * Copyright (c) 2005-2017 Stanford University and the Authors * 13 * Author(s): Peter Loan * 14 * * 15 * Licensed under the Apache License, Version 2.0 (the "License"); you may * 16 * not use this file except in compliance with the License. You may obtain a * 17 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. * 18 * * 19 * Unless required by applicable law or agreed to in writing, software * 20 * distributed under the License is distributed on an "AS IS" BASIS, * 21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 22 * See the License for the specific language governing permissions and * 23 * limitations under the License. * 24 * -------------------------------------------------------------------------- */ 25 26 27 // INCLUDE 28 #include "osimActuatorsDLL.h" 29 #include <OpenSim/Common/PropertyDbl.h> 30 #include <OpenSim/Common/PropertyObjPtr.h> 31 #include <OpenSim/Simulation/Model/ActivationFiberLengthMuscle_Deprecated.h> 32 33 #ifdef SWIG 34 #ifdef OSIMACTUATORS_API 35 #undef OSIMACTUATORS_API 36 #define OSIMACTUATORS_API 37 #endif 38 #endif 39 40 namespace OpenSim { 41 42 class Function; 43 44 //============================================================================= 45 //============================================================================= 46 /** 47 * A class implementing a SIMM muscle. This implementation is based on muscle 48 * model 2 from the Dynamics Pipeline, but is modified slightly so that when 49 * fiber_velocity = 0.0, this model calculates lengths and forces that match 50 * SIMM's isometric calculations. 51 * 52 * @author Peter Loan 53 * @version 1.0 54 */ 55 class OSIMACTUATORS_API Delp1990Muscle_Deprecated 56 : public ActivationFiberLengthMuscle_Deprecated { 57 OpenSim_DECLARE_CONCRETE_OBJECT(Delp1990Muscle_Deprecated, 58 ActivationFiberLengthMuscle_Deprecated); 59 60 //============================================================================= 61 // DATA 62 //============================================================================= 63 protected: 64 /** Scale factor for normalizing time */ 65 PropertyDbl _timeScaleProp; 66 double &_timeScale; 67 68 /** Parameter used in time constant of ramping up of muscle force */ 69 PropertyDbl _activation1Prop; 70 double &_activation1; 71 72 /** Parameter used in time constant of ramping up and ramping down of muscle force */ 73 PropertyDbl _activation2Prop; 74 double &_activation2; 75 76 /** Mass between the tendon and muscle fibers */ 77 PropertyDbl _massProp; 78 double &_mass; 79 80 /* Function representing force-length behavior of tendon */ 81 PropertyObjPtr<Function> _tendonForceLengthCurveProp; 82 Function *&_tendonForceLengthCurve; 83 84 /* Function representing active force-length behavior of muscle fibers */ 85 PropertyObjPtr<Function> _activeForceLengthCurveProp; 86 Function *&_activeForceLengthCurve; 87 88 /* Function representing passive force-length behavior of muscle fibers */ 89 PropertyObjPtr<Function> _passiveForceLengthCurveProp; 90 Function *&_passiveForceLengthCurve; 91 92 /* Function representing force-velocity behavior of muscle fibers */ 93 PropertyObjPtr<Function> _forceVelocityCurveProp; 94 Function *&_forceVelocityCurve; 95 96 private: 97 static const int STATE_FIBER_VELOCITY; 98 //============================================================================= 99 // METHODS 100 //============================================================================= 101 //-------------------------------------------------------------------------- 102 // CONSTRUCTION 103 //-------------------------------------------------------------------------- 104 public: 105 Delp1990Muscle_Deprecated(); 106 Delp1990Muscle_Deprecated(const std::string &aName,double aMaxIsometricForce,double aOptimalFiberLength,double aTendonSlackLength,double aPennationAngle); 107 Delp1990Muscle_Deprecated(const Delp1990Muscle_Deprecated &aMuscle); 108 virtual ~Delp1990Muscle_Deprecated(); 109 110 #ifndef SWIG 111 Delp1990Muscle_Deprecated& operator=(const Delp1990Muscle_Deprecated &aMuscle); 112 113 #endif 114 void copyData(const Delp1990Muscle_Deprecated &aMuscle); 115 116 //-------------------------------------------------------------------------- 117 // GET 118 //-------------------------------------------------------------------------- 119 // Properties getTimeScale()120 virtual double getTimeScale() const { return _timeScale; } getMass()121 virtual double getMass() const { return _mass; } 122 virtual bool setTimeScale(double aTimeScale); 123 virtual bool setActivation1(double aActivation1); 124 virtual bool setActivation2(double aActivation2); 125 virtual bool setMass(double aMass); 126 // Computed quantities getFiberVelocity(const SimTK::State & s)127 virtual double getFiberVelocity(const SimTK::State& s) const { return getStateVariableValue(s, "fiber_velocity"); } setFiberVelocity(SimTK::State & s,double fiberVelocity)128 virtual void setFiberVelocity(SimTK::State& s, double fiberVelocity) const { setStateVariableValue(s, "fiber_velocity", fiberVelocity); } getFiberVelocityDeriv(const SimTK::State & s)129 virtual double getFiberVelocityDeriv(const SimTK::State& s) const { return getStateVariableDeriv(s, "fiber_velocity"); } setFiberVelocityDeriv(const SimTK::State & s,double fiberVelocityDeriv)130 virtual void setFiberVelocityDeriv(const SimTK::State& s, double fiberVelocityDeriv) const { setStateVariableDeriv(s, "fiber_velocity", fiberVelocityDeriv); } 131 virtual void setActiveForce(const SimTK::State& s, double aForce) const; 132 virtual double getActiveForce(const SimTK::State& s) const; 133 134 //-------------------------------------------------------------------------- 135 // COMPUTATION 136 //-------------------------------------------------------------------------- 137 double computeActuation(const SimTK::State& s) const override; 138 double computeIsometricForce(SimTK::State& s, double activation) const override; 139 140 virtual Function* getActiveForceLengthCurve() const; 141 virtual bool setActiveForceLengthCurve(Function* aActiveForceLengthCurve); 142 virtual Function* getPassiveForceLengthCurve() const; 143 virtual bool setPassiveForceLengthCurve(Function* aPassiveForceLengthCurve); 144 virtual Function* getTendonForceLengthCurve() const; 145 virtual bool setTendonForceLengthCurve(Function* aTendonForceLengthCurve); 146 virtual Function* getForceVelocityCurve() const; 147 virtual bool setForceVelocityCurve(Function* aForceVelocityCurve); 148 149 protected: 150 // Model Component Interface 151 void extendConnectToModel(Model& aModel) override; 152 void extendAddToSystem(SimTK::MultibodySystem& system) const override; 153 void computeStateVariableDerivatives(const SimTK::State &s) const override; 154 155 private: 156 void setNull(); 157 void setupProperties(); 158 double calcTendonForce(const SimTK::State& s, double aNormTendonLength) const; 159 double calcFiberForce(double aActivation, double aNormFiberLength, double aNormFiberVelocity) const; 160 161 //============================================================================= 162 }; // END of class Delp1990Muscle_Deprecated 163 //============================================================================= 164 //============================================================================= 165 166 } // end of namespace OpenSim 167 168 #endif // __Delp1990Muscle_Deprecated_h__ 169 170 171