VEXcode Doxygen
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | List of all members
vex::inertial Class Reference

Use the inertial class to control the inertial sensor. More...

#include <vex_imu.h>

Inheritance diagram for vex::inertial:
vex::device vex::guido

Classes

class  accel
 class to hold inertial sensor acceleration data More...
 
class  attitude
 class to hold inertial angle data More...
 
class  gyro
 class to hold inertial sensor gyro data More...
 
class  matrix
 class to hold an inertial matrix More...
 
class  quaternion
 class to hold inertial quaternion data More...
 

Public Types

enum  tEventType {
  EVENT_HEADING_CHANGED = 0, EVENT_COLLISION = 1, EVENT_COLLISION_AXIS_X = 8, EVENT_COLLISION_AXIS_Y = 9,
  EVENT_COLLISION_AXIS_Z = 10
}
 

Public Member Functions

 inertial (int32_t index)
 Creates a new inertial object on the port specified. More...
 
bool installed ()
 
int32_t value ()
 
void startCalibration (int32_t value=0)
 Starts recalibration of the inertial sensor.
 
void calibrate (int32_t value=0)
 
bool isCalibrating (void)
 Returns true while the inertial sensor is performing a requested recalibration, changing to false once recalibration has completed. More...
 
void resetHeading ()
 reset the heading of the sensor to 0
 
void resetRotation ()
 reset the rotation angle of the sensor to 0
 
void setHeading (double value, rotationUnits units)
 set the inertial sensor heading to a new value More...
 
void setRotation (double value, rotationUnits units)
 set the inertial sensor rotation to angle More...
 
double angle (rotationUnits units=rotationUnits::deg)
 Gets the angle (yaw angle) of the inertial sensor. More...
 
double roll (rotationUnits units=rotationUnits::deg)
 Gets the roll angle of the inertial sensor. More...
 
double pitch (rotationUnits units=rotationUnits::deg)
 Gets the pitch angle of the inertial sensor. More...
 
double yaw (rotationUnits units=rotationUnits::deg)
 Gets the yaw angle of the inertial sensor. More...
 
double orientation (orientationType axis, rotationUnits units)
 Gets an orientation angle of the inertial sensor. More...
 
double heading (rotationUnits units=rotationUnits::deg)
 Gets the heading (yaw angle as 0-360 deg) of the inertial sensor. More...
 
double rotation (rotationUnits units=rotationUnits::deg)
 Gets the absolute angle (yaw angle without limits) of the inertial sensor. More...
 
void orientation (quaternion &q)
 Gets the inertial sensor orientation in quaternion form. More...
 
quaternion orientation ()
 Gets the inertial sensor orientation in quaternion form. More...
 
void orientation (attitude &a)
 Gets the inertial sensor orientation in rotation form. More...
 
double gyroRate (axisType axis, velocityUnits units)
 Gets the inertial sensor raw gyro data in specified units. More...
 
double acceleration (axisType axis)
 Gets the inertial sensor raw acceleration data in G. More...
 
void changed (void(*callback)(void))
 Calls a function when the inertial sensor heading value changes. More...
 
void collision (void(*callback)(axisType, double, double, double))
 Calls a function when the inertial sensor detects a collision. More...
 
- Public Member Functions inherited from vex::device
 device (int32_t index)
 
V5_DeviceType type ()
 
int32_t index ()
 
void init (int32_t index)
 
uint32_t timestamp ()
 

Protected Types

enum  orientationMode {
  ZUp, ZDown, XUp, XDown,
  YUp, YDown, Auto
}
 

Protected Member Functions

int32_t status ()
 recover inertial sensor raw status
 
double temperature ()
 recover inertial sensor temperature in deg C
 
void datarate (uint32_t rate)
 change data rate to user specified value, will be rounded to multiple of 5mS
 
inertial::gyro gyroRate ()
 Gets the inertial sensor raw gyro data in dps. More...
 
inertial::accel acceleration ()
 Gets the inertial sensor raw acceleration data in G. More...
 
void setOrientation (inertial::orientationMode orientation)
 Set the physical orientation of the inertial sensor, this will cause recalibration. More...
 
void setAccelerometerRange (uint8_t value)
 
void setCollisionThreshold (double value)
 

Additional Inherited Members

- Protected Attributes inherited from vex::device
int32_t _index
 
int32_t _threadID
 

Detailed Description

Use the inertial class to control the inertial sensor.

Constructor & Destructor Documentation

◆ inertial()

vex::inertial::inertial ( int32_t  index)

Creates a new inertial object on the port specified.

Parameters
indexThe port index for this inertial. The index is zero-based.

Member Function Documentation

◆ acceleration() [1/2]

inertial::accel vex::inertial::acceleration ( )
protected

Gets the inertial sensor raw acceleration data in G.

Returns
inertial::accel object

◆ acceleration() [2/2]

double vex::inertial::acceleration ( axisType  axis)

Gets the inertial sensor raw acceleration data in G.

Parameters
axisthe inertial sensor axis to use
Returns
value of the specified inertial sensor axis

◆ angle()

double vex::inertial::angle ( rotationUnits  units = rotationUnits::deg)
virtual

Gets the angle (yaw angle) of the inertial sensor.

Returns
Returns a double that represents the unit value specified by the parameter of the inertial sensor.
Parameters
unitsThe measurement unit for the inertial device.

Implements vex::guido.

◆ changed()

void vex::inertial::changed ( void(*)(void)  callback)

Calls a function when the inertial sensor heading value changes.

Parameters
callbackA reference to a function.

◆ collision()

void vex::inertial::collision ( void(*)(axisType, double, double, double)  callback)

Calls a function when the inertial sensor detects a collision.

Parameters
callbackA reference to a function.

◆ gyroRate() [1/2]

inertial::gyro vex::inertial::gyroRate ( )
protected

Gets the inertial sensor raw gyro data in dps.

Returns
inertial::gyro object

◆ gyroRate() [2/2]

double vex::inertial::gyroRate ( axisType  axis,
velocityUnits  units 
)

Gets the inertial sensor raw gyro data in specified units.

Parameters
axisthe inertial sensor axis to use
unitsThe units return value
Returns
value of the specified inertial sensor axis

◆ heading()

double vex::inertial::heading ( rotationUnits  units = rotationUnits::deg)
virtual

Gets the heading (yaw angle as 0-360 deg) of the inertial sensor.

Returns
Returns a double that represents the unit value specified by the parameter of the inertial sensor.
Parameters
unitsThe measurement unit for the inertial sensor.

Implements vex::guido.

◆ isCalibrating()

bool vex::inertial::isCalibrating ( void  )
virtual

Returns true while the inertial sensor is performing a requested recalibration, changing to false once recalibration has completed.

Returns
Returns true if inertial sensor is still calibrating.

Implements vex::guido.

◆ orientation() [1/4]

quaternion vex::inertial::orientation ( )

Gets the inertial sensor orientation in quaternion form.

Returns
inertial::quaternion object

◆ orientation() [2/4]

void vex::inertial::orientation ( attitude a)

Gets the inertial sensor orientation in rotation form.

Parameters
areference to instance of a inertial::attitude class

◆ orientation() [3/4]

double vex::inertial::orientation ( orientationType  axis,
rotationUnits  units 
)

Gets an orientation angle of the inertial sensor.

Returns
Returns a double that represents the unit value specified by the parameter of the inertial sensor.
Parameters
axisThe orientation axis to recover, roll, pitch or yaw.
unitsThe measurement unit for the inertial sensor.

◆ orientation() [4/4]

void vex::inertial::orientation ( quaternion q)

Gets the inertial sensor orientation in quaternion form.

Parameters
qreference to instance of a inertial::quaternion class

◆ pitch()

double vex::inertial::pitch ( rotationUnits  units = rotationUnits::deg)

Gets the pitch angle of the inertial sensor.

Returns
Returns a double that represents the unit value specified by the parameter of the inertial sensor.
Parameters
unitsThe measurement unit for the inertial device.

◆ roll()

double vex::inertial::roll ( rotationUnits  units = rotationUnits::deg)

Gets the roll angle of the inertial sensor.

Returns
Returns a double that represents the unit value specified by the parameter of the inertial sensor.
Parameters
unitsThe measurement unit for the inertial sensor.

◆ rotation()

double vex::inertial::rotation ( rotationUnits  units = rotationUnits::deg)
virtual

Gets the absolute angle (yaw angle without limits) of the inertial sensor.

Returns
Returns a double that represents the unit value specified by the parameter of the inertial sensor.
Parameters
unitsThe measurement unit for the inertial sensor.

Implements vex::guido.

◆ setHeading()

void vex::inertial::setHeading ( double  value,
rotationUnits  units 
)
virtual

set the inertial sensor heading to a new value

Parameters
valueThe new heading for the inertial sensor
unitsThe rotation unit for the angle

Implements vex::guido.

◆ setOrientation()

void vex::inertial::setOrientation ( inertial::orientationMode  orientation)
protected

Set the physical orientation of the inertial sensor, this will cause recalibration.

Parameters
orientationthe inertial sensor orientation

◆ setRotation()

void vex::inertial::setRotation ( double  value,
rotationUnits  units 
)
virtual

set the inertial sensor rotation to angle

Parameters
valueThe new absolute rotation angle for the inertial sensor
unitsThe rotation unit for the angle

Implements vex::guido.

◆ yaw()

double vex::inertial::yaw ( rotationUnits  units = rotationUnits::deg)

Gets the yaw angle of the inertial sensor.

Returns
Returns a double that represents the unit value specified by the parameter of the inertial sensor.
Parameters
unitsThe measurement unit for the inertial sensor.

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