-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Exponential Contact #3310
Open
fcanderson
wants to merge
62
commits into
opensim-org:main
Choose a base branch
from
fcanderson:exponential_springs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
ff5fb01
Draft of OpenSim::ExponentialSpringForce
fcanderson 60a82d6
First draft.
fcanderson 39aeed4
Minor. Just line length corrections.
fcanderson 9f73ff3
Completed the basic framework.
fcanderson 569e1cf
Added draft of a Visualizer class.
fcanderson eb632ca
Adding 8 HuntCrossley at corners.
fcanderson 3064448
Constructing based on "BodyName" instead of Body.
fcanderson ab3aeda
Added Exponential Springs and an ExternalForce.
fcanderson 94f1b81
Minor Changes + Bug Fixes
fcanderson b5812da
Added Parameters. Changed name.
fcanderson 8f339cd
Bug fix, plus minor tweaks
fcanderson 6a9563f
Non-default params working + comments and tweaks.
fcanderson 110d356
File rename: "ExpoentialSpringForce" to "ExponentialContact"
fcanderson 4a0d4a7
Improved documentation comments.
fcanderson 1ffa6e3
Cleaned up code, removed memory leaks, polished comments.
fcanderson 814f974
Added detailed Doxygen comments.
fcanderson fa57ae2
Enhanced reported information.
fcanderson 52c95bc
Registered class ExponentialContact.
fcanderson 9e710a4
Bug fix and some internal testing.
fcanderson a4f91aa
Made naming more consistent.
fcanderson fd85ee5
Removed unused method.
fcanderson a5d5793
Tweaked/shortened command-line options.
fcanderson e5d97e1
Minor name change: FxES -> FxEC
fcanderson ff07658
Polished documentation comments.
fcanderson e4b3411
Memory management and simplifications.
fcanderson 94ac923
Added ExponentialContact.h to include file.
fcanderson 882e83f
Minor name changes.
fcanderson ccb4258
Added test routine for class ExponentialContact.
fcanderson 9eca269
Added two new initial conditions.
fcanderson fc38ee5
Improved output formatting.
fcanderson 56f4e22
Added resetAnchorPoint(), removed props, polished comments.
fcanderson 82cf83d
Added resetAnchorPoint(), removed props, polished comments.
fcanderson 11c8f36
Added accessors for states.
fcanderson fd02274
Added accessors for data cache entries.
fcanderson e7a006b
Added static method for resetting anchor points.
fcanderson e2a172b
ExponentialContact: Using monograph notation
fcanderson af8eb21
Merge branch 'opensim-org:master' into exponential_springs
fcanderson 36145fc
Typo Fix: corrected volume of block.
fcanderson 783c16f
testForce: enhanced test for ExponentialContact
fcanderson d2fbce2
Modified ExponentialContact::getRecordValues()
fcanderson 7f8bdf1
Modified testExponentialContact() in testForces.cpp
fcanderson e24d170
Merge branch 'opensim-org:main' into exponential_springs
fcanderson 2583850
Merge branch 'opensim-org:main' into exponential_springs
fcanderson 540da3f
Dependencies updated to build against latest Simbody build.
fcanderson e7b17b1
Commented out some cout statements.
fcanderson eb6752f
updateFromXMLNode() now declared as override
fcanderson 75e87c9
Ubuntu build fix?: Catching exception std::bad_cast
fcanderson f74c4d8
Merge branch 'opensim-org:main' into exponential_springs
fcanderson d1a605c
Minor changes to comments.
fcanderson 855b73a
Added tests for Discrete Variable accessors.
fcanderson cf84b90
ExponentialContact:: added methods related to Discrete States.
fcanderson e114e54
Component: modifications to accommodate externally allocated Discrete…
fcanderson b1cf08d
Merge branch 'opensim-org:main' into exponential_springs
fcanderson 0e67551
Merge branch 'exponential_springs' of https://github.com/fcanderson/o…
fcanderson 0ea90bc
ExponentialContact: Exported elastic anchor point as a discrete varia…
fcanderson 437feb7
[WIP] Modifications to support serializing Discrete Variables.
fcanderson 63ff32f
Removed wip methods for traversing to a DiscreteVariable.
fcanderson 69e747e
Discrete variables can now be accessed by path.
fcanderson 9f2ee6d
Component.h: fixed a few typos
fcanderson 19d99e7
testExponentialContact: output simulated states
fcanderson 3f8e4d4
testExponentialContact: added StatesTrajectoryReporter
fcanderson eefb305
Merge branch 'opensim-org:main' into exponential_springs
fcanderson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1389,44 +1389,117 @@ OpenSim_DECLARE_ABSTRACT_OBJECT(Component, Object); | |
const std::string& name) const; | ||
|
||
/** | ||
* Retrieve a read-only reference to the abstract value of the discrete | ||
* variable of a specified name. This method provides a more general | ||
* interface to handle discrete variables that may not be type double. | ||
* %Set the value of a discrete variable allocated by this Component by name. | ||
* | ||
* @param state the State from which to get the value | ||
* @param name the name of the discrete state variable | ||
* @return value the discrete variable value as a SimTK::AbstractValue | ||
* @param state the State for which to set the value | ||
* @param name the name of the discrete variable | ||
* @param value the value to set | ||
* @throws ComponentHasNoSystem if this Component has not been added to a | ||
* System (i.e., if initSystem has not been called) | ||
*/ | ||
void setDiscreteVariableValue(SimTK::State& state, const std::string& name, | ||
double value) const; | ||
|
||
|
||
//------------------------------------------------------------------------- | ||
// F. C. Anderson (January 2023, May 2023) | ||
// Added the ability to get the value of a discrete variable as a | ||
// SimTK::AbstractValue, thereby allowing types like Vec3. | ||
// In addition, getDiscreteVariableAbstractValue() and | ||
// updDiscreteVariableAbstractValue() accept the path of a discrete | ||
// variable, not just its name. | ||
|
||
/** | ||
* Based on a specified path, resolve the name of a discrete variable and | ||
* the component that owns it (i.e., its parent). | ||
* | ||
* @param pathName Specified path of the discrete variable in the Model | ||
* heirarchy. | ||
* @param dvName Returned name of the discrete variable. This string is | ||
* simply the last string in the specified pathName. | ||
* @return Pointer to the Component that owns the discrete variable. | ||
*/ | ||
const Component* resolveDiscreteVariableNameAndOwner( | ||
const std::string& pathName, std::string& dvName) const; | ||
|
||
/** | ||
* Retrieve a read-only reference to the abstract value of the discrete | ||
* variable at a specified path. This method provides a more general | ||
* interface that is not limited to values of type double. | ||
* | ||
* To obtain the type-specific value of a discrete variable, perform | ||
* a cast using the template methods provided in class SimTK::Value<T>. | ||
* When the type is unknow, it can be querried using the | ||
* SimTK::Value<T>::isA() method. For example, | ||
* | ||
* ``` | ||
* const SimTK::AbstractValue& valAbstract = | ||
* getDiscreteVariableAbstractValue(state, pathName); | ||
* | ||
* if (SimTK::Value<double>::isA(valAbstract)) { | ||
* const SimTK::Value<double>& valDbl = | ||
* SimTK::Value<double>::downcast(valAbstract); | ||
* double x = valDbl + 0.4; | ||
* | ||
* } else if (SimTK::Value<Vec3>::isA(valAbstract)) { | ||
* const SimTK::Value<Vec3>& valVec3 = | ||
* SimTK::Value<Vec3>::downcast(valAbstract); | ||
* Vec3 x = valDbl + Vec3(0.4); | ||
* } | ||
* ``` | ||
* | ||
* @param state State from which to get the value. | ||
* @param pathName Specified path of the discrete variable in the Model | ||
* heirarchy. | ||
* @return Value of the discrete variable as a reference to an | ||
* AbstractValue. | ||
* @throws ComponentHasNoSystem if this Component has not been added to a | ||
* System (i.e., if initSystem has not been called). | ||
* @throws Exception if the discrete variable is not found. | ||
*/ | ||
const SimTK::AbstractValue& getDiscreteVariableAbstractValue( | ||
const SimTK::State& state, const std::string& name) const; | ||
const SimTK::State& state, const std::string& pathName) const; | ||
|
||
/** | ||
* Retrieve a writable reference to the abstract value of the discrete | ||
* variable of a specified name. This method provides a more general | ||
* interface to handle discrete variables that may not be type double. | ||
* | ||
* @param state the State from which to get the value | ||
* @param name the name of the discrete state variable | ||
* @return value the discrete variable value as a SimTK::AbstractValue | ||
* variable at a specified path. This method provides a more general | ||
* interface that is not limited to values of type double. | ||
* | ||
* To obtain the type-specific value of a discrete variable, perform | ||
* a cast using the template methods provided in class SimTK::Value<T>. | ||
* When the type is unknow, it can be querried using the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same typos here. |
||
* SimTK::Value<T>::isA() method. For example, | ||
* | ||
* ``` | ||
* SimTK::AbstractValue& valAbstract = | ||
* updDiscreteVariableAbstractValue(state, pathName); | ||
* | ||
* if (SimTK::Value<double>::isA(valAbstract)) { | ||
* SimTK::Value<double>& valDbl = | ||
* SimTK::Value<double>::updDowncast(valAbstract); | ||
* valDbl = 0.4; | ||
* | ||
* } else if (SimTK::Value<Vec3>::isA(valAbstract)) { | ||
* SimTK::Value<Vec3>& valVec3 = | ||
* SimTK::Value<Vec3>::updDowncast(valAbstract); | ||
* valDbl = Vec3(0.4); | ||
* } | ||
* ``` | ||
* | ||
* @param state State from which to get the value. | ||
* @param pathName Specified path of the discrete variable in the Model | ||
* heirarchy. | ||
* @return Value of the discrete variable as a reference to an | ||
* AbstractValue. | ||
* @throws ComponentHasNoSystem if this Component has not been added to a | ||
* System (i.e., if initSystem has not been called) | ||
* System (i.e., if initSystem has not been called). | ||
* @throws Exception if the discrete variable is not found. | ||
*/ | ||
SimTK::AbstractValue& updDiscreteVariableAbstractValue( | ||
SimTK::State& state, const std::string& name) const; | ||
//-------------------------------------------------------------------------- | ||
|
||
|
||
/** | ||
* %Set the value of a discrete variable allocated by this Component by name. | ||
* | ||
* @param state the State for which to set the value | ||
* @param name the name of the discrete variable | ||
* @param value the value to set | ||
* @throws ComponentHasNoSystem if this Component has not been added to a | ||
* System (i.e., if initSystem has not been called) | ||
*/ | ||
void setDiscreteVariableValue(SimTK::State& state, const std::string& name, | ||
double value) const; | ||
|
||
/** | ||
* %Set the value of a discrete variable allocated by this Component by | ||
|
@@ -2034,6 +2107,12 @@ OpenSim_DECLARE_ABSTRACT_OBJECT(Component, Object); | |
|
||
protected: | ||
class StateVariable; | ||
|
||
// F. C. Anderson (May 2023) | ||
// Need declaration up front to support new methods for traversing the | ||
// Component graph to Discrete Variables. | ||
//struct DiscreteVariableInfo; | ||
|
||
//template <class T> friend class ComponentSet; | ||
// Give the ComponentMeasure access to the realize() methods. | ||
template <class T> friend class ComponentMeasure; | ||
|
@@ -2748,6 +2827,8 @@ OpenSim_DECLARE_ABSTRACT_OBJECT(Component, Object); | |
*/ | ||
const StateVariable* traverseToStateVariable( | ||
const ComponentPath& path) const; | ||
|
||
|
||
#endif | ||
|
||
/// @name Access to the owning component (advanced). | ||
|
@@ -3316,6 +3397,7 @@ OpenSim_DECLARE_ABSTRACT_OBJECT(Component, Object); | |
bool allocate{true}; | ||
}; | ||
|
||
|
||
/** | ||
* A cache variable, as stored internally by Component. | ||
*/ | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of typos here:
unknow
-->unknown
andquerried
-- >queried
.