Get distance covered by a wheel using a gyroscope placed on it
Show older comments
I have to calculate the distance covered by a wheelchiar using data gathered from a gyroscope that was placed on one of the driving wheels. I know the total leght of the corridor we used for thye measurment was 8.4 meters, but I would like to know the distance that the wheelchair coverd when the velocity was constant (or almost constant). The radius of the wheel is 0.17m and the distance between the gyroscope and the centre of the wheel was 0.08m. The Gyroscope gives me the velocity in deg/s and this is how the plot looks.

The sampling frequency of the gyroscope is 75Hz and this is the code I wrote in Matlab to unwrap the angle:
Gyr_Z1(isnan(Gyr_Z1)) = 0 % substitue Nan with 0
splrate = 1/75;
values = zeros(length(Gyr_Z1),1); %create empty vector
for (i=2 : length(Gyr_Z1))
values(i) = values(i-1) + Gyr_Z1 (i)*splrate;
end
And this is the bit of code I am using to get the distance covered by the wheel:
for (i=1 : length(Gyr_Z1))
values(i) = 2*pi*.17*values(i)/360;
end But when I plot the results this is what I get

So as you can see from the picture the path of the plot looks correct as wheelchair appears to travel at a steady velocity as the Gyroscope graph indicates, but the values are clearly wrong. The lenght of the corridor was approximately 8.4 meters. I know I am making a mistake somewhere (and is likely something quite trivial), but I can't see where. Is anybody able to tell me what I am doing wrong? Thanks!
Answers (1)
James Tursa
on 8 Oct 2015
Edited: James Tursa
on 8 Oct 2015
What exactly is in the Gyr_Z1 vector? Are these raw values coming from the gyro? Are they counts? Have they been scaled so that this vector contains an angular rate as you seem to indicate? What are the units?
Gyros typically return a delta angle measured across some sampling time (perhaps returned as "counts" that need to be scaled appropriately). For your calculation, the sampling frequency (75Hz), the distance the gyro is from the wheel center (0.08m), and the resulting angular rate of the wheel have nothing to do with it. The only thing you need is the total angle through which the wheel has turned. Assuming the Gyr_Z1 contain delta angles, that calculation would then be something like this (the scaling factor dependent on what exactly is in the Gyr_Z1 array):
Total_Angle = sum(Gyr_Z1) * some_scaling_factor; % <-- want result in radians
Then to get the distance the wheel has traveled, simply:
Total_Distance = Total_Angle * Wheel_Radius;
But again, this is partly speculation on my part because it is not clear what exactly is in the Gyr_Z1 vector. If the values currently in Gyr_Z1 have already been scaled in some way by the 75Hz value, then that would have to be backed out. Please clarify this.
If you know the answer should be 8.4m, then you could of course simply use that in the above equations (set Total_Distance = 8.4) to solve for what the some_scaling_factor value should be, and then see if that makes sense.
Categories
Find more on Axes Transformations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!