How to handle "Inf or Huge value in QACC" error.

Discussion in 'Priority support' started by Moses Nah, Feb 3, 2020.

  1. Hello!

    I am aware of the fact that the MuJoCo simulator monitors the system state for large numbers or infs/nans, and resets automatically if it finds them.

    For me, rather than automatically reseting the MuJoCo simulator, I just want to exit from the int main() function with a specific return value.

    For this, is there any function or bit that I can check of whether an "Inf or Huge value in QACC" error occurred?

    If so, my aim is then to write the following pseudo-code:

    if( "Inf or Huge value in QACC" error occurred == TRUE )
    cout << "QACC error occurred! Halting Simulation" << endl;
    return MY_ERROR_FLAG;

    I will thoroughly appreciate any help related to this.

    Thank you very much.
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    You can write your own function and call it before mj_step, like this (do the same for qvel and qacc as well):

    int mj_checkPos(const mjModel* m, mjData* d)
    for( int i=0; i<m->nq; i++ )
    if( mju_isBad(d->qpos) )
    return 1;
    return 0;

    The function mju_isBad is defined as:

    int mju_isBad(mjtNum x)
    return( x!=x || x>mjMAXVAL || x<-mjMAXVAL );
  3. Prof. Emo Todorov.

    This is perfect. Thank you very much for your response!