Understanding accelerometer readings

Discussion in 'Simulation' started by Itamar Katz, Apr 16, 2019.

  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]);


    Attached Files:

  2. Ok, after some exploration I came to the conclusion that these noisy readings are the result of the contact points interactions. For example, a zero acceleration in the z direction can be the result of a momentarily 'free fall' when no contact is present (that's just a guess, I did not dive into the description of the contact model).

    When I do not allow a motion in the z-direction (by replacing the free joint with 2 sliding joints for x,y directions and a hinge joint for the z rotation), the readings look exactly the way I expect (as I described above), nice and smooth.
    Unfortunately I don't know how to allow friction in this case (no z movement), so I guess I'll have to change the model.
    This conclusion also makes sense in view of this thread:
    "Try modeling the wheels as ellipsoids instead of cylinders. Ellipsoid-plane contacts behave better."​