![]() |
API
4.5
For C++ developers
|
A utility class for fitting a set of FunctionBasedPath
s to existing geometry-path in an OpenSim model using MultivariatePolynomialFunction
s.
More...
OpenSim Properties, Sockets, Outputs, Inputs | |
Properties (single-value) | |
ModelProcessor | model |
"The model containing geometry-based path objects to which " "polynomial-based path objects will be fitted." More... | |
TableProcessor | coordinate_values |
"The reference trajectory used to sample coordinate values for " "path fitting." More... | |
std::string | output_directory |
"The directory to which the path fitting results are written." More... | |
double | moment_arm_threshold |
"The moment arm threshold value that determines whether or not a " "path depends on a model coordinate. In other words, the moment " "arm of a path with respect to a coordinate must be greater than " "this value to be included during path fitting." More... | |
int | minimum_polynomial_order |
"The minimum order of the polynomial used to fit each path. The " "order of a polynomial is the highest power of the independent " "variable(s) in the polynomial." More... | |
int | maximum_polynomial_order |
"The maximum order of the polynomial used to fit each path. The " "order of a polynomial is the highest power of the independent " "variable(s) in the polynomial." More... | |
SimTK::Vec2 | global_coordinate_sampling_bounds |
"The global bounds (in degrees) that determine the minimum and " "maximum coordinate value samples at each time point." More... | |
double | moment_arm_tolerance |
"The tolerance on the root-mean-square (RMS) error (in meters) " "between the moment arms computed from an original model path and " "a fitted polynomial-based path, which is used to determine the " "order of the polynomial used in the fitted path (default: 1e-4)." More... | |
double | path_length_tolerance |
"The tolerance on the root-mean-square (RMS) error (in meters) " "between the path lengths computed from an original model path and " "a fitted polynomial-based path, which is used to determine the " "order of the polynomial used in the fitted path (default: 1e-4)." More... | |
int | num_samples_per_frame |
"The number of samples taken per time frame in the coordinate " "values table used to fit each path (default: 25)." More... | |
int | num_parallel_threads |
"The number of threads used to parallelize the path fitting " "process (default: two fewer than the number of available " "hardware threads)." More... | |
std::string | latin_hypercube_algorithm |
"The Latin hypercube sampling algorithm used to sample coordinate " "values for path fitting (default: 'random')." More... | |
Properties (list) | |
PolynomialPathFitterBounds | coordinate_sampling_bounds |
"The bounds (in degrees) that determine the minimum and maximum " "coordinate value samples at each time point for specific " "coordinates. These bounds override the default coordinate " "sampling bounds." More... | |
Public Member Functions | |
PolynomialPathFitter () | |
~PolynomialPathFitter () noexcept override | |
PolynomialPathFitter (const PolynomialPathFitter &) | |
PolynomialPathFitter (PolynomialPathFitter &&) | |
PolynomialPathFitter & | operator= (const PolynomialPathFitter &) |
PolynomialPathFitter & | operator= (PolynomialPathFitter &&) |
void | setModel (ModelProcessor model) |
The model containing geometry-based path objects to which polynomial-based path objects will be fitted. More... | |
void | setCoordinateValues (TableProcessor coordinateValues) |
The reference trajectory used to sample coordinate values for path fitting. More... | |
void | run () |
Run the path fitting process. More... | |
void | setOutputDirectory (std::string directory) |
The directory to which the path fitting results are written. More... | |
std::string | getOutputDirectory () const |
void | setMomentArmThreshold (double threshold) |
The moment arm threshold value that determines whether or not a path depends on a model coordinate. More... | |
double | getMomentArmThreshold () const |
The moment arm threshold value that determines whether or not a path depends on a model coordinate. More... | |
void | setMinimumPolynomialOrder (int order) |
The minimum order of the polynomial used to fit each path. More... | |
int | getMinimumPolynomialOrder () const |
The minimum order of the polynomial used to fit each path. More... | |
void | setMaximumPolynomialOrder (int order) |
The maximum order of the polynomial used to fit each path. More... | |
int | getMaximumPolynomialOrder () const |
The maximum order of the polynomial used to fit each path. More... | |
void | setGlobalCoordinateSamplingBounds (SimTK::Vec2 bounds) |
The global bounds that determine the minimum and maximum coordinate value samples at each time point. More... | |
SimTK::Vec2 | getGlobalCoordinateSamplingBounds () const |
The global bounds that determine the minimum and maximum coordinate value samples at each time point. More... | |
void | appendCoordinateSamplingBounds (const std::string &coordinatePath, const SimTK::Vec2 &bounds) |
The bounds (in degrees) that determine the minimum and maximum coordinate value samples at each time point for the coordinate at coordinatePath . More... | |
void | setMomentArmTolerance (double tolerance) |
The tolerance on the root-mean-square (RMS) error (in meters) between the moment arms computed from an original model path and a fitted polynomial-based path, which is used to determine the order of the polynomial used in the fitted path. More... | |
double | getMomentArmTolerance () const |
The tolerance on the root-mean-square (RMS) error (in meters) between the moment arms computed from an original model path and a fitted polynomial-based path, which is used to determine the order of the polynomial used in the fitted path. More... | |
void | setPathLengthTolerance (double tolerance) |
The tolerance on the root-mean-square (RMS) error (in meters) between the path lengths computed from an original model path and a fitted polynomial-based path, which is used to determine the order of the polynomial used in the fitted path. More... | |
double | getPathLengthTolerance () const |
The tolerance on the root-mean-square (RMS) error (in meters) between the path lengths computed from an original model path and a fitted polynomial-based path, which is used to determine the order of the polynomial used in the fitted path. More... | |
void | setNumSamplesPerFrame (int numSamples) |
The number of samples taken per time frame in the coordinate values table used to fit each path. More... | |
int | getNumSamplesPerFrame () const |
The number of samples taken per time frame in the coordinate values table used to fit each path. More... | |
void | setNumParallelThreads (int numThreads) |
The number of threads used to parallelize the path fitting process. More... | |
int | getNumParallelThreads () const |
The number of threads used to parallelize the path fitting process. More... | |
void | setLatinHypercubeAlgorithm (std::string algorithm) |
The Latin hypercube sampling algorithm used to sample coordinate values for path fitting. More... | |
std::string | getLatinHypercubeAlgorithm () const |
The Latin hypercube sampling algorithm used to sample coordinate values for path fitting. More... | |
![]() | |
virtual | ~Object () |
Virtual destructor for cleanup. More... | |
bool | isEqualTo (const Object &aObject) const |
Equality operator wrapper for use from languages not supporting operator overloading. More... | |
Object & | operator= (const Object &aObject) |
Copy assignment copies he base class fields, including the properties. More... | |
virtual bool | operator== (const Object &aObject) const |
Determine if two objects are equal. More... | |
virtual bool | operator< (const Object &aObject) const |
Provide an ordering for objects so they can be put in sorted containers. More... | |
void | setName (const std::string &name) |
Set the name of the Object. More... | |
const std::string & | getName () const |
Get the name of this Object. More... | |
void | setDescription (const std::string &description) |
Set description, a one-liner summary. More... | |
const std::string & | getDescription () const |
Get description, a one-liner summary. More... | |
const std::string & | getAuthors () const |
Get Authors of this Object. More... | |
void | setAuthors (const std::string &authors) |
Set Authors of this object. More... | |
const std::string & | getReferences () const |
Get references or publications to cite if using this object. More... | |
void | setReferences (const std::string &references) |
Set references or publications to cite if using this object. More... | |
int | getNumProperties () const |
Determine how many properties are stored with this Object. More... | |
const AbstractProperty & | getPropertyByIndex (int propertyIndex) const |
Get a const reference to a property by its index number, returned as an AbstractProperty. More... | |
AbstractProperty & | updPropertyByIndex (int propertyIndex) |
Get a writable reference to a property by its index number, returned as an AbstractProperty. More... | |
bool | hasProperty (const std::string &name) const |
Return true if this Object has a property of any type with the given name, which must not be empty. More... | |
const AbstractProperty & | getPropertyByName (const std::string &name) const |
Get a const reference to a property by its name, returned as an AbstractProperty. More... | |
AbstractProperty & | updPropertyByName (const std::string &name) |
Get a writable reference to a property by its name, returned as an AbstractProperty. More... | |
template<class T > | |
bool | hasProperty () const |
Return true if this Object contains an unnamed, one-object property that contains objects of the given template type T. More... | |
template<class T > | |
const Property< T > & | getProperty (const PropertyIndex &index) const |
Get property of known type Property<T> as a const reference; the property must be present and have the right type. More... | |
template<class T > | |
const Property< T > & | getPropertyByName (const std::string &name) const |
Get property of known type Property<T> as a const reference; the property must be present and have the right type. More... | |
template<class T > | |
Property< T > & | updProperty (const PropertyIndex &index) |
Get property of known type Property<T> as a writable reference; the property must be present and have the right type. More... | |
template<class T > | |
Property< T > & | updPropertyByName (const std::string &name) |
Get property of known type Property<T> as a writable reference; the property must be present and have the right type. More... | |
bool | isObjectUpToDateWithProperties () const |
Returns true if no property's value has changed since the last time setObjectIsUpToDateWithProperties() was called. More... | |
void | readObjectFromXMLNodeOrFile (SimTK::Xml::Element &objectElement, int versionNumber) |
We're given an XML element from which we are to populate this Object. More... | |
virtual void | updateFromXMLNode (SimTK::Xml::Element &objectElement, int versionNumber) |
Use this method to deserialize an object from a SimTK::Xml::Element. More... | |
void | updateXMLNode (SimTK::Xml::Element &parent, const AbstractProperty *prop=nullptr) const |
Serialize this object into the XML node that represents it. More... | |
bool | getInlined () const |
Inlined means an in-memory Object that is not associated with an XMLDocument. More... | |
void | setInlined (bool aInlined, const std::string &aFileName="") |
Mark this as inlined or not and optionally provide a file name to associate with the new XMLDocument for the non-inline case. More... | |
std::string | getDocumentFileName () const |
If there is a document associated with this object then return the file name maintained by the document. More... | |
int | getDocumentFileVersion () const |
If there is a document associated with this object then return its version number. More... | |
void | setAllPropertiesUseDefault (bool aUseDefault) |
bool | print (const std::string &fileName) const |
Write this Object into an XML file of the given name; conventionally the suffix to use is ".osim". More... | |
std::string | dump () const |
dump the XML representation of this Object into an std::string and return it. More... | |
virtual bool | isA (const char *type) const |
The default implementation returns true only if the supplied string is "Object"; each Object-derived class overrides this to match its own class name. More... | |
const std::string & | toString () const |
Wrapper to be used on Java side to display objects in tree; this returns just the object's name. More... | |
PropertySet & | getPropertySet () |
OBSOLETE: Get a reference to the PropertySet maintained by the Object. More... | |
const PropertySet & | getPropertySet () const |
Public Types | |
typedef PolynomialPathFitter | Self |
This typedef might be useful within the member functions of this class. More... | |
typedef Object | Super |
Use this typedef to refer to the superclass of this class. More... | |
Static Public Member Functions | |
static void | evaluateFunctionBasedPaths (Model model, TableProcessor trajectory, const std::string &functionBasedPathsFile, double pathLengthTolerance=1e-4, double momentArmTolerance=1e-4) |
Print out a summary of the path fitting results, including information about the fitted polynomial functions and root-mean-square (RMS) errors between the original and fitted paths. More... | |
![]() | |
static void | registerType (const Object &defaultObject) |
Register an instance of a class; if the class is already registered it will be replaced. More... | |
static void | renameType (const std::string &oldTypeName, const std::string &newTypeName) |
Support versioning by associating the current Object type with an old name. More... | |
static const Object * | getDefaultInstanceOfType (const std::string &concreteClassName) |
Return a pointer to the default instance of the registered (concrete) Object whose class name is given, or NULL if the type is not registered. More... | |
template<class T > | |
static bool | isObjectTypeDerivedFrom (const std::string &concreteClassName) |
Return true if the given concrete object type represents a subclass of the template object type T, and thus could be referenced with a T*. More... | |
static Object * | newInstanceOfType (const std::string &concreteClassName) |
Create a new instance of the concrete Object type whose class name is given as concreteClassName. More... | |
static void | getRegisteredTypenames (Array< std::string > &typeNames) |
Retrieve all the typenames registered so far. More... | |
template<class T > | |
static void | getRegisteredObjectsOfGivenType (ArrayPtrs< T > &rArray) |
Return an array of pointers to the default instances of all registered (concrete) Object types that derive from a given Object-derived type that does not have to be concrete. More... | |
static bool | PrintPropertyInfo (std::ostream &os, const std::string &classNameDotPropertyName, bool printFlagInfo=true) |
Dump formatted property information to a given output stream, useful for creating a "help" facility for registered objects. More... | |
static bool | PrintPropertyInfo (std::ostream &os, const std::string &className, const std::string &propertyName, bool printFlagInfo=true) |
Same as the other signature but the class name and property name are provided as two separate strings. More... | |
static Object * | makeObjectFromFile (const std::string &fileName) |
Create an OpenSim object whose type is based on the tag at the root node of the XML file passed in. More... | |
static const std::string & | getClassName () |
Return the name of this class as a string; i.e., "Object". More... | |
static void | setSerializeAllDefaults (bool shouldSerializeDefaults) |
Static function to control whether all registered objects and their properties are written to the defaults section of output files rather than only those values for which the default was explicitly overwritten when read in from an input file or set programmatically. More... | |
static bool | getSerializeAllDefaults () |
Report the value of the "serialize all defaults" flag. More... | |
static bool | isKindOf (const char *type) |
Returns true if the passed-in string is "Object"; each Object-derived class defines a method of this name for its own class name. More... | |
static void | setDebugLevel (int newLevel) |
Set the amount of logging output. More... | |
static int | getDebugLevel () |
Get the current setting of debug level. More... | |
static Object * | SafeCopy (const Object *aObject) |
Use the clone() method to duplicate the given object unless the pointer is null in which case null is returned. More... | |
static void | RegisterType (const Object &defaultObject) |
OBSOLETE alternate name for registerType(). More... | |
static void | RenameType (const std::string &oldName, const std::string &newName) |
OBSOLETE alternate name for renameType(). More... | |
Auto-generated functions | |
static PolynomialPathFitter * | safeDownCast (OpenSim::Object *obj) |
For use in MATLAB and Python to access the concrete class. More... | |
static const std::string & | getClassName () |
This returns "PolynomialPathFitter". More... | |
void | assign (Object &aObject) override |
This allows copy assignment in the Java GUI. More... | |
PolynomialPathFitter * | clone () const override |
Create a new heap-allocated copy of the concrete object to which this Object refers. More... | |
const std::string & | getConcreteClassName () const override |
Returns the class name of the concrete Object-derived class of the actual object referenced by this Object, as a string. More... | |
Additional Inherited Members | |
![]() | |
static const std::string | DEFAULT_NAME |
Name used for default objects when they are serialized. More... | |
![]() | |
Object () | |
The default constructor is only for use by constructors of derived types. More... | |
Object (const std::string &fileName, bool aUpdateFromXMLNode=true) | |
Constructor from a file, to be called from other constructors that take a file as input. More... | |
Object (const Object &source) | |
Copy constructor is invoked automatically by derived classes with default copy constructors; otherwise it must be invoked explicitly. More... | |
Object (SimTK::Xml::Element &aElement) | |
Construct the base class portion of an Object from a given Xml element that describes this Object. More... | |
template<class T > | |
PropertyIndex | addProperty (const std::string &name, const std::string &comment, const T &value) |
Define a new single-value property of known type T, with the given name, associated comment, and initial value. More... | |
template<class T > | |
PropertyIndex | addOptionalProperty (const std::string &name, const std::string &comment) |
Add an optional property, meaning it can contain either no value or a single value. More... | |
template<class T > | |
PropertyIndex | addOptionalProperty (const std::string &name, const std::string &comment, const T &value) |
Add an optional property, meaning it can contain either no value or a single value. More... | |
template<class T > | |
PropertyIndex | addListProperty (const std::string &name, const std::string &comment, int minSize, int maxSize) |
Define a new list-valued property of known type T, with the given name, associated comment, minimum (==0) and maximum (>0) allowable list lengths, and a zero-length initial value. More... | |
template<class T , template< class > class Container> | |
PropertyIndex | addListProperty (const std::string &name, const std::string &comment, int minSize, int maxSize, const Container< T > &valueList) |
Define a new list-valued property as above, but assigning an initial value via some templatized container class that supports size() and indexing. More... | |
PropertyIndex | getPropertyIndex (const std::string &name) const |
Look up a property by name and return its PropertyIndex if it is found. More... | |
template<class T > | |
PropertyIndex | getPropertyIndex () const |
Look up an unnamed property by the type of object it contains, and return its PropertyIndex if it is found. More... | |
template<class T > | |
void | checkPropertyValueIsPositive (const Property< T > &p) const |
Throw an exception if any of the property's values are not positive. More... | |
template<class T > | |
void | checkPropertyValueIsInSet (const Property< T > &p, const std::set< T > &set) const |
Throw an exception if any of the property's values are not in the provided set. More... | |
template<class T > | |
void | checkPropertyValueIsInRangeOrSet (const Property< T > &p, const T &lower, const T &upper, const std::set< T > &set) const |
Throw an exception if any of the property's values are neither in the provided range nor in the provided set. More... | |
void | setObjectIsUpToDateWithProperties () |
When an object is initialized using the current values of its properties, it can set a flag indicating that it is up to date. More... | |
void | clearObjectIsUpToDateWithProperties () |
For testing or debugging purposes, manually clear the "object is up to
date with respect to properties" flag. More... | |
void | makeObjectNamesConsistentWithProperties () |
Make sure the name of an object is consistent with its property type. More... | |
void | updateFromXMLDocument () |
Use this method only if you're deserializing from a file and the object is at the top level; that is, primarily in constructors that take a file name as input. More... | |
void | setDocument (XMLDocument *doc) |
Unconditionally set the XMLDocument associated with this object. More... | |
const XMLDocument * | getDocument () const |
Get a const pointer to the document (if any) associated with this object. More... | |
XMLDocument * | updDocument () |
Get a writable pointer to the document (if any) associated with this object. More... | |
![]() | |
PropertySet | _propertySet |
OBSOLETE: Property_Deprecated set for serializable member variables of this and derived classes. More... | |
![]() | |
#define | OpenSim_DECLARE_CONCRETE_OBJECT(ConcreteClass, SuperClass) |
Macro to be included as the first line of the class declaration for any non-templatized, concrete class that derives from OpenSim::Object. More... | |
#define | OpenSim_DECLARE_ABSTRACT_OBJECT(ConcreteClass, SuperClass) |
Macro to be included as the first line of the class declaration for any still-abstract class that derives from OpenSim::Object. More... | |
#define | OpenSim_DECLARE_CONCRETE_OBJECT_T(ConcreteClass, TArg, SuperClass) |
Macro to be included as the first line of the class declaration for any templatized, concrete class that derives from OpenSim::Object, like Set<T>. More... | |
#define | OpenSim_DECLARE_ABSTRACT_OBJECT_T(ConcreteClass, TArg, SuperClass) |
Macro to be included as the first line of the class declaration for any templatized, still-abstract class that derives from OpenSim::Object. More... | |
A utility class for fitting a set of FunctionBasedPath
s to existing geometry-path in an OpenSim model using MultivariatePolynomialFunction
s.
The primary inputs to this class include a model containing path objects derived from AbstractGeometryPath
(e.g., GeometryPath
) and a reference trajectory containing coordinate values for all Coordinate
s in the model. The path fitting process samples coordinate values around the reference trajectory, computes path lengths and moment arms from the geometry-based paths in the model, and fits polynomial coefficients for MultivariatePolynomialFunction
objects based on the path length and moment arm samples. The fitted paths are written to an XML file, along with the modified coordinate values, sampled coordinate values, path lengths, and moment arms for both the original and fitted paths.
setOutputDirectory
method.Various settings can be adjusted to control the path fitting process. The setMomentArmsThreshold
method determines whether or not a path depends on a model coordinate. In other words, the absolute value the moment arm of a with respect to a particular coordinate must be greater than this value to be included during path fitting. The setMinimumPolynomialOrder
and setMaximumPolynomialOrder
methods specify the minimum and maximum order of the polynomial used to fit each path. The setGlobalCoordinateSamplingBounds
property specifies the global bounds (in degrees) that determine the minimum and maximum coordinate values sampled at each time point. The method appendCoordinateSamplingBounds
can be used to override the global bounds for a specific coordinate. The setMomentArmTolerance
and setPathLengthTolerance
methods specify the tolerance on the root-mean-square (RMS) error (in meters) between the moment arms and path lengths computed from the original model paths and the fitted polynomial paths. The setNumSamplesPerFrame
method specifies the number of samples taken per time frame in the coordinate values table used to fit each path. The setNumParallelThreads
method specifies the number of threads used to parallelize the path fitting process. The setLatinHypercubeAlgorithm
method specifies the Latin hypercube sampling algorithm used to sample coordinate values for path fitting.
The default settings are as follows:
The most basic usage of PolynomialPathFitter
requires the user to provide a model and reference trajectory. The model should contain at least one path object derived from AbstractGeometryPath
and should not contain any FunctionBasedPath
objects. The reference trajectory must contain coordinate values for all Coordinate
s in the model:
The additional settings can be adjusted using the various set
methods described above. For example, the global coordinate sampling bounds, bounds for the coordinate at "/jointset/slider/position", and the number of samples per frame can be set as follows:
The path fitting process can be run using the run()
method:
Information from each step of the path fitting process is logged to the console, provided that you have set the OpenSim::Logger to level "info" or greater. Warnings are printed if the number of samples is likely insufficient for the fitting process, or if the fit for a particular path did not meet the specified tolerances.
It is highly recommended to use the files printed to the output directory to evaluate the quality of the fitted paths (see setOutputDirectory()
for more details). Depending on the quality of the original model, it may not be possible to achieve a good fit for all paths (e.g., due to kinks or other discontinuities in the path). Finally, the fitted paths should only be used in simulations for which the coordinate values represent the expected range of motion for the model. If you are unsure if a simulation you have created with the fitted paths is valid, you can use the evaluateFunctionBasedPaths
static method to compare the fitted paths to the original model paths given a new kinematic trajectory.
evaluateFunctionBasedPaths
method can be used independently from the rest of this class, and does not require the FunctionBasedPath
s in the model to use MultivariatePolynomialFunction
s. This typedef might be useful within the member functions of this class.
This is generated by the OpenSim_DECLARE_*_OBJECT
macros.
Use this typedef to refer to the superclass of this class.
Avoid using the explicit type name of the superclass; this would introduce bugs if the superclass is changed.
This is generated by the OpenSim_DECLARE_*_OBJECT
macros.
OpenSim::PolynomialPathFitter::PolynomialPathFitter | ( | ) |
|
overridenoexcept |
OpenSim::PolynomialPathFitter::PolynomialPathFitter | ( | const PolynomialPathFitter & | ) |
OpenSim::PolynomialPathFitter::PolynomialPathFitter | ( | PolynomialPathFitter && | ) |
void OpenSim::PolynomialPathFitter::appendCoordinateSamplingBounds | ( | const std::string & | coordinatePath, |
const SimTK::Vec2 & | bounds | ||
) |
The bounds (in degrees) that determine the minimum and maximum coordinate value samples at each time point for the coordinate at coordinatePath
.
The bounds are specified as a SimTK::Vec2
, where the first element is the minimum bound and the second element is the maximum bound. The maximum sample value at a particular time point is the nominal coordinate value plus the maximum bound, and the minimum sample value is the nominal coordinate value minus the minimum bound. This overrides the global bounds set by setGlobalCoordinateSamplingBounds()
for this coordinate.
|
inlineoverride |
This allows copy assignment in the Java GUI.
Exception | if the argument is not of type PolynomialPathFitter. |
|
inlineoverridevirtual |
Create a new heap-allocated copy of the concrete object to which this Object refers.
It is up to the caller to delete the returned object when no longer needed. Every concrete object deriving from Object implements this pure virtual method automatically, via the declaration macro it invokes (e.g., OpenSim_DECLARE_CONCRETE_OBJECT()). Note that the concrete class overrides modify the return type to be a pointer to the concrete object; that still overrides the base class method because the return type is covariant with (that is, derives from) Object.
Implements OpenSim::Object.
|
static |
Print out a summary of the path fitting results, including information about the fitted polynomial functions and root-mean-square (RMS) errors between the original and fitted paths.
The trajectory
argument is a TableProcessor
object containing the simulation trajectory, specifically the set of coordinate values, used to compute path lengths and moment arms. The polynomialPathsFile
argument is the path to an XML file containing the set of FunctionBasedPath
s fitted to the geometry-based paths in model
. These paths can be defined by MultivariatePolynomialFunction
s generated by this class or any other Function
objects that approximate the original model paths.
|
inlinestatic |
This returns "PolynomialPathFitter".
See getConcreteClassName() if you want the class name of the underlying concrete object instead.
This is generated by the OpenSim_DECLARE_*_OBJECT
macros.
|
inlineoverridevirtual |
Returns the class name of the concrete Object-derived class of the actual object referenced by this Object, as a string.
This is the string that is used as the tag for this concrete object in an XML file. Every concrete class derived from Object automatically overrides this method via the declaration macro it uses. See getClassName() to get the class name of the referencing (possibly abstract) class rather than the concrete object.
Implements OpenSim::Object.
SimTK::Vec2 OpenSim::PolynomialPathFitter::getGlobalCoordinateSamplingBounds | ( | ) | const |
The global bounds that determine the minimum and maximum coordinate value samples at each time point.
The bounds are specified as a SimTK::Vec2
, where the first element is the minimum bound and the second element is the maximum bound. Rotational coordinates are in degrees; translational coordinates in meters. The maximum sample value at a particular time point is the nominal coordinate value plus the maximum bound, and the minimum sample value is the nominal coordinate value minus the minimum bound.
appendCoordinateSamplingBounds()
).appendCoordinateSamplingBounds()
method. std::string OpenSim::PolynomialPathFitter::getLatinHypercubeAlgorithm | ( | ) | const |
The Latin hypercube sampling algorithm used to sample coordinate values for path fitting.
The Latin hypercube sampling algorithm is used to sample coordinate values for path fitting. The algorithm can be set to either "random" or "ESEA", which stands for the enhanced stochastic evolutionary algorithm developed by Jin et al. 2005 (see class LatinHypercubeDesign
for more details). The "random" algorithm is used by default, and "ESEA" can be used to improve the quality of the sampling at the expense of higher computational cost. For most applications, the "random" algorithm is likely sufficient.
int OpenSim::PolynomialPathFitter::getMaximumPolynomialOrder | ( | ) | const |
The maximum order of the polynomial used to fit each path.
The order of a polynomial is the highest power of the independent variable(s) in the polynomial.
int OpenSim::PolynomialPathFitter::getMinimumPolynomialOrder | ( | ) | const |
The minimum order of the polynomial used to fit each path.
The order of a polynomial is the highest power of the independent variable(s) in the polynomial.
double OpenSim::PolynomialPathFitter::getMomentArmThreshold | ( | ) | const |
The moment arm threshold value that determines whether or not a path depends on a model coordinate.
In other words, the moment arm of a path with respect to a particular coordinate must be greater than this value to be included during path fitting.
double OpenSim::PolynomialPathFitter::getMomentArmTolerance | ( | ) | const |
The tolerance on the root-mean-square (RMS) error (in meters) between the moment arms computed from an original model path and a fitted polynomial-based path, which is used to determine the order of the polynomial used in the fitted path.
The moment arm RMS error must be less than the tolerance for the polynomial order to be accepted. If the RMS error is greater than the tolerance, the polynomial order is increased by one and the path is refitted. This process is repeated until the RMS error is less than the tolerance or the maximum polynomial order is reached.
setPathLengthTolerance
). int OpenSim::PolynomialPathFitter::getNumParallelThreads | ( | ) | const |
The number of threads used to parallelize the path fitting process.
This setting is used to divide the coordinate sampling, path length and moment arm computations, and path fitting across multiple threads. The number of threads must be greater than zero.
int OpenSim::PolynomialPathFitter::getNumSamplesPerFrame | ( | ) | const |
The number of samples taken per time frame in the coordinate values table used to fit each path.
std::string OpenSim::PolynomialPathFitter::getOutputDirectory | ( | ) | const |
double OpenSim::PolynomialPathFitter::getPathLengthTolerance | ( | ) | const |
The tolerance on the root-mean-square (RMS) error (in meters) between the path lengths computed from an original model path and a fitted polynomial-based path, which is used to determine the order of the polynomial used in the fitted path.
The path length RMS error must be less than the tolerance for the polynomial order to be accepted. If the RMS error is greater than the tolerance, the polynomial order is increased by one and the path is refitted. This process is repeated until the RMS error is less than the tolerance or the maximum polynomial order is reached.
setMomentArmTolerance
). PolynomialPathFitter& OpenSim::PolynomialPathFitter::operator= | ( | const PolynomialPathFitter & | ) |
PolynomialPathFitter& OpenSim::PolynomialPathFitter::operator= | ( | PolynomialPathFitter && | ) |
void OpenSim::PolynomialPathFitter::run | ( | ) |
Run the path fitting process.
The path fitting process consists of the following steps:
1. Load the model and reference coordinate values trajectory. The coordinate values table is modified to update the column labels based on the model coordinate paths, to update any coordinates dependent on `CoordinateCouplerConstraint`s, and to convert the coordinate values to radians if the "inDegrees" metadata flag is set to "yes". 2. Set sampling bounds for coordinates based on the global and coordinate-specific bounds properties. 3. Verify that the remaining user settings are valid. 4. Sample coordinate values around the reference trajectory using Latin hypercube sampling. The sampling is defined based on the coordinate bounds and range maps, the number of samples per frame, and the Latin hypercube sampling algorithm. 5. Compute path lengths and moment arms from the geometry-based paths in the input model. 6. Filter out bad coordinate samples and populate a map containing the coordinates that path is dependent on. 7. Fit the polynomial coefficients by finding a least-squares fit between the path lengths and moment arms computed from the geometry-based paths and the path lengths and moment arms computed from the fitted polynomial-based paths. 8. Print out a summary of the path fitting results, including information about the fitted polynomial functions and root-mean-square (RMS) errors between the original and fitted paths. 9. Write the fitted paths, modified coordinate values, sampled coordinate values, path lengths, and moment arms to files.
setParallel()
method.
|
inlinestatic |
For use in MATLAB and Python to access the concrete class.
Example: cObj = PolynomialPathFitter.safeDownCast(obj)
. This is equivalent to dynamic_cast<PolynomialPathFitter*>(obj)
in C++.
void OpenSim::PolynomialPathFitter::setCoordinateValues | ( | TableProcessor | coordinateValues | ) |
The reference trajectory used to sample coordinate values for path fitting.
The reference trajectory should be provided using a TableProcessor
object. The reference trajectory must contain coordinate values for all Coordinate
s in the model. We assumed that the coordinate values meet all the kinematic constraints in the model, except for CoordinateCouplerConstraint
s, since we automatically update the coordinate trajectory to satisfy these constraints. The TimeSeriesTable
must contain the "inDegrees" metadata flag; the coordinate values are automatically converted to radians if this flag is set to "yes".
void OpenSim::PolynomialPathFitter::setGlobalCoordinateSamplingBounds | ( | SimTK::Vec2 | bounds | ) |
The global bounds that determine the minimum and maximum coordinate value samples at each time point.
The bounds are specified as a SimTK::Vec2
, where the first element is the minimum bound and the second element is the maximum bound. Rotational coordinates are in degrees; translational coordinates in meters. The maximum sample value at a particular time point is the nominal coordinate value plus the maximum bound, and the minimum sample value is the nominal coordinate value minus the minimum bound.
appendCoordinateSamplingBounds()
).appendCoordinateSamplingBounds()
method. void OpenSim::PolynomialPathFitter::setLatinHypercubeAlgorithm | ( | std::string | algorithm | ) |
The Latin hypercube sampling algorithm used to sample coordinate values for path fitting.
The Latin hypercube sampling algorithm is used to sample coordinate values for path fitting. The algorithm can be set to either "random" or "ESEA", which stands for the enhanced stochastic evolutionary algorithm developed by Jin et al. 2005 (see class LatinHypercubeDesign
for more details). The "random" algorithm is used by default, and "ESEA" can be used to improve the quality of the sampling at the expense of higher computational cost. For most applications, the "random" algorithm is likely sufficient.
void OpenSim::PolynomialPathFitter::setMaximumPolynomialOrder | ( | int | order | ) |
The maximum order of the polynomial used to fit each path.
The order of a polynomial is the highest power of the independent variable(s) in the polynomial.
void OpenSim::PolynomialPathFitter::setMinimumPolynomialOrder | ( | int | order | ) |
The minimum order of the polynomial used to fit each path.
The order of a polynomial is the highest power of the independent variable(s) in the polynomial.
void OpenSim::PolynomialPathFitter::setModel | ( | ModelProcessor | model | ) |
The model containing geometry-based path objects to which polynomial-based path objects will be fitted.
The model should be provided using a ModelProcessor
object. We expect the model to contain at least one path object derived from AbstractGeometryPath
and does not already contain any FunctionBasedPath
objects. The bounds for clamped coordinates are obeyed during the fitting process. Locked coordinates are unlocked if data is provided for them, or replaced with WeldJoints if no data is provided for them.
void OpenSim::PolynomialPathFitter::setMomentArmThreshold | ( | double | threshold | ) |
The moment arm threshold value that determines whether or not a path depends on a model coordinate.
In other words, the moment arm of a path with respect to a particular coordinate must be greater than this value to be included during path fitting.
void OpenSim::PolynomialPathFitter::setMomentArmTolerance | ( | double | tolerance | ) |
The tolerance on the root-mean-square (RMS) error (in meters) between the moment arms computed from an original model path and a fitted polynomial-based path, which is used to determine the order of the polynomial used in the fitted path.
The moment arm RMS error must be less than the tolerance for the polynomial order to be accepted. If the RMS error is greater than the tolerance, the polynomial order is increased by one and the path is refitted. This process is repeated until the RMS error is less than the tolerance or the maximum polynomial order is reached.
setPathLengthTolerance
). void OpenSim::PolynomialPathFitter::setNumParallelThreads | ( | int | numThreads | ) |
The number of threads used to parallelize the path fitting process.
This setting is used to divide the coordinate sampling, path length and moment arm computations, and path fitting across multiple threads. The number of threads must be greater than zero.
void OpenSim::PolynomialPathFitter::setNumSamplesPerFrame | ( | int | numSamples | ) |
The number of samples taken per time frame in the coordinate values table used to fit each path.
void OpenSim::PolynomialPathFitter::setOutputDirectory | ( | std::string | directory | ) |
The directory to which the path fitting results are written.
If the path fitting is successful, the fitted paths are written as a Set
of FunctionBasedPath
objects (with path length functions defined using MultivariatePolynomialFunction
objects) to an XML file. Files containing the modified coordinate values, sampled coordinate values, path lengths, and moment arms for both the original and fitted paths are also written to the output directory.
void OpenSim::PolynomialPathFitter::setPathLengthTolerance | ( | double | tolerance | ) |
The tolerance on the root-mean-square (RMS) error (in meters) between the path lengths computed from an original model path and a fitted polynomial-based path, which is used to determine the order of the polynomial used in the fitted path.
The path length RMS error must be less than the tolerance for the polynomial order to be accepted. If the RMS error is greater than the tolerance, the polynomial order is increased by one and the path is refitted. This process is repeated until the RMS error is less than the tolerance or the maximum polynomial order is reached.
setMomentArmTolerance
). PolynomialPathFitterBounds OpenSim::PolynomialPathFitter::coordinate_sampling_bounds |
"The bounds (in degrees) that determine the minimum and maximum " "coordinate value samples at each time point for specific " "coordinates. These bounds override the default coordinate " "sampling bounds."
This property appears in XML files under the tag <coordinate_sampling_bounds>. This property holds a list of objects, and was generated with the OpenSim_DECLARE_LIST_PROPERTY macro; see Property to learn about the property system.
TableProcessor OpenSim::PolynomialPathFitter::coordinate_values |
"The reference trajectory used to sample coordinate values for " "path fitting."
This property appears in XML files under the tag <coordinate_values>. This property was generated with the OpenSim_DECLARE_PROPERTY macro; see Property to learn about the property system.
SimTK::Vec2 OpenSim::PolynomialPathFitter::global_coordinate_sampling_bounds |
"The global bounds (in degrees) that determine the minimum and " "maximum coordinate value samples at each time point."
This property appears in XML files under the tag <global_coordinate_sampling_bounds>. This property was generated with the OpenSim_DECLARE_PROPERTY macro; see Property to learn about the property system.
std::string OpenSim::PolynomialPathFitter::latin_hypercube_algorithm |
"The Latin hypercube sampling algorithm used to sample coordinate " "values for path fitting (default: 'random')."
This property appears in XML files under the tag <latin_hypercube_algorithm>. This property was generated with the OpenSim_DECLARE_PROPERTY macro; see Property to learn about the property system.
int OpenSim::PolynomialPathFitter::maximum_polynomial_order |
"The maximum order of the polynomial used to fit each path. The " "order of a polynomial is the highest power of the independent " "variable(s) in the polynomial."
This property appears in XML files under the tag <maximum_polynomial_order>. This property was generated with the OpenSim_DECLARE_PROPERTY macro; see Property to learn about the property system.
int OpenSim::PolynomialPathFitter::minimum_polynomial_order |
"The minimum order of the polynomial used to fit each path. The " "order of a polynomial is the highest power of the independent " "variable(s) in the polynomial."
This property appears in XML files under the tag <minimum_polynomial_order>. This property was generated with the OpenSim_DECLARE_PROPERTY macro; see Property to learn about the property system.
ModelProcessor OpenSim::PolynomialPathFitter::model |
"The model containing geometry-based path objects to which " "polynomial-based path objects will be fitted."
This property appears in XML files under the tag <model>. This property was generated with the OpenSim_DECLARE_PROPERTY macro; see Property to learn about the property system.
double OpenSim::PolynomialPathFitter::moment_arm_threshold |
"The moment arm threshold value that determines whether or not a " "path depends on a model coordinate. In other words, the moment " "arm of a path with respect to a coordinate must be greater than " "this value to be included during path fitting."
This property appears in XML files under the tag <moment_arm_threshold>. This property was generated with the OpenSim_DECLARE_PROPERTY macro; see Property to learn about the property system.
double OpenSim::PolynomialPathFitter::moment_arm_tolerance |
"The tolerance on the root-mean-square (RMS) error (in meters) " "between the moment arms computed from an original model path and " "a fitted polynomial-based path, which is used to determine the " "order of the polynomial used in the fitted path (default: 1e-4)."
This property appears in XML files under the tag <moment_arm_tolerance>. This property was generated with the OpenSim_DECLARE_PROPERTY macro; see Property to learn about the property system.
int OpenSim::PolynomialPathFitter::num_parallel_threads |
"The number of threads used to parallelize the path fitting " "process (default: two fewer than the number of available " "hardware threads)."
This property appears in XML files under the tag <num_parallel_threads>. This property was generated with the OpenSim_DECLARE_PROPERTY macro; see Property to learn about the property system.
int OpenSim::PolynomialPathFitter::num_samples_per_frame |
"The number of samples taken per time frame in the coordinate " "values table used to fit each path (default: 25)."
This property appears in XML files under the tag <num_samples_per_frame>. This property was generated with the OpenSim_DECLARE_PROPERTY macro; see Property to learn about the property system.
std::string OpenSim::PolynomialPathFitter::output_directory |
"The directory to which the path fitting results are written."
This property appears in XML files under the tag <output_directory>. This property was generated with the OpenSim_DECLARE_PROPERTY macro; see Property to learn about the property system.
double OpenSim::PolynomialPathFitter::path_length_tolerance |
"The tolerance on the root-mean-square (RMS) error (in meters) " "between the path lengths computed from an original model path and " "a fitted polynomial-based path, which is used to determine the " "order of the polynomial used in the fitted path (default: 1e-4)."
This property appears in XML files under the tag <path_length_tolerance>. This property was generated with the OpenSim_DECLARE_PROPERTY macro; see Property to learn about the property system.