Building is successful but when I load it in the OpenSim GUI I get this error:
Here is the codeError trying to load library osimMyACLPlugin. Library not loaded.
HEADER FILE
Code: Select all
#ifndef __MyACL_h__
#define __MyACL_h__
/* -------------------------------------------------------------------------- *
* OpenSim: MyACL.h *
* -------------------------------------------------------------------------- *
// INCLUDE
#include <string>
#include <OpenSim/Simulation/Model/GeometryPath.h>
#include <OpenSim/Common/SimmSpline.h>
#include <OpenSim/Common/PropertyStr.h>
#include <OpenSim/Common/PropertyDblVec.h>
#include <OpenSim/Simulation/Model/Ligament.h>
#include "osimPluginDLL.h"
namespace OpenSim {
class OSIMPLUGIN_API MyACL: public Ligament {
OpenSim_DECLARE_CONCRETE_OBJECT(MyACL, Ligament);
//=============================================================================
// METHODS
//=============================================================================
public:
// CONSTRUCTION
MyACL();
/*virtual ~MyACL();*/
//SET
//void setBody1ByName(std::string aBodyName);
//void setBody1BushingLocation(SimTK::Vec3 location, SimTK::Vec3 orientation=SimTK::Vec3(0));
//void setBody2ByName(std::string aBodyName);
//void setBody2BushingLocation(SimTK::Vec3 location, SimTK::Vec3 orientation=SimTK::Vec3(0));
//--------------------------------------------------------------------------
// COMPUTATION
//--------------------------------------------------------------------------
virtual void computeForce(const SimTK::State& s,
SimTK::Vector_<SimTK::SpatialVec>& bodyForces,
SimTK::Vector& generalizedForces) const;
//--------------------------------------------------------------------------
// Display
//--------------------------------------------------------------------------
//virtual const VisibleObject* getDisplayer() const;
//virtual void updateDisplayer(const SimTK::State& s) const;
protected:
/** Override this method if you would like to calculate a color for use
when the %Ligament's path is displayed in the visualizer. You do not have
to invoke the base class ("Super") method, just replace it completely. This
method will be invoked during realizeDynamics() so the supplied \a state has
already been realized through Stage::Velocity and you can access time,
position, and velocity dependent quantities. You must \e not attempt to
realize the passed-in \a state any further since we are already in the
middle of realizing here. Return SimTK::Vec3(SimTK::NaN) if you want to
leave the color unchanged (that's what the base class implementation does).
@param[in] state
A SimTK::State already realized through Stage::Velocity. Do not
attempt to realize it any further.
@returns
The desired color for the path as an RGB vector with each
component ranging from 0 to 1, or NaN to indicate that the color
should not be changed. **/
virtual SimTK::Vec3 computePathColor(const SimTK::State& state) const;
// Implement ModelComponent interface.
/** Extension of parent class method; derived classes may extend further. **/
void connectToModel(Model& aModel) OVERRIDE_11;
/**
* Create a SimTK::Force which implements this MyACL as part of the SimTK::MultibodySystem.
*/
void addToSystem(SimTK::MultibodySystem& system) const OVERRIDE_11;
/** Extension of parent class method; derived classes may extend further. **/
void realizeDynamics(const SimTK::State& state) const OVERRIDE_11;
//Force reporting
/**
* Methods to query a Force for the value actually applied during simulation
* The names of the quantities (column labels) is returned by this first function
* getRecordLabels()
*/
OpenSim::Array<std::string> getRecordLabels() const {
OpenSim::Array<std::string> labels("");
labels.append(getName());
return labels;
}
/**
* Given SimTK::State object extract all the values necessary to report forces, application location
* frame, etc. used in conjunction with getRecordLabels and should return same size Array
*/
OpenSim::Array<double> getRecordValues(const SimTK::State& state) const {
OpenSim::Array<double> values(1);
values.append(getTension(state));
return values;
}
private:
//void setupProperties();
void constructProperties();
//=============================================================================
}; // END of class MyACL
//=============================================================================
//=============================================================================
} // end of namespace OpenSim
#endif // __MyACL_h__
Code: Select all
/* -------------------------------------------------------------------------- *
* OpenSim: MyACL.cpp *
* -------------------------------------------------------------------------- *
//=============================================================================
// INCLUDES
//=============================================================================
#include <OpenSim/Simulation/Model/BodySet.h>
#include <OpenSim/Simulation/Model/Model.h>
#include "MyACL.h"
//=============================================================================
// STATICS
//=============================================================================
using namespace std;
using namespace SimTK;
using namespace OpenSim;
static const Vec3 DefaultLigamentColor(.9,.9,.9); // mostly white
//=============================================================================
// CONSTRUCTOR(S) AND DESTRUCTOR
//=============================================================================
//_____________________________________________________________________________
/**
* Destructor.
*/
//MyACL::~MyACL()
//{
//}
//_____________________________________________________________________________
/**
* Default constructor.
*/
MyACL::MyACL() : Ligament()
{
constructProperties();
}
void MyACL::computeForce(const SimTK::State& s,
SimTK::Vector_<SimTK::SpatialVec>& bodyForces,
SimTK::Vector& generalizedForces) const
{
Super::computeForce( s, bodyForces, generalizedForces);
}
void MyACL::constructProperties()
{
setAuthors("Peter Loan");
constructProperty_GeometryPath(GeometryPath());
constructProperty_resting_length(0.0);
constructProperty_pcsa_force(0.0);
int forceLengthCurvePoints = 13;
double forceLengthCurveX[] = {-5.00000000, 3.20000000, 3.30000000, 3.40000000, 3.45000000, 3.50000000, 3.60000000, 3.70000000, 3.75000000, 3.80000000, 3.85000000, 3.92000000, 5.00000000};
double forceLengthCurveY[] = {0.00000000, 0.00000000, 0.04069010, 0.16276042, 0.25431315, 0.36621094, 0.65104167, 1.01725260, 1.23087565, 1.46484375, 1.71915690, 2.10937500, 2.66250000};
SimmSpline forceLengthCurve
(forceLengthCurvePoints, forceLengthCurveX, forceLengthCurveY);
constructProperty_force_length_curve(forceLengthCurve);
}
//_____________________________________________________________________________
/**
* Update the visible object used to represent the Ligament.
*/
//void MyACL::updateDisplayer(const SimTK::State& s) const
//{
// getGeometryPath().updateDisplayer(s);
//}
//------------------------------------------------------------------------------
// REALIZE DYNAMICS
//------------------------------------------------------------------------------
// See if anyone has an opinion about the path color and change it if so.
void MyACL::realizeDynamics(const SimTK::State& state) const {
Super::realizeDynamics(state); // Mandatory first line
if(!isDisabled(state)){
const SimTK::Vec3 color = computePathColor(state);
if (!color.isNaN())
getGeometryPath().setColor(state, color);
}
}
//------------------------------------------------------------------------------
// COMPUTE PATH COLOR
//------------------------------------------------------------------------------
// This is the Ligament base class implementation for choosing the path
// color. Derived classes can override this with something meaningful.
// TODO: should the default attempt to use the ligament tension to control
// colors? Not sure how to scale.
SimTK::Vec3 MyACL::computePathColor(const SimTK::State& state) const {
return SimTK::Vec3(SimTK::NaN);
}
//------------------------------------------------------------------------------
// CONNECT TO MODEL
//------------------------------------------------------------------------------
/**
* Perform some setup functions that happen after the
* ligament has been deserialized or copied.
*
* @param aModel model containing this ligament.
*/
void MyACL::connectToModel(Model& aModel)
{
GeometryPath& path = upd_GeometryPath();
const double& restingLength = get_resting_length();
path.setDefaultColor(DefaultLigamentColor);
// Specify underlying ModelComponents prior to calling
// Super::connectToModel() to automatically propagate connectToModel()
// to subcomponents. Subsequent addToSystem() will also be automatically
// propagated to subcomponents.
// TODO: this is awkward; subcomponent API needs to be revisited (sherm)
includeAsSubComponent(&path);
//TODO: can't call this at start of override; this is an API bug.
Super::connectToModel(aModel);
// _model will be NULL when objects are being registered.
if (_model == NULL)
return;
// Resting length must be greater than 0.0.
assert(restingLength > 0.0);
path.setOwner(this);
}
//------------------------------------------------------------------------------
// ADD TO SYSTEM
//------------------------------------------------------------------------------
/**
* allocate and initialize the SimTK state for this ligament.
*/
void MyACL::addToSystem(SimTK::MultibodySystem& system) const
{
Super::addToSystem(system);
// Cache the computed tension and strain of the ligament
addCacheVariable<double>("tension", 0.0, SimTK::Stage::Velocity);
addCacheVariable<double>("strain", 0.0, SimTK::Stage::Velocity);
}