Aria  2.8.0
ArAnalogGyro Class Reference

Use onboard gyro to improve the heading in an ArRobot object's pose value. More...

#include <ArAnalogGyro.h>

Public Member Functions

void activate (void)
 Lets the gyro correct readings.
 
void activateGyroOnly (void)
 Activates it and puts it in gyro only mode.
 
 ArAnalogGyro (ArRobot *robot)
 Constructor.
 
void deactivate (void)
 Stops the gyro from correcting readings (still accumulates)
 
double encoderCorrect (ArPoseWithTime deltaPose)
 internal function for correcting the encoder readings with the gyro data
 
double getAverage (void) const
 Gets the most recently calculated average rotational velocity (over one.
 
ArTime getAverageTaken (void) const
 Gets the time the last average was taken.
 
double getHeading (void) const
 Gets a heading calculated from past gyro readings.
 
int getPacCount (void)
 Returns the number of readings taken in the last second.
 
double getScalingFactor (void) const
 Gets the scaling factor used for multiplying the reading values received (default 1.626)
 
int getTemperature (void) const
 Gets the temperature the gyro has.
 
bool handleGyroPacket (ArRobotPacket *packet)
 Internal packet handler for the gyro packets.
 
bool hasGyroOnlyMode (void)
 If we have a gyro only mode.
 
bool hasNoInternalData (void)
 If this class actually has data or not (if it has no data, the robot is all there is)
 
bool haveGottenData (void)
 Returns true if any amount of gyro data has yet been received, false if no readings have yet been received from the robot.
 
bool isActive (void)
 Gets if we really have a gyro or not.
 
bool isGyroOnlyActive (void)
 If we're using gyro only mode.
 
void setFilterModel (double gyroSigma, double inertialVar, double rotVar, double transVar)
 Set the parameters of the Kalman filter model. More...
 
void setLogAnomalies (bool logAnomalies)
 Sets whether we log anomalies or not (temporary function for debugging)
 
void setScalingFactor (double factor)
 Sets the scaling factor used for multiplying the readings.
 
void stabilizingCallback (void)
 Internal connection callback; delays for a short amount of time to give the gyro enough time to stabilize before we try to use it.
 
void userTaskCallback (void)
 Internal user task callback.
 
virtual ~ArAnalogGyro ()
 Destructor.
 

Protected Types

enum  GyroType { GYRO_NONE, GYRO_ANALOG_COMPUTER, GYRO_ANALOG_CONTROLLER }
 Gyro type. More...
 

Protected Attributes

double myAccumulatedDelta
 
int myAverageCount
 
ArTime myAverageStarted
 
double myAverageTotal
 
ArRetFunctor1C< double, ArAnalogGyro, ArPoseWithTimemyEncoderCorrectCB
 
double myGyroSigma
 
GyroType myGyroType
 
bool myGyroWorking
 
ArRetFunctor1C< bool, ArAnalogGyro, ArRobotPacket * > myHandleGyroPacketCB
 
bool myHasGyroOnlyMode
 
bool myHasNoData
 
bool myHaveGottenData
 
double myHeading
 
double myInertialVarianceModel
 
bool myIsActive
 
bool myIsGyroOnlyActive
 
double myLastAverage
 
ArTime myLastAverageTaken
 
double myLastHeading
 
bool myLogAnomalies
 
int myPacCount
 
int myPacCurrentCount
 
bool myReadingThisCycle
 
ArRobotmyRobot
 
double myRotVarianceModel
 
double myScalingFactor
 
ArFunctorC< ArAnalogGyromyStabilizingCB
 
int myTemperature
 
time_t myTimeLastPacket
 
double myTransVarianceModel
 
ArFunctorC< ArAnalogGyromyUserTaskCB
 

Detailed Description

Use onboard gyro to improve the heading in an ArRobot object's pose value.

The gyro is an accessory connected to the robot's microcontroller. The gyro's purpose is to improve large errors due to wheel slippage, wheels coming off the ground, and other factors like this (or for the skid steer of an AT). The gyro also happens to provide temperature readings as well.

When an ArAnalogGyro object is created, it registers callbacks with the robot, and automatic heading correction will begin when new data arrives from the robot. If you delete the object, it will remove itself from the robot.

The readings come back from the gyro over the robot microcontroller's analog ports. The microcontroller then sends the readings to us just before sending us the standard packet. ArAnalogGyro uses these readings to calculate a better heading of the robot (integrating the velocities to give position). Then when the standard packet comes in, ArRobot calls an encoder correction callback in ArAnalogGyro which does a simple Kalman filter and fuses the encoder information's heading with the gyro's heading to compute the most probable heading which it then returns to the ArRobot object to use as its heading.

The robot's normal dead reconing angle is fairly good if you have properly inflated tires (if you have pneumatic tires) and if you have the revcount parameter sent correctly. See the robot operation manual for how to change the revcount parameter.

Gyro readings are affected by temperature (a temperature value is reported along with the gyro data in the packets from the microcontroller). The gyro will auto calibrate itself to the center of the range (which may have drifted due to temperature) whenever the robot is stationary for more than one second (that is, if its translational and rotational velocities are less than 1 and if the gyro readings are also within .5% of the average). The scaling factor (between change of voltage and amount of turn) doesn't seem to change due to temperature, though it can vary among different gyro devices. (This scaling factor can be accessed with getScalingFactor() and setScalingFactor().) The default value used here was within 3% of correct most of the time. The default resides in the parameter file for the robot that is loaded or used when a connection is made. If you want to tune this more you can, by finding a different scale factor. (There is just one so there doesn't have to be alot of calibration in flash that is lost if parameters are loaded from a file.)

General notes on gyros and inertial correction: The purpose of the gyro is to correct for wheel slippage and large errors. It is not to totally correct for all errors, but to bring the errors into smaller zones that software can correct for more easily (such as by localization). We have found that if gyros or inertial measurement devices are used to attempt to correct for all error, the result can be not very robust, and include many problematic assumptions. For this reason, we have found that it is best to integrate this one simple gyro to simply improve robot odometry, rather than a complicated and expensive IMU.

Examples:
demo.cpp, gotoActionExample.cpp, and gyroExample.cpp.

Member Enumeration Documentation

◆ GyroType

enum ArAnalogGyro::GyroType
protected

Gyro type.

Enumerator
GYRO_NONE 

No gyro.

GYRO_ANALOG_COMPUTER 

Analog gyro used by computer.

GYRO_ANALOG_CONTROLLER 

Analog gyro used by microcontroller.

Member Function Documentation

◆ setFilterModel()

void ArAnalogGyro::setFilterModel ( double  gyroSigma,
double  inertialVar,
double  rotVar,
double  transVar 
)
inline

Set the parameters of the Kalman filter model.

Parameters
gyroSigmathe amount its off statically
inertialVarthe proportional amount it is off
rotVarthe amount the rotation is off proportionally
transVarthe amount the translation throws off the heading proportionally

The documentation for this class was generated from the following files: