Skip to content
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]: Do Not Merge: Quick and dirty way to get and return GravityForce from model #3416

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Bindings/OpenSimHeaders_simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
#include <OpenSim/Simulation/Model/BushingForce.h>
#include <OpenSim/Simulation/Model/FunctionBasedBushingForce.h>
#include <OpenSim/Simulation/Model/ExpressionBasedBushingForce.h>
#include <OpenSim/Simulation/Model/GravityHelper.h>

#include <OpenSim/Simulation/Solver.h>
#include <OpenSim/Simulation/AssemblySolver.h>
Expand Down Expand Up @@ -165,4 +166,6 @@
#include <OpenSim/Actuators/ForceVelocityInverseCurve.h>
#include <OpenSim/Actuators/TendonForceLengthCurve.h>



#endif // OPENSIM_OPENSIM_HEADERS_SIMULATION_H_
4 changes: 3 additions & 1 deletion Bindings/simulation.i
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ OpenSim::ModelComponentSet<OpenSim::Controller>;
%include <OpenSim/Actuators/MuscleFixedWidthPennationModel.h>
%include <OpenSim/Actuators/Thelen2003Muscle.h>
%include <OpenSim/Actuators/Millard2012EquilibriumMuscle.h>

// Additional utility to access GravityForces
%include <OpenSim/Simulation/Model/GravityHelper.h>

// Compensate for insufficient C++11 support in SWIG
// =================================================
Expand Down Expand Up @@ -408,3 +409,4 @@ EXPOSE_SET_CONSTRUCTORS_HELPER(MarkerSet);
EXPOSE_SET_CONSTRUCTORS_HELPER(WrapObjectSet);
EXPOSE_SET_CONSTRUCTORS_HELPER(CoordinateSet);

// Extend class to extract Forces from Simbody
24 changes: 24 additions & 0 deletions OpenSim/Simulation/Model/GravityHelper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef OPENSIM_GRAVITY_HELPER_H_
#define OPENSIM_GRAVITY_HELPER_H_
#include <OpenSim/Simulation/osimSimulationDLL.h>
#include <OpenSim/Simulation/Model/ModelComponent.h>
#include <OpenSim/Simulation/Model/Model.h>
#include "Simbody.h"
namespace OpenSim {

class GravityHelper {
SimTK::ReferencePtr<Model> _model;
public:
GravityHelper(OpenSim::Model& aModel){
_model = aModel;
}
const SimTK::Vector_<SimTK::SpatialVec>& getGravityForces(
const SimTK::State& state)
{
return _model->getGravityForce().getBodyForces(state);
}

};
}

#endif // OPENSIM_GRAVITY_HELPER_H_