コード例 #1
0
int main() {

    SimTK::Array_<std::string> failures;

    try {testSingleRigidTendonMuscle();}
    catch (const std::exception& e)
        {  cout << e.what() <<endl; failures.push_back("testSingleRigidTendonMuscle"); }

    // redo with the Millard2012EquilibriumMuscle 
    Object::renameType("Thelen2003Muscle", "Millard2012EquilibriumMuscle");

    try {testSingleMillardRigidTendonMuscle();}
    catch (const std::exception& e)
        {   cout << e.what() <<endl;
            failures.push_back("testSingleMillardRigidTendonMuscle"); }
    
    if (!failures.empty()) {
        cout << "Done, with failure(s): " << failures << endl;
        return 1;
    }

    cout << "Done" << endl;

    return 0;
}
コード例 #2
0
int main()
{
    SimTK::Array_<std::string> failures;

    try { testTorqueActuator(); }
    catch (const std::exception& e){
        cout << e.what() <<endl; failures.push_back("testTorqueActuator");
    }
    try { testClutchedPathSpring(); }
    catch (const std::exception& e){
        cout << e.what() <<endl; failures.push_back("testClutchedPathSpring");
    }
    try { testMcKibbenActuator(); }
    catch (const std::exception& e) {
        cout << e.what() << endl; failures.push_back("testMcKibbenActuator");
    }
    try { testBodyActuator(); }
    catch (const std::exception& e) {
        cout << e.what() << endl; failures.push_back("testBodyActuator");
    }
    try { testActuatorsCombination(); }
    catch (const std::exception& e) {
        cout << e.what() << endl; failures.push_back("testActuatorsCombination");
    }
    if (!failures.empty()) {
        cout << "Done, with failure(s): " << failures << endl;
        return 1;
    }

    cout << "Done, testActuators passed." << endl;
}
コード例 #3
0
int main()
{
    SimTK::Array_<std::string> failures;

    // get all registered Components
    SimTK::Array_<Component*> availableComponents;

    // starting with type Frame
    ArrayPtrs<Frame> availableFrames;
    Object::getRegisteredObjectsOfGivenType(availableFrames);
    for (int i = 0; i < availableFrames.size(); ++i) {
        availableComponents.push_back(availableFrames[i]);
    }

    // then type Joint
    ArrayPtrs<Joint> availableJoints;
    Object::getRegisteredObjectsOfGivenType(availableJoints);
    for (int i = 0; i < availableJoints.size(); ++i) {
        availableComponents.push_back(availableJoints[i]);
    }

    // continue with Constraint, Actuator, Frame, ...
    //Example of an updated force that passes
    ArrayPtrs<PointToPointSpring> availablePointToPointSpring;
    Object::getRegisteredObjectsOfGivenType(availablePointToPointSpring);
    availableComponents.push_back(availablePointToPointSpring[0]);

    for (unsigned int i = 0; i < availableComponents.size(); i++) {
        try {
            testComponent(*availableComponents[i]);
        }
        catch (const std::exception& e) {
            cout << "*******************************************************\n";
            cout<< "FAILURE: " << availableComponents[i]->getConcreteClassName() << endl;
            cout<< e.what() << endl;
            failures.push_back(availableComponents[i]->getConcreteClassName());
        }
    }
    
    if (!failures.empty()) {
        cout << "*******************************************************\n";
        cout << "Done, with failure(s): " << failures << endl;
        cout << failures.size() << "/" << availableComponents.size() 
            << " components failed test." << endl;
        cout << 100 * (availableComponents.size() - failures.size()) / availableComponents.size()
            << "% components passed." << endl;
        cout << "*******************************************************\n" << endl;
        return 1;
    }
    cout << "\ntestComponents PASSED. " << availableComponents.size() 
        << " components were tested." << endl;
}
コード例 #4
0
// See if we can find the given file. The rules are
//  - if it is an absolute pathname, we only get one shot, else:
//  - define "modelDir" to be the absolute pathname of the 
//      directory from which we read in the .osim model, if we did,
//      otherwise modelDir="." (current directory).
//  - look for the geometry file in modelDir
//  - look for the geometry file in modelDir/Geometry
//  - look for the geometry file in installDir/Geometry
bool ModelVisualizer::
findGeometryFile(const Model& aModel, 
                 const std::string&          geoFile,
                 bool&                       geoFileIsAbsolute,
                 SimTK::Array_<std::string>& attempts)
{
    attempts.clear();
    std::string geoDirectory, geoFileName, geoExtension; 
    SimTK::Pathname::deconstructPathname(geoFile, 
        geoFileIsAbsolute, geoDirectory, geoFileName, geoExtension);

    bool foundIt = false;
    if (geoFileIsAbsolute) {
        attempts.push_back(geoFile);
        foundIt = Pathname::fileExists(attempts.back());
    } else {  
        const string geoDir = "Geometry" + Pathname::getPathSeparator();
        string modelDir;
        if (aModel.getInputFileName() == "Unassigned") 
            modelDir = Pathname::getCurrentWorkingDirectory();
        else {
            bool isAbsolutePath; string directory, fileName, extension; 
            SimTK::Pathname::deconstructPathname(
                aModel.getInputFileName(),
                isAbsolutePath, directory, fileName, extension);
            modelDir = isAbsolutePath 
                ? directory
                : Pathname::getCurrentWorkingDirectory() + directory;
        }

        attempts.push_back(modelDir + geoFile);
        foundIt = Pathname::fileExists(attempts.back());

        if (!foundIt) {
            attempts.push_back(modelDir + geoDir + geoFile); 
            foundIt = Pathname::fileExists(attempts.back());
        }

        if (!foundIt) {
            const string installDir = 
                Pathname::getInstallDir("OPENSIM_HOME", "OpenSim");
            attempts.push_back(installDir + geoDir + geoFile);
            foundIt = Pathname::fileExists(attempts.back());
        }
    }

    return foundIt;
}
コード例 #5
0
ファイル: Geometry.cpp プロジェクト: bit20090138/opensim-core
void Cone::implementCreateDecorativeGeometry(SimTK::Array_<SimTK::DecorativeGeometry>& decoGeoms) const
{
    const Vec3 netScale = get_scale_factors();
    DecorativeCone deco(get_origin(), SimTK::UnitVec3(get_direction()), get_height(), get_base_radius());
    deco.setScaleFactors(netScale);
    decoGeoms.push_back(deco);
}
コード例 #6
0
ファイル: Geometry.cpp プロジェクト: bit20090138/opensim-core
void Cylinder::implementCreateDecorativeGeometry(SimTK::Array_<SimTK::DecorativeGeometry>& decoGeoms) const
{
    const Vec3 netScale = get_scale_factors();
    DecorativeCylinder deco(get_radius(), get_half_height());
    deco.setScaleFactors(netScale);
    decoGeoms.push_back(deco);
}
コード例 #7
0
ファイル: Geometry.cpp プロジェクト: bit20090138/opensim-core
void Ellipsoid::implementCreateDecorativeGeometry(SimTK::Array_<SimTK::DecorativeGeometry>& decoGeoms) const
{
    const Vec3 netScale = get_scale_factors();
    DecorativeEllipsoid deco(get_radii());
    deco.setScaleFactors(netScale);
    decoGeoms.push_back(deco);
}
コード例 #8
0
ファイル: Geometry.cpp プロジェクト: bit20090138/opensim-core
void Brick::implementCreateDecorativeGeometry(SimTK::Array_<SimTK::DecorativeGeometry>& decoGeoms) const
{
    const Vec3 netScale = get_scale_factors();
    DecorativeBrick deco(get_half_lengths());
    deco.setScaleFactors(netScale);
    decoGeoms.push_back(deco);
}
コード例 #9
0
ファイル: Geometry.cpp プロジェクト: bit20090138/opensim-core
void Mesh::implementCreateDecorativeGeometry(SimTK::Array_<SimTK::DecorativeGeometry>& decoGeoms) const
{
    if (cachedMesh.get() != nullptr) {
        cachedMesh->setScaleFactors(get_scale_factors());
        decoGeoms.push_back(*cachedMesh);
    }
}
コード例 #10
0
int main()
{
    Array<string> muscleModelNames;
    muscleModelNames.append("Thelen2003Muscle_Deprecated"); 
    muscleModelNames.append("Thelen2003Muscle");    
    muscleModelNames.append("Millard2012EquilibriumMuscle");
    muscleModelNames.append("Millard2012AccelerationMuscle");

    // Tolerances for the differences between the current models
    // and the 'standard' solution, which was closest to using 
    // Thelen2003Muscle_Deprecated musle formulation.
    double actTols[4] = {0.005, 0.025, 0.04, 0.04};
    double forceTols[4] = {0.5, 4, 5, 6};

    SimTK::Array_<std::string> failures;
    
    for(int i=0; i< muscleModelNames.getSize(); ++i){
        try { // regression test for the Thelen deprecate muscle
              // otherwise verify that SO runs with the new models
            testArm26(muscleModelNames[i], actTols[i], forceTols[i]);
        }
        catch (const std::exception& e) {
            cout << e.what() <<endl; 
            failures.push_back("testArm26_"+muscleModelNames[i]);
        }
    }
  
    if (!failures.empty()) {
        cout << "Done, with failure(s): " << failures << endl;
        return 1;
    }

    cout << "Done" << endl;
    return 0;
}
コード例 #11
0
// Implement generateDecorations by WrapCylinder to replace the previous out of place implementation
// in ModelVisualizer
void WrapCylinder::generateDecorations(bool fixed, const ModelDisplayHints& hints, const SimTK::State& state,
                                       SimTK::Array_<SimTK::DecorativeGeometry>& appendToThis) const
{

    Super::generateDecorations(fixed, hints, state, appendToThis);
    if (fixed) return;

    if (hints.get_show_wrap_geometry()) {
        const Appearance& defaultAppearance = get_Appearance();
        if (!defaultAppearance.get_visible()) return;
        const Vec3 color = defaultAppearance.get_color();

        SimTK::Transform ztoy;
        // Make transform that takes z axis to y axis due to different
        // assumptions between DecorativeCylinder aligned with y  and
        // WrapCylinder aligned with z
        ztoy.updR().setRotationFromAngleAboutX(SimTK_PI / 2);
        const SimTK::Transform& X_GB = getFrame().getTransformInGround(state);
        SimTK::Transform X_GW = X_GB*getTransform()*ztoy;
        appendToThis.push_back(
            SimTK::DecorativeCylinder(get_radius(),
                                      get_length() / 2)
            .setTransform(X_GW).setResolution(2.0)
            .setColor(color).setOpacity(defaultAppearance.get_opacity())
            .setScale(1).setRepresentation(defaultAppearance.get_representation()));
    }
}
コード例 #12
0
ファイル: Geometry.cpp プロジェクト: bit20090138/opensim-core
void LineGeometry::implementCreateDecorativeGeometry(SimTK::Array_<SimTK::DecorativeGeometry>& decoGeoms) const
{
    const Vec3 netScale = get_scale_factors();
    DecorativeLine deco(get_start_point(), get_end_point());
    deco.setScaleFactors(netScale);
    decoGeoms.push_back(deco);
}
コード例 #13
0
ファイル: Geometry.cpp プロジェクト: bit20090138/opensim-core
void FrameGeometry::implementCreateDecorativeGeometry(SimTK::Array_<SimTK::DecorativeGeometry>& decoGeoms) const
{
    const Vec3 netScale = get_scale_factors();
    DecorativeFrame deco(1.0);
    deco.setLineThickness(get_display_radius());
    deco.setScaleFactors(netScale);
    decoGeoms.push_back(deco);
}
コード例 #14
0
ファイル: Geometry.cpp プロジェクト: bit20090138/opensim-core
void Arrow::implementCreateDecorativeGeometry(SimTK::Array_<SimTK::DecorativeGeometry>& decoGeoms) const
{
    const Vec3 netScale = get_scale_factors();
    SimTK::Vec3 endPt(get_length()*get_direction());
    DecorativeArrow deco(SimTK::Vec3(0), endPt);
    deco.setLineThickness(0.05);
    deco.setScaleFactors(netScale);
    decoGeoms.push_back(deco);
}
コード例 #15
0
int main()
{
    SimTK::Array_<std::string> failures;
    
    try { 
    Millard2012EquilibriumMuscle muscle("muscle",
                    MaxIsometricForce0,
                    OptimalFiberLength0,
                    TendonSlackLength0,
                    PennationAngle0);

    MuscleFirstOrderActivationDynamicModel actMdl = muscle.getFirstOrderActivationModel();
    actMdl.setActivationTimeConstant(Activation0);
    actMdl.setDeactivationTimeConstant(Deactivation0);
    muscle.setFirstOrderActivationModel(actMdl);

    double x0 = 0;
    double act0 = 0.2;

    Constant control(0.5);

    Sine motion(0.1, SimTK::Pi, 0);

    simulateMuscle(muscle, 
        x0, 
        act0, 
        &motion, 
        &control, 
        IntegrationAccuracy,
        CorrectnessTest,
        CorrectnessTestTolerance,
        true);
        
        
        cout << "Probes test passed" << endl; 
    }

    catch (const Exception& e) { 
        e.print(cerr);
        failures.push_back("testProbes");
    }


    printf("\n\n");
    cout <<"************************************************************"<<endl;
    cout <<"************************************************************"<<endl;

    if (!failures.empty()) {
        cout << "Done, with failure(s): " << failures << endl;
        return 1;
    }

    
    cout << "testProbes Done" << endl;
    return 0;
}
コード例 #16
0
int main()
{
    SimTK::Array_<std::string> failures;

    try { testBody(); }
    catch (const std::exception& e){
        cout << e.what() <<endl; failures.push_back("testBody");
    }
        
    try { testPhysicalOffsetFrameOnBody(); }
    catch (const std::exception& e){
        cout << e.what() <<endl; 
        failures.push_back("testPhysicalOffsetFrameOnBody");
    }

    try { testPhysicalOffsetFrameOnBodySerialize(); }
    catch (const std::exception& e){
        cout << e.what() << endl; 
        failures.push_back("testPhysicalOffsetFrameOnBodySerialize");
    }
    
    try { testPhysicalOffsetFrameOnPhysicalOffsetFrame(); }
    catch (const std::exception& e){
        cout << e.what() << endl;
        failures.push_back("testPhysicalOffsetFrameOnPhysicalOffsetFrame");
    }

    try { testPhysicalOffsetFrameOnPhysicalOffsetFrameOrder(); }
    catch (const std::exception& e) {
        cout << e.what() << endl;
        failures.push_back("testPhysicalOffsetFrameOnPhysicalOffsetFrameOrder");
    }

    try { testFilterByFrameType(); }
    catch (const std::exception& e){
        cout << e.what() << endl;
        failures.push_back("testFilterByFrameType");
    }

    try { testVelocityAndAccelerationMethods(); }
    catch (const std::exception& e) {
        cout << e.what() << endl;
        failures.push_back("testVelocityAndAccelerationMethods");
    }

    if (!failures.empty()) {
        cout << "Done, with failure(s): " << failures << endl;
        return 1;
    }

    cout << "Done. All cases passed." << endl;

    return 0;
}
コード例 #17
0
ファイル: Geometry.cpp プロジェクト: bit20090138/opensim-core
void Geometry::generateDecorations(bool fixed, const ModelDisplayHints& hints, const SimTK::State& state,
    SimTK::Array_<SimTK::DecorativeGeometry>& appendToThis) const
{
    if (!fixed) return; // serialized Geometry is assumed fixed
    SimTK::Array_<SimTK::DecorativeGeometry> decos;
    implementCreateDecorativeGeometry(decos);
    if (decos.size() == 0) return;
    setDecorativeGeometryTransform(decos, state);
    for (unsigned i = 0; i < decos.size(); i++){
        setDecorativeGeometryAppearance(decos[i]);
        appendToThis.push_back(decos[i]);
    }
}
コード例 #18
0
ファイル: GeometryPath.cpp プロジェクト: ANKELA/opensim-core
//------------------------------------------------------------------------------
//                         GENERATE DECORATIONS
//------------------------------------------------------------------------------
// The GeometryPath takes care of drawing itself here, using information it
// can extract from the supplied state, including position information and
// color information that may have been calculated as late as Stage::Dynamics.
// For example, muscles may want the color to reflect activation level and 
// other path-using components might want to use forces (tension). We will
// ensure that the state has been realized to Stage::Dynamics before looking
// at it. (It is only guaranteed to be at Stage::Position here.)
void GeometryPath::
generateDecorations(bool fixed, const ModelDisplayHints& hints, 
                    const SimTK::State& state, 
                    SimTK::Array_<SimTK::DecorativeGeometry>& appendToThis) const
{        
    // There is no fixed geometry to generate here.
    if (fixed) { return; }
    // Ensure that the state has been realized to Stage::Dynamics to give
    // clients of this path a chance to calculate meaningful color information.
    this->getModel().getMultibodySystem().realize(state, SimTK::Stage::Dynamics);

    this->updateDisplayPath(state);

    // Even though these are Points which are Components they are completey 
    // orphaned and not part of any system since they are populated during 
    // a simulation. TODO we need another data structure to be a DecorativePath
    // which simply an array of points in ground or on MBs.
    // Trying to getLocationInGround(state) will faile due to no underlying system.
    const Array<PathPoint*>& points = getCurrentDisplayPath(state);

    if (points.getSize() == 0) { return; }

    const PathPoint* lastPoint = points[0];
    MobilizedBodyIndex mbix(0);

    Vec3 lastPos = lastPoint->getLocationInGround(state);
    if (hints.get_show_path_points())
        DefaultGeometry::drawPathPoint(mbix, lastPos, getColor(state), appendToThis);

    Vec3 pos;
    for (int j = 1; j < points.getSize(); j++) {
        const PathPoint* point = points[j];

        // the body (PhysicalFrame) IS part of the actual Model and its system
        // so we can ask it for its transform w.r.t. Ground
        pos = point->getBody().getTransformInGround(state)*point->getLocation();

        if (hints.get_show_path_points())
            DefaultGeometry::drawPathPoint(mbix, pos, getColor(state), appendToThis);

        
        // Line segments will be in ground frame
        appendToThis.push_back(DecorativeLine(lastPos, pos)
            .setLineThickness(4)
            .setColor(getColor(state)).setBodyId(0).setIndexOnBody(j));

        lastPos = pos;
    }
}
コード例 #19
0
int main()
{
    SimTK::Array_<std::string> failures;

    try { testPendulumModelWithNestedJoints<Device>(); }
    catch (const std::exception& e) {
        cout << e.what() << endl;
        failures.push_back("testPendulumModelWithNestedJoints<Device>");
    }
    try { testPendulumModelWithNestedJoints<Model>(); }
    catch (const std::exception& e) {
        cout << e.what() << endl;
        failures.push_back("testPendulumModelWithNestedJoints<Model>");
    }

    if (!failures.empty()) {
        cout << "Done, with failure(s): " << failures << endl;
        return 1;
    }

    cout << "Done. All cases passed." << endl;

    return 0;
}
コード例 #20
0
void EllipsoidJoint::generateDecorations
       (bool                                        fixed, 
        const ModelDisplayHints&                    hints,
        const SimTK::State&                         state,
        SimTK::Array_<SimTK::DecorativeGeometry>&   geometryArray) const
{
    // invoke parent class method, this draws 2 Frames
    Super::generateDecorations(fixed,hints,state,geometryArray); 

    // Construct the visible Ellipsoid
    SimTK::DecorativeEllipsoid ellipsoid(get_radii_x_y_z());
    ellipsoid.setTransform(getParentFrame().getTransformInGround(state));
    ellipsoid.setColor(Vec3(0.0, 1.0, 1.0));

    geometryArray.push_back(ellipsoid);
}
コード例 #21
0
int main()
{
    SimTK::Array_<std::string> failures;

    try { testMarkersReference(); }
    catch (const std::exception& e) {
        cout << e.what() << endl;
        failures.push_back("testMarkersReference");
    }
    try { testOrientationsReference(); }
    catch (const std::exception& e) {
        cout << e.what() << endl;
        failures.push_back("testOrientationsReference");
    }
    try { testAccuracy(); }
    catch (const std::exception& e) {
        cout << e.what() << endl; failures.push_back("testAccuracy");
    }
    try { testUpdateMarkerWeights(); }
    catch (const std::exception& e) {
        cout << e.what() << endl;
        failures.push_back("testUpdateMarkerWeights");
    }
    try { testTrackWithUpdateMarkerWeights(); }
    catch (const std::exception& e) {
        cout << e.what() << endl;
        failures.push_back("testTrackWithUpdateMarkerWeights");
    }

    try { testNumberOfMarkersMismatch(); }
    catch (const std::exception& e) {
        cout << e.what() << endl;
        failures.push_back("testNumberOfMarkersMismatch");
    }

    try { testNumberOfOrientationsMismatch(); }
    catch (const std::exception& e) {
        cout << e.what() << endl;
        failures.push_back("testNumberOfOrientationsMismatch");
    }

    if (!failures.empty()) {
        cout << "Done, with failure(s): " << failures << endl;
        return 1;
    }

    cout << "Done. All cases passed." << endl;

    return 0;
}
コード例 #22
0
int main()
{
    try {
        Storage result("Arm26_optimized_states.sto"),
                standard("std_Arm26_optimized_states.sto");
        CHECK_STORAGE_AGAINST_STANDARD(result, standard, Array<double>(0.01, 16),
            __FILE__, __LINE__, "Arm26 states failed comparison test");
        cout << "Arm26 states comparison test passed\n";

        // Ensure the optimization result acheived a velocity of at least
        // REF_MAX_VEL, and that the control values are within either 20% of the
        // reference values or 0.05 in absolute value.
        ifstream resFile;
        resFile.open("Arm26_optimization_result");
        ASSERT(resFile.is_open(), __FILE__, __LINE__,
               "Can't open optimization result file" );

        SimTK::Array_<double> resVec;
        for ( ; ; ) {
            double tmp;
            resFile >> tmp;
            if (!resFile.good())
                break;
            resVec.push_back(tmp);
        }

        ASSERT(resVec.size() == ARM26_DESIGN_SPACE_DIM+1, __FILE__, __LINE__,
               "Optimization result size mismatch" );
        
        // Ensure the optimizer found a local minimum we expect.
        for (int i = 0; i < ARM26_DESIGN_SPACE_DIM-1; ++i) {
            ASSERT(fabs(resVec[i] - refControls[i])/refControls[i] < 0.2 ||
                   fabs(resVec[i] - refControls[i]) < 0.05, __FILE__, __LINE__,
                   "Control value does not match reference" );
        }
        ASSERT(resVec[ARM26_DESIGN_SPACE_DIM] > REF_MAX_VEL, __FILE__, __LINE__,
               "Optimized velocity smaller than reference" );

        cout << "Arm26 optimization results passed\n";
    }
    catch (const Exception& e) {
        e.print(cerr);
        return 1;
    }
    cout << "Done" << endl;
    return 0;
}
コード例 #23
0
void ConstantDistanceConstraint::generateDecorations(
    bool                                        fixed,
    const ModelDisplayHints&                    hints,
    const SimTK::State&                         state,
    SimTK::Array_<SimTK::DecorativeGeometry>&   appendToThis) const
{
    Super::generateDecorations(fixed, hints, state, appendToThis);
    if (fixed) return;
    const Vec3 pink(1, .6, .8);
    const OpenSim::PhysicalFrame& frame1 = getBody1();
    const Vec3& p_B1 = frame1.getTransformInGround(state)*get_location_body_1();
    const OpenSim::PhysicalFrame& frame2 = getBody2();
    const Vec3& p_B2 = frame2.getTransformInGround(state)*get_location_body_2();
    appendToThis.push_back(
        SimTK::DecorativeLine(p_B1, p_B2).setBodyId(0)
        .setColor(pink).setOpacity(1.0).setLineThickness(.05));
}
コード例 #24
0
int main()
{
	Array<string> muscleModelNames;
    muscleModelNames.append("Thelen2003Muscle_Deprecated");	
    muscleModelNames.append("Thelen2003Muscle");	
	muscleModelNames.append("Millard2012EquilibriumMuscle");
	muscleModelNames.append("Millard2012AccelerationMuscle");


    cout << "=========================================================" << endl;
    cout << "                       WARNING                           " << endl;
    cout << "Athough this file says it testsStaticOptimization, it is" << endl;
    cout << "not a valid test. It merely checks to see if the current" << endl;
    cout << "static results agree with past static results.          " << endl;
    cout << endl;
    cout << "                This is not a test                      " << endl;
    cout << endl;
    cout << "A valid test might be done by instead checking that " <<endl;
    cout << "1. IPOPT can correctly solve a quadradic problem " <<endl;
    cout << "2. That the muscle forces provided to static are in fact   "<<endl;
    cout << "   linear with activation, as is assumed in a static " << endl;
    cout << "   optimization.                       M.Millard 2012" << endl;
    cout << "=========================================================" << endl;
	
	SimTK::Array_<std::string> failures;
	
	for(int i=0; i< muscleModelNames.getSize(); ++i){
		try { // regression test for the Thelen deprecate muscle
			  // otherwise verify that SO runs with the new models
            testArm26(muscleModelNames[i], i<1);
		}
		catch (const std::exception& e) {
			cout << e.what() <<endl; 
			failures.push_back("testArm26_"+muscleModelNames[i]);
		}
	}
  
    if (!failures.empty()) {
        cout << "Done, with failure(s): " << failures << endl;
        return 1;
    }

    cout << "Done" << endl;
    return 0;
}
コード例 #25
0
ファイル: Marker.cpp プロジェクト: chrisdembia/opensim-core
void Marker::generateDecorations(bool fixed, const ModelDisplayHints& hints, const SimTK::State& state,
    SimTK::Array_<SimTK::DecorativeGeometry>& appendToThis) const
{
    Super::generateDecorations(fixed, hints, state, appendToThis);
    if (!fixed) return;
    if (hints.get_show_markers()) { 
        // @TODO default color, size, shape should be obtained from hints
        const Vec3 pink(1, .6, .8);
        const OpenSim::PhysicalFrame& frame = getReferenceFrame();
        const Frame& bf = frame.findBaseFrame();
        SimTK::Transform bTrans = frame.findTransformInBaseFrame();
        const Vec3& p_BM = bTrans*get_location();
        appendToThis.push_back(
            SimTK::DecorativeSphere(.005).setBodyId(frame.getMobilizedBodyIndex())
            .setColor(pink).setOpacity(1.0)
            .setTransform(get_location()));
    }
}
コード例 #26
0
// Implement generateDecorations by WrapEllipsoid to replace the previous out of place implementation
// in ModelVisualizer
void WrapEllipsoid::generateDecorations(bool fixed, const ModelDisplayHints& hints, const SimTK::State& state,
                                        SimTK::Array_<SimTK::DecorativeGeometry>& appendToThis) const
{

    Super::generateDecorations(fixed, hints, state, appendToThis);
    if (fixed) return;

    if (hints.get_show_wrap_geometry()) {
        const Vec3 color(SimTK::Cyan);

        const SimTK::Transform& X_GB = getFrame().getTransformInGround(state);
        SimTK::Transform X_GW = X_GB*getTransform();
        appendToThis.push_back(
            SimTK::DecorativeEllipsoid(getRadii())
            .setTransform(X_GW).setResolution(2.0)
            .setColor(color).setOpacity(0.5));
    }

}
int main() {
    Object::renameType("Thelen2003Muscle", "Thelen2003Muscle_Deprecated");
    //Object::renameType("Thelen2003Muscle", "Millard2012AccelerationMuscle");
    //Object::renameType("Thelen2003Muscle", "Millard2012EquilibriumMuscle");
    SimTK::Array_<std::string> failures;

    try {testGait2354();}
    catch (const std::exception& e)
        {  cout << e.what() <<endl; failures.push_back("testGait2354"); }

    if (!failures.empty()) {
        cout << "Done, with failure(s): " << failures << endl;
        return 1;
    }

    cout << "Done" << endl;

    return 0;
}
コード例 #28
0
int main() {

    SimTK::Array_<std::string> failures;

    try{
        testCMCEMGDrivenArm();
    } catch(const std::exception& e) {  
        cout << e.what() <<endl; failures.push_back("testCMCEMGDrivenArm"); 
    }

    if (!failures.empty()) {
        cout << "Done, with failure(s): " << failures << endl;
        return 1;
    }

    cout << "Done" << endl;

    return 0;
}
コード例 #29
0
int main() {
	Object::renameType("Thelen2003Muscle", "Thelen2003Muscle_Deprecated");

	SimTK::Array_<std::string> failures;

	// test manager/integration process
	try { testPendulum(); cout << "\nPendulum test PASSED " << endl; }	
    catch (const std::exception& e)
		{ cout << e.what() <<endl; failures.push_back("testPendulum"); }
	
	// test application of external loads
    try { testPendulumExternalLoad(); 
		cout << "\nPendulum with external load test PASSED " << endl; }
	catch (const std::exception& e)
		{ cout << e.what() <<endl; failures.push_back("testPendulumExternalLoad"); }

	// test application of external loads
    try { testPendulumExternalLoadWithPointInGround(); 
		cout << "\nPendulum with external load and point in ground PASSED " << endl; }
	catch (const std::exception& e)
		{ cout << e.what() <<endl; failures.push_back("testPendulumExternalLoadWithPointInGround"); }
	
	// now add computation of controls and generation of muscle forces
    try { testArm26(); 
		cout << "\narm26 test PASSED " << endl; }
	catch (const std::exception& e)
		{ cout << e.what() <<endl; failures.push_back("testArm26"); }
		
	// include applied ground reactions forces 
    try { testGait2354(); 
		cout << "\ngait2354 test PASSED " << endl; }
	catch (const std::exception& e)
		{ cout << e.what() <<endl; failures.push_back("testGait2354"); }		
		
	// finally include a controller
    try { testGait2354WithController(); 
		cout << "\ngait2354 with correction controller test PASSED " << endl; }
	catch (const std::exception& e)
		{ cout << e.what() <<endl; failures.push_back("testGait2354WithController"); }	

    if (!failures.empty()) {
        cout << "Done, with failure(s): " << failures << endl;
        return 1;
    }

	cout << "Done" << endl;
    return 0;
}
コード例 #30
0
int main() {

    SimTK::Array_<std::string> failures;

    Object::renameType("Thelen2003Muscle", "Millard2012EquilibriumMuscle");

    try{
        testCMCEMGDrivenArm();
    } catch (const std::exception& e) {  
        cout << e.what() <<endl; failures.push_back("testCMCEMGDrivenArm_Millard"); 
    }

    if (!failures.empty()) {
        cout << "Done, with failure(s): " << failures << endl;
        return 1;
    }

    cout << "Done" << endl;

    return 0;
}