WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation


Supports gyros/gyroscopes.
Gyros normally come in either 2 axis, or 3 axis versions. Sometimes you can buy a combo board that contains gyro and, say, an accelerometer. I don't directly support these combos so you need to declare the two individual sensors.
So what do they do? Gyros measure rotational velocity in degrees per second. This could be used to monitor whether a robot biped is falling over, so that you can compensate, or if measuring the rotation of an axle then, knowing the wheel circumference, you can work out the current speed of the robot.
These devices either use one ADC pin for each axis, or provide an I2C interface but you will need to check the individual data sheets to see what power supply they need.
All gyros return one value per axis and this value is in 'degrees per second'. Each value may be positive or negative and a two axis device will set the Z value to zero.
Since all of the devices have been implemented in the same way then it means that you can swap one device for another by only changing the #include and the MAKE command used to create the device.
So here is the generic way to work with a <DEVICE> of a given <MAKE> and <MODEL>:-
// Include the relevant sensor file
#include "Sensors/Gyro/<MAKE>/<MODEL>.h"
// Create the device
<DEVICE> device = MAKE_<DEVICE>(F0,F1);
In your appInitHardware you should initialise the device:-
Then in your main loop you can read the sensor using:-
Each axis can then be read independently into a variable of type 'ACCEL_TYPE':-
GYRO_TYPE x = device.gyro.x_axis_degrees_per_second;
GYRO_TYPE y = device.gyro.y_axis_degrees_per_second;
Or dumped to the current rprintf destination using:-




Valid XHTML 1.0 Transitional