Understanding accelerometer readings

Discussion in 'Simulation' started by Itamar Katz, Apr 16, 2019 at 3:23 PM.

  1. Hi
    I have a simple model of a 'box' rotating around its z axis, with some friction to add decay to the rotation. I give it an initial condition of z rotation, and I read the values of an accelerometer mounted on a site on one of the sides. As far as I understand, the accelerometer (which measures in the site's frame) should measure constant acceleration in the z direction (gravity), 0 acceleration in the x direction (perpendicular to the radius), and a slowly decaying accelaration in the y direction (the centrifugal accelaration, parallel to the radius).
    But what I see is not quite what I expect:
    in the x direction it jumps between 0 and noisy decaying values starting around 0.8, then stabilizes at 0 as the rotation stops
    in the y direction I see what I expect
    in the z direction it jumps between 0 and noisy decaying values starting around 20, then stabilizes at 9.8 as the rotation stops.
    So, what is the reason it looks the way it looks? Attached is the xml and a plot of x,y,z measurements vs. time.

    Btw, in the code, I print to the terminal the sensor values after each mj_step call and redirect to a file. Is there a better way to output the sensor values?

    int accel_adr = m->sensor_adr[0]; // outside the simulation loop
    accel_x = (float)(d->sensordata[accel_adr]);
    accel_y = (float)(d->sensordata[accel_adr + 1]);
    accel_z = (float)(d->sensordata[accel_adr + 2]);


    Thanks
     

    Attached Files: