Loading
Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more

crowdAI is shutting down - please read our blog post for more information

Learning How to Walk

Reinforcement learning environments with musculoskeletal models


Completed
200
Submissions
125
Participants
18142
Views

Hunt Crossley contact model crashes integration

Posted by tomvw over 2 years ago

Hi,

I am running simulations with the model you provided, but I’m working with it in a matlab-cpp framework since I had already a learning algorithm implemented in Matlab. In some cases when I run a forward simulation the forward integration keeps running. I tried to investigate the cause of this and I found that something strange happens in the contact forces.

At a certain moment the contact force between ground and feet drops to zero and stays zero for some integration steps (at this moment there is clearly contact though). Because there is no force the foot sinks in the ground. A couple of integration steps further, the contact force peaks from zero to a huge value (because the foot sunk in the ground). This huge peak is probably the reason why the integration fails, but the cause for the force to have an interval where it is 0 is unknown to me.

Regards Tom

Posted by Lukasz_  over 2 years ago |  Quote

Hi, that sounds very interesting. Can you please share some basic code, so that we can reproduce the error?

Best, Lukasz

Posted by tomvw  over 2 years ago |  Quote

Just to give an idea how I am running the simulation: Below is the C++ code snippet that I use to do my forward integration(it is not truncated in 10ms intervals but it has a controller implemented). The “myPeriodicController” is an implementation of the abstract periodiceventhandler. It allows me to do one forward integration and adapt anything in the states (in our case the activations) every fixed “eventinterval” (10ms in our case). I think it will be difficult to replicate exactly what I am having (since it will depend on the controller that I test, and in a lot of cases there is no problem). But you can reproduce the error by just running a forward simulation through the OpenSim GUI. If you open the model and drag it so that the pelvis_y coordinate is at its maximum (via the coordinate window) and next do a simulation by hitting the green button next to simulate, the model will fall down and sink a little bit in the ground. The integration will from now on proceed very slow (it will look like it does not continue). The cause is the sudden very high peak in contact force that tries to accelerate the system, that is overall governed by stiff differential equations. If you don’t get it working immediately I can also send you .mot and .sto file with the forces acting on the system and the states of the system respectively. If you have noticed that your forward integration is in some cases going extremely slow, this is the probable cause ;-).

// ******** SimBody**********// osimModel->buildSystem(); Real eventinterval = 0.01; MultibodySystem& system_ref = osimModel->updMultibodySystem(); MyPeriodicController myPeriodicController = new MyPeriodicController(eventinterval, osimModel, NN_structure); system_ref.addEventHandler(myPeriodicController);

// ******************** OpenSim***********************//
State& s = osimModel->initializeState();
    
double initialTime;
double finalTime;
initialTime = TimeVec[0]; finalTime = TimeVec[1];

osimModel->equilibrateMuscles(s);
osimModel->getMultibodySystem().realize(s, Stage::Dynamics);
ForceReporter* reporter = new ForceReporter(osimModel);
osimModel->addAnalysis(reporter);

RungeKuttaMersonIntegrator integrator(osimModel->getMultibodySystem());    
integrator.setAccuracy(1e-6);
Manager manager(*osimModel, integrator);
manager.setInitialTime(initialTime);                                        
manager.setFinalTime(finalTime);
manager.integrate(s);

Posted by tomvw  over 2 years ago |  Quote

I am trying to find out in the source code of simbody why this happens. I am not sure of the cause but, I think it can be prevented that the model comes into this problematic state by increasing the stiffness of the contact.