.exe file exited with code -1073741819

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Xu Chen
Posts: 2
Joined: Fri Mar 01, 2019 1:31 pm

.exe file exited with code -1073741819

Post by Xu Chen » Sun Mar 17, 2019 9:43 am

]Hi every one. I am a fresher of OpenSim. I want to add a controllable spring between the two points on a muscoskeleton model and simulate it only under gravity . But during the intergration the .exe file always exited exited with code -1073741819.

I used "ControllableSpring.h" and "PistonActuator.h" in "APIExample" of OpenSim 3.3. My codes are below.



#include <OpenSim\OpenSim.h>
#include <iostream>
#include <string>
#include "PistonActuator.h"
#include "ControllableSpring.h"

using namespace OpenSim;
using namespace SimTK;
using namespace std;


int main()
{
try {

// load existing OpenSim model
Model Model("D:/OpenSim3.3/CustomActuatorExample/build/Geometry1/wristModel_simplified.osim");
cout << "Done loading existing model" << endl << endl;
// get existing objects
const BodySet &bodySet = Model.getBodySet();
int numBodies = Model.getNumBodies();
const JointSet &jointSet = Model.getJointSet();
int numJoints = Model.getNumJoints();
const CoordinateSet &coordinateSet = Model.getCoordinateSet();
const ForceSet &forceSet = Model.getForceSet();
const Set<Muscle> &muscleSet = Model.getMuscles();
const int numMuscles = muscleSet.getSize();
cout << "No. of muscles: " << numMuscles << endl << endl;
// Initiallise the spring
ControllableSpring *spring = new ControllableSpring;
Vec3 pointOnulna(0.00971783, - 0.0959509, 0.024286), pointOnhumerus(0.018064, - 0.140141, - 0.012746);
OpenSim::Body* ulna = &(bodySet.get(9));
OpenSim::Body* humerus = &(bodySet.get(8));
spring->setName("spring");
spring->setBodyA(ulna);
spring->setBodyB(humerus);
spring->setPointA(pointOnulna);
spring->setPointB(pointOnhumerus);
spring->setOptimalForce(2000.0);
spring->setPointsAreGlobal(false);
spring->setRestLength(0.8);
// Add the spring
Model.addForce(spring);

// Initialize the system and get the states representing the state system
State &states = Model.initSystem();

// introducing variable - muscle (dynamic array of pointers to muscle)
Schutte1993Muscle_Deprecated** muscle = new Schutte1993Muscle_Deprecated*[numMuscles];

// remove pre-existing controller
double numExistingControllers = Model.getControllerSet().getSize();
if (numExistingControllers > 0)
{
Controller &existingController = Model.getControllerSet().get(0);
Model.removeController(&existingController);
}

// define controller to introduce tremor in muscles
PrescribedController *Controller = new PrescribedController();
Controller->setName("controller");
Controller->setActuators(Model.updActuators());
cout << "setup controller" << endl << endl;

// specify some control nodes for spring stiffness control
double t[] = { 0.0, 4.0, 7.0, 10.0, 15.0 };
double x[] = { 1.0, 1.0, 0.25, 0.25, 5.0 };

// specify the control function for each actuator
tremorController->prescribeControlForActuator("spring", new PiecewiseLinearFunction(5, t, x));

// add controller
Model.addController(Controller);
cout << "Done adding controller" << endl << endl;
// save model to file
Model.print("Model.osim");
cout << "Done printing to file" << endl << endl;
// set visualizer
Model.setUseVisualizer(false);

// start and finish times for simulation
double startTime = 0.0, finishTime = 5.0;

//forward dynamics
ForwardTool *tool = new ForwardTool();
tool->setModel(Model);
tool->setStartTime(startTime);
tool->setFinalTime(finishTime);
tool->setSolveForEquilibrium(true);
tool->setName(Model_Trial");
tool->run();
Attachments
marker.png
marker.png (127.33 KiB) Viewed 171 times

Tags:

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: .exe file exited with code -1073741819

Post by Dimitar Stanev » Sun Mar 17, 2019 2:31 pm

You can add a getchar() statement in the catch block in order to pause the execution and read any exception that might be thrown:

Code: Select all

int main(int argc, char *argv[]) {
    try {
        ...
    } catch (exception &e) {
        cout << e.what() << endl;
        getchar();
        return -1;
    }
    return 0;
}
If the exception is not helpful, you should debug your application.

POST REPLY