Rigid Body Dynamics Library
Millard2016TorqueMuscle.h
Go to the documentation of this file.
1#ifndef MILLARD2016TORQUEMUSCLE_H_
2#define MILLARD2016TORQUEMUSCLE_H_
3
4/*
5 * RBDL - Rigid Body Dynamics Library: Addon : muscle
6 * Copyright (c) 2016 Matthew Millard <millard.matthew@gmail.com>
7 *
8 * Licensed under the zlib license. See LICENSE for more details.
9 */
10
11#include <vector>
12#include <rbdl/rbdl_math.h>
13#include "../geometry/SmoothSegmentedFunction.h"
14
15
16
17namespace RigidBodyDynamics {
18 namespace Addons {
19 namespace Muscle{
20 #ifdef RBDL_BUILD_ADDON_MUSCLE_FITTING
21 class TorqueMuscleFittingToolkit;
22 class FitTorqueMuscleParameters;
23 #endif
24
36 const static struct DataSet{
37 enum item{
40 Last
41 };
42 const static char* names[];
45
46
51 const static struct GenderSet{
52 enum item {
53 Male = 0,
55 Last
56 };
57 const static char* names[];
60
65 const static struct AgeGroupSet{
66 enum item {
70 Last
71 };
72 const static char* names[];
75
80 const static struct JointTorqueSet{
81 enum item{
106 Last = 24
107 };
108 const static char* names[];
111
112
120 const static struct Anderson2007{
121 enum Gender {
125 };
126 enum AgeGroup {
131 };
140 };
141 const static char* GenderNames[];
142 const static char* AgeGroupNames[];
143 const static char* JointTorqueNames[];
146
156 const static struct Gymnast{
157 enum Gender {
160 };
161 enum AgeGroup {
164 };
165
176 };
177
208 };
209 const static char* GenderNames[];
210 const static char* AgeGroupNames[];
211 const static char* JointTorqueNames[];
214
215
216
248 double massInKg;
249 };
250
251
252
256
259
260
263
267
271
275
278
281
286
287
289 fiberAngle(nan("1")),
290 fiberAngularVelocity(nan("1")),
291 activation(nan("1")),
296 fiberTorque(nan("1")),
297 jointTorque(nan("1")){}
298
299 };
300
302
305
310
313
314 //The angle that the tendon spans (radians)
315 //double tendonAngle;
316
321
322 /*The rate-of-angular-lengthening of the tendon.
323 A positive sign is for a concentric contraction,
324 that is where the tendon is shortening. (radians/sec)*/
325 //double tendonAngularVelocity;
326
340 /*The normalized value of the tendon-torque-angle curve.
341 Here a value of 1 means 1 maximum-isometric-torque. (Nm/Nm)*/
342 //double tendonTorqueAngleMultiplier;
343
346
350
354
359
362
365
368
369 /*The torque transmitted through the tendon across the joint (Nm)*/
370 //double tendonTorque;
371
376
379
380 /*The stiffness of the tendon (Nm/rad)*/
381 //double tendonStiffness;
382
387
392
397
400
405
408
411
415
422
425
426
432
434 jointAngle(nan("1")),
435 jointAngularVelocity(nan("1")),
436 fiberAngle(nan("1")),
437 fiberAngularVelocity(nan("1")),
445 activation(nan("1")),
446 fiberActiveTorque(nan("1")),
447 fiberPassiveTorque(nan("1")),
449 fiberDampingTorque(nan("1")),
450 fiberNormDampingTorque(nan("1")),
451 fiberTorque(nan("1")),
452 jointTorque(nan("1")),
453 fiberStiffness(nan("1")),
454 jointStiffness(nan("1")),
455 fiberActivePower(nan("1")),
456 fiberPassivePower(nan("1")),
457 fiberPower(nan("1")),
458 jointPower(nan("1")),
459 DjointTorque_Dactivation(nan("1")),
460 DjointTorque_DjointAngle(nan("1")),
469 {}
470
471 };
472
473
475
479
481
487
490
491 //double objectiveValue;
492 //double constraintError;
494
498
499
501 indexAtMaximumActivation(std::numeric_limits<unsigned int>::infinity()),
502 indexAtMinimumActivation(std::numeric_limits<unsigned int>::infinity()),
503 indexAtMaxPassiveTorqueAngleMultiplier(std::numeric_limits<unsigned int>::infinity()),
511 maximumAngularVelocity(nan("1")),
512 fittingConverged(false),
516 };
517
522
524
528 };
529
923#ifdef RBDL_BUILD_ADDON_MUSCLE_FITTING
926#endif
927
928 public:
935
936
1014 DataSet::item dataSet,
1015 const SubjectInformation &subjectInfo,
1016 int jointTorque,
1017 double jointAngleOffsetRelativeToDoxygenFigures,
1018 double signOfJointAngleRelativeToDoxygenFigures,
1019 double signOfJointTorqueToDoxygenFigures,
1020 const std::string& name
1021 );
1022
1023
1047 double jointAngle,
1048 double jointAngularVelocity,
1049 double activation) const;
1050
1051
1089 void calcActivation(double jointAngle,
1090 double jointAngularVelocity,
1091 double jointTorque,
1093 &updTorqueMuscleSummaryStruct) const;
1094
1095
1128 double jointAngle,
1129 double jointAngularVelocity,
1130 double activation,
1131 double jointTorque) const;
1132
1153 double jointAngle,
1154 double jointAngularVelocity,
1155 double activation,
1156 TorqueMuscleInfo& updTorqueMuscleInfoStruct) const;
1157
1161 double getJointTorqueSign() const;
1162
1167 double getJointAngleSign() const;
1168
1173 double getJointAngleOffset() const;
1174
1175
1181
1188
1197
1210
1218
1219
1227
1233
1241
1248
1265 void setPassiveTorqueScale(double passiveTorqueScale);
1266
1274 double passiveCurveAngleOffsetVal);
1275
1276
1278 void setTorqueVelocityMultiplierAtHalfOmegaMax(double tvAtHalfOmegaMax);
1279
1290 void fitPassiveTorqueScale(double jointAngle,
1291 double passiveFiberTorque);
1292
1302 void fitPassiveCurveAngleOffset(double jointAngle,
1303 double passiveFiberTorque);
1304
1314 double maxIsometricTorque);
1315
1322 double maxAngularVelocity);
1323
1329 const RigidBodyDynamics::Addons::Geometry::
1330 SmoothSegmentedFunction& getActiveTorqueAngleCurve() const;
1331
1337 const RigidBodyDynamics::Addons::Geometry::
1338 SmoothSegmentedFunction& getPassiveTorqueAngleCurve() const;
1339
1344 const RigidBodyDynamics::Addons::Geometry::
1345 SmoothSegmentedFunction& getTorqueAngularVelocityCurve() const;
1346
1347
1352
1357
1362
1370 double blendingVariable);
1371
1379 double blendingVariable);
1380
1388 double blendingVariable);
1389
1397
1406 void setActiveTorqueAngleCurveAngleScaling(double angleScaling);
1407
1408
1417 const TorqueMuscleParameterFittingData &fittedParameters);
1418
1419
1440 const std::string& path,
1441 const std::string& fileNameWithoutExtension,
1442 int numberOfSamplePoints);
1443
1444 std::string getName();
1445 void setName(std::string& name);
1446
1453
1454 private:
1455
1460
1461 RigidBodyDynamics::Addons::Geometry::
1462 SmoothSegmentedFunction mTaCurve;
1464 static const double mTaLambdaMax;// = 1.0 -> defined in the cc file
1465 RigidBodyDynamics::Addons::Geometry::
1466 SmoothSegmentedFunction mTpCurve;
1468 static const double mTpLambdaMax;// = 0.0 -> defined in the cc file
1469 RigidBodyDynamics::Addons::Geometry::
1470 SmoothSegmentedFunction mTvCurve;
1472
1479
1480
1484
1489
1493
1495
1504
1505 double mBetaMax; //passive damping coefficient
1506
1510
1515
1516 std::string mMuscleName;
1517
1518 double calcJointAngle(double fiberAngle) const;
1519 double calcFiberAngle(double jointAngle) const;
1521 double jointAngularVelocity) const;
1523 double fiberAngularVelocity) const;
1524
1525 //const static RigidBodyDynamics::Math::MatrixNd&
1526 //getAnderson2007ParameterMatrix();
1527 static double const Anderson2007Table3Mean[36][14];
1528 static double const Anderson2007Table3Std[36][14];
1529 static double const GymnastWholeBody[24][12];
1530
1531
1533 RigidBodyDynamics::Math::VectorNd const &jointTorque,
1534 RigidBodyDynamics::Math::VectorNd const &jointAngle,
1535 RigidBodyDynamics::Math::VectorNd const &jointAangularVelocity,
1536 double activeTorqueAngleBlendingVariable,
1537 double passiveTorqueAngleBlendingVariable,
1538 double torqueVelocityBlendingVariable,
1539 double activeTorqueAngleAngleScaling,
1540 double activeTorqueAngleAtOneNormTorque,
1541 double passiveTorqueAngleCurveOffset,
1542 double maxAngularVelocity,
1543 double maxActiveIsometricTorque,
1544 TorqueMuscleDataFeatures &tmf) const;
1545
1563 double normPassiveFiberTorque,
1564 double blendingVariable,
1565 double passiveTorqueAngleCurveOffset) const;
1566
1604 double curveArgument,
1605 double blendingVariable,
1606 double maximumBlendingValue,
1607 unsigned int derivativeOrderArgument,
1608 unsigned int derivativeOrderBlendingVariable,
1610 const &curve) const;
1611
1612
1647 double blendedCurveValue,
1648 double argGuess,
1649 double blendingVariable,
1650 double maximumBlendingValue,
1652 const &curve) const;
1653
1691 double activation,
1692 double jointAngle,
1693 double jointAngularVelocity,
1694 double activeTorqueAngleBlendingVariable,
1695 double passiveTorqueAngleBlendingVariable,
1696 double activeTorqueAngularVelocityBlendingVariable,
1697 double activeTorqueAngleAngleScaling,
1698 double activeTorqueAngleAtOneNormTorque,
1699 double passiveTorqueAngleCurveOffset,
1700 double maxAngularVelocity,
1701 double maxActiveIsometricTorque,
1702 TorqueMuscleSummary &updTms) const;
1732 double fiberAngle,
1733 double normFiberAngularVelocity,
1734 double activeTorqueAngleBlendingVariable,
1735 double passiveTorqueAngleBlendingVariable,
1736 double activeTorqueAngularVelocityBlendingVariable,
1737 double activeTorqueAngleAngleScaling,
1738 double activeTorqueAngleAtOneNormTorque,
1739 double passiveTorqueAngleCurveOffset,
1740 TorqueMuscleSummary &updTms) const;
1741
1780 double activation,
1781 double jointAngle,
1782 double jointAngularVelocity,
1783 double activeTorqueAngleBlendingVariable,
1784 double passiveTorqueAngleBlendingVariable,
1785 double activeTorqueAngularVelocityBlendingVariable,
1786 double activeTorqueAngleAngleScaling,
1787 double activeTorqueAngleAtOneNormTorque,
1788 double passiveTorqueAngleCurveOffset,
1789 double maxAngularVelocity,
1790 double maxActiveIsometricTorque,
1791 TorqueMuscleInfo &updTmi) const;
1792
1832 double jointTorque,
1833 double jointAngle,
1834 double jointAngularVelocity,
1835 double activeTorqueAngleBlendingVariable,
1836 double passiveTorqueAngleBlendingVariable,
1837 double activeTorqueAngularVelocityBlendingVariable,
1838 double activeTorqueAngleAngleScaling,
1839 double activeTorqueAngleAtOneNormTorque,
1840 double passiveTorqueAngleCurveOffset,
1841 double maxAngularVelocity,
1842 double maxActiveIsometricTorque,
1843 TorqueMuscleSummary &updTms) const;
1844
1845
1846
1847};
1848
1849
1850
1851
1852}
1853}
1854}
1855
1856
1857
1858#endif
This class implements a rigid-tendon muscle-torque-generator (MTG) for a growing list of joints and t...
void updTorqueMuscleSummary(double activation, double jointAngle, double jointAngularVelocity, double activeTorqueAngleBlendingVariable, double passiveTorqueAngleBlendingVariable, double activeTorqueAngularVelocityBlendingVariable, double activeTorqueAngleAngleScaling, double activeTorqueAngleAtOneNormTorque, double passiveTorqueAngleCurveOffset, double maxAngularVelocity, double maxActiveIsometricTorque, TorqueMuscleSummary &updTms) const
void calcActivation(double jointAngle, double jointAngularVelocity, double jointTorque, TorqueMuscleSummary &updTorqueMuscleSummaryStruct) const
void updTorqueMuscleSummaryCurveValues(double fiberAngle, double normFiberAngularVelocity, double activeTorqueAngleBlendingVariable, double passiveTorqueAngleBlendingVariable, double activeTorqueAngularVelocityBlendingVariable, double activeTorqueAngleAngleScaling, double activeTorqueAngleAtOneNormTorque, double passiveTorqueAngleCurveOffset, TorqueMuscleSummary &updTms) const
void fitPassiveCurveAngleOffset(double jointAngle, double passiveFiberTorque)
void updInvertTorqueMuscleSummary(double jointTorque, double jointAngle, double jointAngularVelocity, double activeTorqueAngleBlendingVariable, double passiveTorqueAngleBlendingVariable, double activeTorqueAngularVelocityBlendingVariable, double activeTorqueAngleAngleScaling, double activeTorqueAngleAtOneNormTorque, double passiveTorqueAngleCurveOffset, double maxAngularVelocity, double maxActiveIsometricTorque, TorqueMuscleSummary &updTms) const
RigidBodyDynamics::Addons::Geometry::SmoothSegmentedFunction mTvCurve
double calcBlendedCurveDerivative(double curveArgument, double blendingVariable, double maximumBlendingValue, unsigned int derivativeOrderArgument, unsigned int derivativeOrderBlendingVariable, RigidBodyDynamics::Addons::Geometry::SmoothSegmentedFunction const &curve) const
double calcFiberAngularVelocity(double jointAngularVelocity) const
void setMaximumConcentricJointAngularVelocity(double maxAngularVelocity)
void updTorqueMuscleInfo(double activation, double jointAngle, double jointAngularVelocity, double activeTorqueAngleBlendingVariable, double passiveTorqueAngleBlendingVariable, double activeTorqueAngularVelocityBlendingVariable, double activeTorqueAngleAngleScaling, double activeTorqueAngleAtOneNormTorque, double passiveTorqueAngleCurveOffset, double maxAngularVelocity, double maxActiveIsometricTorque, TorqueMuscleInfo &updTmi) const
RigidBodyDynamics::Addons::Geometry::SmoothSegmentedFunction mTaCurve
void calcTorqueMuscleInfo(double jointAngle, double jointAngularVelocity, double activation, TorqueMuscleInfo &updTorqueMuscleInfoStruct) const
double calcFiberAngleGivenNormalizedPassiveTorque(double normPassiveFiberTorque, double blendingVariable, double passiveTorqueAngleCurveOffset) const
void setPassiveTorqueAngleCurveBlendingVariable(double blendingVariable)
double calcJointTorque(double jointAngle, double jointAngularVelocity, double activation) const
void fitPassiveTorqueScale(double jointAngle, double passiveFiberTorque)
void printJointTorqueProfileToFile(const std::string &path, const std::string &fileNameWithoutExtension, int numberOfSamplePoints)
void setMaximumActiveIsometricTorque(double maxIsometricTorque)
void setTorqueVelocityMultiplierAtHalfOmegaMax(double tvAtHalfOmegaMax)
void setTorqueAngularVelocityCurveBlendingVariable(double blendingVariable)
const RigidBodyDynamics::Addons::Geometry::SmoothSegmentedFunction & getPassiveTorqueAngleCurve() const
void calcTorqueMuscleDataFeatures(RigidBodyDynamics::Math::VectorNd const &jointTorque, RigidBodyDynamics::Math::VectorNd const &jointAngle, RigidBodyDynamics::Math::VectorNd const &jointAangularVelocity, double activeTorqueAngleBlendingVariable, double passiveTorqueAngleBlendingVariable, double torqueVelocityBlendingVariable, double activeTorqueAngleAngleScaling, double activeTorqueAngleAtOneNormTorque, double passiveTorqueAngleCurveOffset, double maxAngularVelocity, double maxActiveIsometricTorque, TorqueMuscleDataFeatures &tmf) const
Millard2016TorqueMuscle(DataSet::item dataSet, const SubjectInformation &subjectInfo, int jointTorque, double jointAngleOffsetRelativeToDoxygenFigures, double signOfJointAngleRelativeToDoxygenFigures, double signOfJointTorqueToDoxygenFigures, const std::string &name)
const RigidBodyDynamics::Addons::Geometry::SmoothSegmentedFunction & getActiveTorqueAngleCurve() const
void setFittedParameters(const TorqueMuscleParameterFittingData &fittedParameters)
double calcInverseBlendedCurveValue(double blendedCurveValue, double argGuess, double blendingVariable, double maximumBlendingValue, RigidBodyDynamics::Addons::Geometry::SmoothSegmentedFunction const &curve) const
double calcJointAngularVelocity(double fiberAngularVelocity) const
double calcMaximumActiveIsometricTorqueScalingFactor(double jointAngle, double jointAngularVelocity, double activation, double jointTorque) const
void setActiveTorqueAngleCurveBlendingVariable(double blendingVariable)
const RigidBodyDynamics::Addons::Geometry::SmoothSegmentedFunction & getTorqueAngularVelocityCurve() const
void setPassiveCurveAngleOffset(double passiveCurveAngleOffsetVal)
RigidBodyDynamics::Addons::Geometry::SmoothSegmentedFunction mTpCurve
static const struct RigidBodyDynamics::Addons::Muscle::Anderson2007 Anderson2007
static const struct RigidBodyDynamics::Addons::Muscle::DataSet DataSet
static const struct RigidBodyDynamics::Addons::Muscle::GenderSet GenderSet
static const struct RigidBodyDynamics::Addons::Muscle::AgeGroupSet AgeGroupSet
static const struct RigidBodyDynamics::Addons::Muscle::JointTorqueSet JointTorqueSet
static const struct RigidBodyDynamics::Addons::Muscle::Gymnast Gymnast
STL namespace.
double DjointTorque_DactiveTorqueAngleBlendingVariable
First derivatives for the fitting algorithm.