Smartcar Shield
|
#include <GY50.hpp>
Public Member Functions | |
GY50 (Runtime &runtime, int offset, unsigned long samplingInterval=smartcarlib::constants::gy50::kDefaultSamplingInterval) | |
Constructs a GY50 gyroscope. More... | |
int | getHeading () override |
Returns the current heading of the vehicle. More... | |
void | update () override |
Updates the sensor's readings. More... | |
int | getOffset (int measurements=smartcarlib::constants::gy50::kDefaultCalibrationMeasurements) |
Get the sensor's offset which is the value the sensor returns when still. More... | |
Public Member Functions inherited from HeadingSensor | |
virtual | ~HeadingSensor ()=default |
The class representing a GY-50 gyroscope module based on the L3G4200D sensor. This sensor allows you to get the current angular displacement, in degrees, since the beginning of the measurement in the range of [0,360). By the default setup, clockwise movement increases the degree count and counter-clockwise decreases them. If you have different set up (orientation of gyroscope) you will have to adapt accordingly. This method will measure the angular displacement (rotation) since the first GY50::update was called.
Always remember to use GY50::update in your main loop along with this method.
GY50::GY50 | ( | Runtime & | runtime, |
int | offset, | ||
unsigned long | samplingInterval = smartcarlib::constants::gy50::kDefaultSamplingInterval |
||
) |
Constructs a GY50 gyroscope.
runtime | The runtime environment you want to run the class for |
offset | The sensor-specific measurement value when idle. Find the value for your sensing with GY50::getOffset. |
samplingInterval | How often to upate the heading |
Example:
|
overridevirtual |
Returns the current heading of the vehicle.
Example:
Implements HeadingSensor.
int GY50::getOffset | ( | int | measurements = smartcarlib::constants::gy50::kDefaultCalibrationMeasurements | ) |
Get the sensor's offset which is the value the sensor returns when still.
measurements | The amount of measurements to conduct to determine the offset |
Example:
Definition at line 89 of file GY50.cpp.
|
overridevirtual |
Updates the sensor's readings.
This method must be be able to be executed as often as possible.
Example:
Implements HeadingSensor.
Definition at line 40 of file GY50.cpp.