![]() |
roneos
Operating System for the r-one robot
|
fast integer math (no floating point processor on rone) More...
Go to the source code of this file.
Data Structures | |
struct | Pose |
The pose of a robot, it's position and orientation. More... | |
Typedefs | |
typedef struct Pose | Pose |
The pose of a robot, it's position and orientation. | |
Functions | |
uint32 | sqrtInt (uint32 val) |
Compute the integer square root of a number. More... | |
int32 | vectorMag (int32 x, int32 y) |
Computes the magnitude of the input vector. More... | |
uint32 | decToZero (uint32 val) |
Continually decrements the input value by one until it is closest to zero. More... | |
int32 | average (int32 val1, int32 val2) |
Average two values. More... | |
uint8 | bitsCount (uint32 val) |
Counts how many bits the value has. More... | |
int32 | min (int32 x, int32 y) |
Finds the min of the two arguments. More... | |
int32 | max (int32 x, int32 y) |
Finds the min of the two arguments. More... | |
int32 | boundAbs (int32 val, int32 bound) |
Bounds the value with one specified bound as both lower and upper bound. More... | |
int32 | bound (int32 val, int32 lowerBound, int32 upperBound) |
Bounds the value with specified lower and upper bound. More... | |
int16 | sinMilliRad (int16 angle) |
Interprets the angle as milli-radian of sine. More... | |
int16 | cosMilliRad (int16 angle) |
int16 | atan2MilliRad (int32 y, int32 x) |
Gets atan2 approximation in miiliradians. More... | |
int16 | normalizeAngleMilliRad (int16 angle) |
Normalizes the angle. More... | |
int16 | normalizeAngleMilliRad2 (int16 angle) |
Normalizes the angle. More... | |
int32 | normalizeAngleMicroRad (int32 angle) |
Normalizes the angle. More... | |
int16 | smallestAngleDifference (int16 thetaGoal, int16 theta) |
Calculates the smallest angle difference between the two input angles. More... | |
int32 | min3 (int32 valueA, int32 valueB, int32 valueC) |
Finds the min of 3 input values. More... | |
int32 | filterIIR (int32 sample, int32 average, int32 alpha) |
IIR (low pass) filter for integer quantities. More... | |
int16 | averageAngles (int16 angle1, int16 angle2) |
Calculates the average of the two angles in milli-radians. More... | |
int32 | averageAnglesMicroRad (int32 theta1, int32 theta2) |
Calculates the average of the two angles in micro-radians. More... | |
int16 | averageArrayAngle (int16 angleArray[], int32 size) |
Calculates the average of the angles in the array. More... | |
int16 | averageAnglesLeftToRight (int16 angleLeft, int16 angleRight) |
Calculates the average of the two angles in millirad. More... | |
int16 | byteToMillirad (int8 angle) |
unit conversion (16bit to 8bit) More... | |
int8 | milliradToByte (int16 angle) |
unit conversion (16bit to 8bit) More... | |
void | pack16 (uint8 *arrayPtr, uint32 dataWord) |
Pack a 16-bit dataWord into 8-bit, pointed to by pointer arrayPtr. More... | |
void | pack24 (uint8 *arrayPtr, uint32 dataWord) |
Pack a 24-bit dataWord into 8-bit, pointed to by char pointer arrayPtr. More... | |
void | pack32 (uint8 *arrayPtr, uint32 dataWord) |
Pack a 32-bit dataWord into 8-bit, pointed to by char pointer arrayPtr. More... | |
uint16 | unpack16 (uint8 *arrayPtr) |
Unpacks an 8-bit data into 16-bit. More... | |
uint32 | unpack24 (uint8 *arrayPtr) |
Unpacks an 8-bit data into 24-bit. More... | |
uint32 | unpack32 (uint8 *arrayPtr) |
Unpacks an 8-bit data into 32 bit. Implemented in a pedantic way to avoid assumptions of endianness. More... | |
int16 | byteToMilliradUnsigned (uint8 angle) |
unit conversion (8bit to 16bit) More... | |
uint8 | milliradToByteUnsigned (int16 angle) |
unit conversion (16bit to 8bit) More... | |
int16 | angleFromBitVector (uint8 bitVector) |
Calculates the resultant angle from the bit vector. This assumes that bit0 = 0 rad. More... | |
int16 | angleFromBitVectorOffset (uint8 bitVector) |
Calculates the resultant angle from the bit vector. This assumes that bit0 = 383 rad. More... | |
int16 | angleFromBitVectorBeacon (uint8 bitVector) |
Calculates the resultant angle from the bit vector. This assumes that bit0 = 0 rad. More... | |
uint8 | bitsMaxContiguous (uint8 val) |
Determines the number of bits that reflect against an obstacle. More... | |
int32 | poseAngleDiff (Pose *poseGoalPtr, Pose *posePtr) |
Calculates the smallestAngleDifference between two poses. More... | |
void | poseAdd (Pose *poseResPtr, Pose *pose1Ptr, Pose *pose2Ptr) |
Adds two Poses and places result in a Pose. More... | |
int32 | poseDistance (Pose *pose1Ptr, Pose *pose2Ptr) |
Calculates distance between two poses. More... | |
fast integer math (no floating point processor on rone)
int16 angleFromBitVector | ( | uint8 | bitVector) |
Calculates the resultant angle from the bit vector. This assumes that bit0 = 0 rad.
bitVector | is the vector of bits |
int16 angleFromBitVectorBeacon | ( | uint8 | bitVector) |
Calculates the resultant angle from the bit vector. This assumes that bit0 = 0 rad.
bitVector | is the vector of bits |
int16 angleFromBitVectorOffset | ( | uint8 | bitVector) |
Calculates the resultant angle from the bit vector. This assumes that bit0 = 383 rad.
bitVector | is the vector of bits |
int16 atan2MilliRad | ( | int32 | y, |
int32 | x | ||
) |
Gets atan2 approximation in miiliradians.
Originally developed by John Aspinal at iRobot. It is quite good.
y | y-coordinate of the point to be calculated |
x | x-coordinate of the point to be calculated |
int32 average | ( | int32 | val1, |
int32 | val2 | ||
) |
Average two values.
val1 | is the first value |
val2 | is the second value |
int16 averageAngles | ( | int16 | angle1, |
int16 | angle2 | ||
) |
Calculates the average of the two angles in milli-radians.
angle1 | is the first angle to be averaged |
angle2 | is the second angle to be averaged |
int16 averageAnglesLeftToRight | ( | int16 | angleLeft, |
int16 | angleRight | ||
) |
Calculates the average of the two angles in millirad.
angleLeft | is the left angle to be averaged |
angleRight | is the right angle to be averaged |
int32 averageAnglesMicroRad | ( | int32 | theta1, |
int32 | theta2 | ||
) |
Calculates the average of the two angles in micro-radians.
theta1 | is the first angle to be averaged |
theta2 | is the second angle to be averaged |
int16 averageArrayAngle | ( | int16 | angleArray[], |
int32 | size | ||
) |
Calculates the average of the angles in the array.
Calculates the average of the first "size (a number)" of angles in angleArray.
angleArray[] | is the array of angles to be averaged |
size | specifies how many elements in the array (starting from the first) should be averaged |
uint8 bitsCount | ( | uint32 | val) |
Counts how many bits the value has.
Ignores leading zeros.
val | is the value to be counted |
uint8 bitsMaxContiguous | ( | uint8 | val) |
Determines the number of bits that reflect against an obstacle.
The number of bits increases as the robot gets closer to the obstacle.
val | a uint8 value |
int32 bound | ( | int32 | val, |
int32 | lowerBound, | ||
int32 | upperBound | ||
) |
Bounds the value with specified lower and upper bound.
Bounds the value so that it stays within the range of lowerBound <= value <= upperBound. If it exceeds the bound, set it to the lower/upper bound.
val | is the value to be bounded |
lowerBound | is the lower bound |
upperBound | is the upper bound |
int32 boundAbs | ( | int32 | val, |
int32 | bound | ||
) |
Bounds the value with one specified bound as both lower and upper bound.
Bounds the input value so that it stays within the range of -bound <= value <= bound. If it exceeds the bound, set it to the bound.
val | is the value to be bounded |
bound | is the lower and upper bound |
int16 byteToMillirad | ( | int8 | angle) |
unit conversion (16bit to 8bit)
unit conversion (8bit to 16bit)
angle | -angle that needs to be changed |
angle | as a 8 Byte |
unit conversion (16bit to 8bit)
angle | as a 8 Byte |
int16 byteToMilliradUnsigned | ( | uint8 | angle) |
unit conversion (8bit to 16bit)
angle | as a 8 Byte |
int16 cosMilliRad | ( | int16 | angle) |
Interprets the angle as milli-randian of cosine.
angle | the angle to be interpreted |
uint32 decToZero | ( | uint32 | val) |
Continually decrements the input value by one until it is closest to zero.
val | the value to be decremented |
int32 filterIIR | ( | int32 | sample, |
int32 | average, | ||
int32 | alpha | ||
) |
IIR (low pass) filter for integer quantities.
runs an IIR filter for integer quantities.
sample | new measurement |
average | |
alpha | IIR constant. This is divided by 100, so 100 = all newVal and 0 = all currentVal |
int32 max | ( | int32 | x, |
int32 | y | ||
) |
Finds the min of the two arguments.
Finds the min of two arguments.
x | is the value to be compared |
y | is the value to be compared |
int8 milliradToByte | ( | int16 | angle) |
unit conversion (16bit to 8bit)
angle |
uint8 milliradToByteUnsigned | ( | int16 | angle) |
unit conversion (16bit to 8bit)
angle | a int16 |
int32 min | ( | int32 | x, |
int32 | y | ||
) |
Finds the min of the two arguments.
Finds the min of two arguments.
x | is the value to be compared |
y | is the value to be compared * |
int32 min3 | ( | int32 | valueA, |
int32 | valueB, | ||
int32 | valueC | ||
) |
Finds the min of 3 input values.
valueA | first int32 value |
valueB | second int32 value |
valueC | third int32 value |
int32 normalizeAngleMicroRad | ( | int32 | angle) |
Normalizes the angle.
Normalizes the angle to make it stay in the range of 0 <= angle < microrad_2PI.
angle | the angle to be normalized |
int16 normalizeAngleMilliRad | ( | int16 | angle) |
Normalizes the angle.
Normalizes the angle to make it stay in the range of 0 <= angle < millirad_2PI
angle | the angle to be normalized |
int16 normalizeAngleMilliRad2 | ( | int16 | angle) |
Normalizes the angle.
Normalizes the angle to make it stay in the range of -millirad_PI < angle <= millirad_PI.
angle | the angle to be normalized |
void pack16 | ( | uint8 * | arrayPtr, |
uint32 | dataWord | ||
) |
Pack a 16-bit dataWord into 8-bit, pointed to by pointer arrayPtr.
arrayPtr | points to the packed 8-bit dataWord |
dataWord | 16-bit data to be packed |
void pack24 | ( | uint8 * | arrayPtr, |
uint32 | dataWord | ||
) |
Pack a 24-bit dataWord into 8-bit, pointed to by char pointer arrayPtr.
arrayPtr | points to the packed 8-bit dataWord |
dataWord | 24-bit data to be packed |
void pack32 | ( | uint8 * | arrayPtr, |
uint32 | dataWord | ||
) |
Pack a 32-bit dataWord into 8-bit, pointed to by char pointer arrayPtr.
arrayPtr | points to the packed 8-bit dataWord |
dataWord | 32-bit data to be packed |
Calculates the smallestAngleDifference between two poses.
poseGoalPtr | pointer to goal pose |
posePtr | pointer to a pose |
int16 sinMilliRad | ( | int16 | angle) |
Interprets the angle as milli-radian of sine.
angle | the angle to be interpreted |
int16 smallestAngleDifference | ( | int16 | thetaGoal, |
int16 | theta | ||
) |
Calculates the smallest angle difference between the two input angles.
The difference will be within the range of -MILLIRAD_PI <- difference <= MILLIRAD_PI.
thetaGoal | is first angle |
theta | is second angle |
uint32 sqrtInt | ( | uint32 | val) |
Compute the integer square root of a number.
Based on Microchip app note TB040. Can't take the root of numbers higher than MAX_INT32.
val | is the number to be computed |
uint16 unpack16 | ( | uint8 * | arrayPtr) |
Unpacks an 8-bit data into 16-bit.
arrayPtr | points to data with 8-bit wordlength |
uint32 unpack24 | ( | uint8 * | arrayPtr) |
Unpacks an 8-bit data into 24-bit.
arrayPtr | points to data with 8-bit wordlength |
uint32 unpack32 | ( | uint8 * | arrayPtr) |
Unpacks an 8-bit data into 32 bit. Implemented in a pedantic way to avoid assumptions of endianness.
arrayPtr | points to data with 8-bit wordlength |
int32 vectorMag | ( | int32 | x, |
int32 | y | ||
) |
Computes the magnitude of the input vector.
x | the x component of the vector |
y | the y component of the vector |