Friday, November 15, 2013

Gyrosensors

HiTech vs. EV3 Gyrosensor

In this post I will examine how the "old" HiTech Gyrosensor compares to the EV3 Gyrosensor . Seeing as the HiTech Gyrosensor detacts degrees/s and the EV3-sensor allegedly returns some sort of accumulation of degrees (used to make 90 degree turns, according to the LEGO tutorial), I'm unsure how exactly to compare the two. During my examination of how the hardware is used by the people behind leJOS, I'll hopefuly get a good idea of how to proceed.

Finding the old sensor in the new framework

For me this turned out to be a bit of a hunt. As it turns out all the NXT compatible sensors are organized in software packages based upon which producer manufactured them. I spent some time trying to make the GyroSensor class work until I found HiTechnicGyro. Source-code is linked below.

leJOS modes - how a sensor with multiple functions is treated

The EV3 sensor is able to give degree/s OR accumulated degrees. In the new framework this is reflected in each sensor having multiple sensorModes. For the EV3GyroSensor the available modes are:
  1. Rates (degrees/s)
  2. Angles (accumulated degrees)
After choosing a given mode for a sensor, a sampleprovider is given. This sampleprovider is then able to 'fetch' the data.
It should be noted, that this sampleProvider framework is pervasive for all sensors AND that it is possible (but unpractical) to get all possible sampleProviders from a given sensor, at any given time (for the ev3Gyro: both Rates and Angles). This adds the "hidden" cost of changing the sensors readmode between fetching data from the providers. I tested with alternating between Rates and Angles and found it gave an added latency of about 400ms.
Having experimented with how to misuse the framework, I moved on to actually trying to solve my experiment.

Experiment

First I want to compare how the to sensors performed in the same 'mode'. Below is a video which illustrates how I move the two sensors in relation to each other (ei. how I've built the device for testing). It is NOT, however, a video of my actual test-data. I only rotate the two sensors on the axis they're meant to register for the actual test.


The above shows, from all possible angles, how the setup is constructed. The below data is then collected through measured movements.

EV3 in rates mode (degrees/s)
First 90 degrees counter-clockwise, then 90 degrees counter-clockwise, then 180 degrees clockwise, then 90 degrees clockwise and lastly, 90 degrees counter-clockwise.

EV3 in Angles mode (accumulated degrees)
I see a rising degree of inaccuracy in the Angles mode, which isn't too surprising considering I'm never 'resetting' the accumulation. The first 180 degrees where more or less exactly they way I actually moved the sensor, though (fairly slowly).
The reason I didn't include videos of the above experiments was, quite simply, that I needed both hands to control the gadget because of the tangling wires.

Experiments with breaking the framework

Below is a graph of how badly the EV3 Sensor seems to perform in relation to the HiTechnic Gyro, when both modes interchange when to fetch from the hardware:
EV3 in BOTH Rates and Angles mode
It's fairly clear that this messes up the readings a lot, when compared to how equal the graph is for only rates mode.

Files




3 comments:

  1. Hi, I realize this is an old blog post, but I've only just seen it. For anyone else reading you may be interested to know that on later versions of leJOS (0.8.0 onwards), the cost of switching modes is much, much lower than the 400mS quoted here.

    Andy

    ReplyDelete
    Replies
    1. Good to know. I'll post an update of this test for version 0.8.0, when I get the time (shouldn't be too long).

      Delete
  2. Hi,

    You can use the IntegrationFilter to integrate rate to angle. This way you can also compare the angle mode of the EV3 gyro to the HiTechnic/softare solution. Make sure thought that the filter gets fresh sanples frequently.

    Aswin

    ReplyDelete