MSPM0_ValvanoWare  1.0
ECE445L starter code
Data Structures | Macros | Typedefs | Enumerations | Enumerator | Functions | Variables
Math

Software implementations of math functions. More...

Data Structures

struct  complex
 a complex number has a real and imaginary part More...
 

Macros

#define PI   3.14159265358979323846264338327950288
 PI is ratio of circumference to diameter of a circle.
 
#define N   360
 counts/rotation, just one edge of one tach
 
#define D   70000
 wheel diameter 0.0001cm
 
#define W   140000
 wheel base 0.0001 cm
 
#define C   219910
 wheel circumference 0.0001cm
 
#define PI   8192
 representation of pi radians
 
#define TWOPI   (2*PI)
 6.28...
 
#define NORTH   4096
 direction that is north
 
#define EAST   0
 direction that is east
 
#define SOUTH   -4096
 direction that is south
 
#define WEST   -8192
 direction that is west
 
#define XYTOLERANCE   10000
 tolerance in x,y goal seeking, 1 cm
 
#define THETATOLERANCE   (4096/90)
 tolerance in angle goal seeking, 1 deg
 

Typedefs

typedef struct complex complex_t
 
typedef uint8_t fuz_t
 8-bit fuzzy variable having values from true (255,254,253,...,2,1,0) false
 

Enumerations

enum  RobotState {
  ISSTOPPED , GOFORWARD , HARDRIGHT , HARDLEFT ,
  SOFTRIGHT , SOFTLEFT
}
 robot state More...
 
enum  OdometryCommand {
  STOP , FORWARDTOX , FORWARDTOY , LEFTTOTH ,
  RIGHTTOTH
}
 Odometry Commands. More...
 

Functions

void NoiseReject_Init (void)
 Initialization of noise reject filter. More...
 
int32_t NoiseReject (int32_t x)
 removes random noise from audio signal More...
 
void DFT_Init (void)
 Initialization of discrete fourier transform. More...
 
void DFT (uint32_t i, int32_t x)
 Run DFT. More...
 
int32_t Mag1 (void)
 magnitude of the first frequency More...
 
int32_t Mag2 (void)
 magnitude of the second frequency More...
 
void fft (complex_t *v, int n, complex_t *tmp)
 fft More...
 
void ifft (complex_t *v, int n, complex_t *tmp)
 Inverse fft. More...
 
int16_t fixed_sin (int32_t theta)
 decimal fixed-point sin More...
 
int16_t fixed_cos (int32_t theta)
 decimal fixed-point cos More...
 
int32_t fixed_sin2 (int32_t theta)
 binary fixed-point sin More...
 
int32_t fixed_cos2 (int32_t theta)
 binary fixed-point cos More...
 
int32_t sin540 (int32_t theta)
 binary fixed-point sin More...
 
int32_t cos540 (int32_t theta)
 binary fixed-point cos More...
 
fuz_t not (fuz_t u1)
 Complement. More...
 
fuz_t or (fuz_t u1, fuz_t u2)
 Fuzzy or. More...
 
fuz_t or3 (fuz_t u1, fuz_t u2, fuz_t u3)
 Fuzzy or. More...
 
fuz_t and (fuz_t u1, fuz_t u2)
 Fuzzy and. More...
 
fuz_t and3 (fuz_t u1, fuz_t u2, fuz_t u3)
 Fuzzy and. More...
 
uint32_t umin32 (uint32_t u1, uint32_t u2)
 minimum More...
 
int32_t min32 (int32_t n1, int32_t n2, int32_t n3)
 minimum More...
 
fuz_t MinFuzzification (int32_t crisp, const int32_t MIN, const int32_t MAX)
 Fuzzification. More...
 
fuz_t CenterFuzzification (int32_t crisp, const int32_t MIN, const int32_t CENTER, const int32_t MAX)
 Fuzzification. More...
 
fuz_t LeftRightFuzzification (int32_t crisp, const int32_t MIN, const int32_t LEFT, const int32_t RIGHT, const int32_t MAX)
 Fuzzification. More...
 
fuz_t MaxFuzzification (int32_t crisp, const int32_t MIN, const int32_t MAX)
 Fuzzification. More...
 
char FuzzyChar (fuz_t fuz)
 convert fuzzy variable to ASCII character More...
 
uint32_t median5 (uint32_t u[5])
 5-wide median filter More...
 
int8_t Median (int8_t x)
 3-wide median filter More...
 
int8_t Median3 (int8_t u1, int8_t u2, int8_t u3)
 3-wide median filter More...
 
int8_t Median5 (int8_t x)
 5-wide median filter More...
 
int8_t Median7 (int8_t x)
 7-wide median filter More...
 
void Odometry_Init (int32_t initx, int32_t inity, int32_t initTheta)
 Initialize odometry module. More...
 
void Odometry_Update (int32_t LCount, int32_t RCount)
 Compute new position/angle of the robot. More...
 
void Odometry_SetPower (uint32_t fast, uint32_t slow)
 Set power levels. More...
 
int32_t Odometry_GetX (void)
 Get X position. More...
 
int32_t Odometry_GetY (void)
 Get y position. More...
 
int32_t Odometry_GetAngle (void)
 Get theta angle. More...
 
void Odometry_Get (int32_t *x, int32_t *y, int32_t *theta)
 Get the current robot position. More...
 
void UpdatePosition (void)
 update position More...
 
void Display (void)
 OLED output. More...
 
void WaitUntilBumperTouched (void)
 Wait until bumper touched. More...
 
void StopUntilBumperTouched (void)
 Stop and wait until bumper touched. More...
 
uint32_t ForwardUntilCrash (void)
 Go until bumper touched. More...
 
uint32_t ForwardUntilX (int32_t desiredX)
 Forward Until X goal. More...
 
uint32_t ForwardUntilY (int32_t desiredY)
 Forward Until Y goal. More...
 
uint32_t SoftLeftUntilTh (int32_t desiredTh)
 Soft Left Until Theta. More...
 
void ForwardUntilXStart (int32_t thedesiredX)
 start going Forward Until X More...
 
uint32_t ForwardUntilXStatus (void)
 check status of Forward Until X command More...
 
void ForwardUntilYStart (int32_t thedesiredY)
 start going Forward Until Y More...
 
uint32_t ForwardUntilYStatus (void)
 check status of Forward Until Y command More...
 
void SoftLeftUntilThStart (int32_t thedesiredTh)
 start going Forward Until Y More...
 
uint32_t ForwardUntilThStatus (void)
 check status of soft left until theta command More...
 
uint32_t CheckGoal (void)
 check status of odometry command More...
 

Variables

float Real
 
float Imag
 

Detailed Description

Software implementations of math functions.

Enumeration Type Documentation

◆ OdometryCommand

Odometry Commands.

These are possible odometry commands

Enumerator
STOP 

stop robot

FORWARDTOX 

move forward straight until X is matched within tolerance XYTOLERANCE

FORWARDTOY 

move forward straight until Y is matched within tolerance XYTOLERANCE

LEFTTOTH 

turn left until theta is matched within tolerance THETATOLERANCE

RIGHTTOTH 

turn right until theta is matched within tolerance THETATOLERANCE

◆ RobotState

enum RobotState

robot state

These are possible robot motions for odometry system

Enumerator
ISSTOPPED 

stopped

GOFORWARD 

going forward

HARDRIGHT 

turning hard right

HARDLEFT 

turning hard left

SOFTRIGHT 

turning soft right

SOFTLEFT 

turning soft left

Function Documentation

◆ and()

fuz_t and ( fuz_t  u1,
fuz_t  u2 
)

Fuzzy and.

Fuzzy logic and

Parameters
u1is a fuzzy variable
u2is a fuzzy variable
Returns
minimum of u1 u2

◆ and3()

fuz_t and3 ( fuz_t  u1,
fuz_t  u2,
fuz_t  u3 
)

Fuzzy and.

Fuzzy logic and

Parameters
u1is a fuzzy variable
u2is a fuzzy variable
u3is a fuzzy variable
Returns
minimum of u1 u2 u3

◆ CenterFuzzification()

fuz_t CenterFuzzification ( int32_t  crisp,
const int32_t  MIN,
const int32_t  CENTER,
const int32_t  MAX 
)

Fuzzification.

Fuzzy logic fuzzification, converting crisp input to fuzzy variable.
If crisp is less than MIN, then fuzzy is false.
If crisp is between MIN and CENTER, then fuzzy is linear.
If crisp is CENTER, then fuzzy is true.
If crisp is between CENTER and max, then fuzzy is linear.
If crisp is greater than MAX, then fuzzy is false.
255
|.................... -
|................. / ...
|.............. / ........ \
|........... / .............. \
|........ / .................... \
|-----— ........................------—
0.....MIN ... CENTER ....... MAX

Note
MIN must be less than CENTER, and CENTER must be less than MAX. Constants must not be equal.
Parameters
crispis a crisp input
MINis threshold value for the crisp input
CENTERis a second threshold value for the crisp input
MAXis a third threshold value for the crisp input
Returns
fuzzy value

◆ CheckGoal()

uint32_t CheckGoal ( void  )

check status of odometry command

Odometry command to check status of any odometry command. Assumes ForwardUntilXStart ForwardUntilYStart or SoftLeftUntilThStart has been issued

Parameters
none
Returns
true if done or error, false if still running ok

◆ cos540()

int32_t cos540 ( int32_t  theta)

binary fixed-point cos

binaryfixed-point cos****************

Parameters
theta0 to 539, angle is in units 2*pi/540 = 0.011635528 radians (0 to 2pi)
Returns
-65536 to +65536, fixed point resolution 1/65536
Note
input theta=4096 means 90 degrees (pi/2 radians)

◆ DFT()

void DFT ( uint32_t  i,
int32_t  x 
)

Run DFT.

One point added to discrete fourier transform

Parameters
iis 0 to 15 index
xis input data at index i
Returns
none

◆ DFT_Init()

void DFT_Init ( void  )

Initialization of discrete fourier transform.

Initialization of 16-point discrete fourier transform

Parameters
none
Returns
none

◆ Display()

void Display ( void  )

OLED output.

Show current state on OLED

Parameters
none
Returns
none
Note
uses SSD1306.c

◆ fft()

void fft ( complex_t v,
int  n,
complex_t tmp 
)

fft

discrete Fast Fourier Transform, Converts time to frequency domain
Assume the input is real data sampled at fs
Place n measurements into the real part of array v
Set the imaginary part of array v to 0
Call fft() and the results are returned back in array v
If the input is real only, then the transform will contain
Index 0 <= k < n/2 complex components of frequency f=k/fs
E.g., k=0 represents the DC component of the input
Index n/2 <= k < n are complex conjugates of the first half

Parameters
varray of input data in complex form
nsize of the two arrays 2, 4, 8, ..., 2048
tmptemporary array of data in complex form
Returns
none
Note
n is a power of two from 2 to 2048

◆ fixed_cos()

int16_t fixed_cos ( int32_t  theta)

decimal fixed-point cos

decimal fixed-point cos****************

Parameters
theta-3142 to 3142, angle is in units radians/1000
Returns
-10000 to +10000, fixed point resolution 1/10000
Note
input theta=-1571 means 90 degrees (pi/2 radians)

◆ fixed_cos2()

int32_t fixed_cos2 ( int32_t  theta)

binary fixed-point cos

binaryfixed-point cos****************

Parameters
theta-8192 to 8191, angle is in units 2*pi/16384 radians (-pi to +pi)
Returns
-65536 to +65536, fixed point resolution 1/65536
Note
input theta=4096 means 90 degrees (pi/2 radians)

◆ fixed_sin()

int16_t fixed_sin ( int32_t  theta)

decimal fixed-point sin

decimal fixed-point sin****************

Parameters
theta-3142 to 3142, angle is in units radians/1000
Returns
-10000 to +10000, fixed point resolution 1/10000
Note
input theta=1571 means 90 degrees (pi/2 radians)

◆ fixed_sin2()

int32_t fixed_sin2 ( int32_t  theta)

binary fixed-point sin

binary fixed-point sin****************

Parameters
theta-8192 to 8191, angle is in units 2*pi/16384 radians (-pi to +pi)
Returns
-65536 to +65536, fixed point resolution 1/65536
Note
input theta=-4096 means -90 degrees (pi/2 radians)

◆ ForwardUntilCrash()

uint32_t ForwardUntilCrash ( void  )

Go until bumper touched.

Go straight until bumper touched (crash)

Parameters
none
Returns
none
Note
uses bump.c

◆ ForwardUntilThStatus()

uint32_t ForwardUntilThStatus ( void  )

check status of soft left until theta command

Odometry command to check status of soft left until theta command. Assumes SoftLeftUntilThStart has been issued

Parameters
none
Returns
true if done or error, false if still running ok

◆ ForwardUntilX()

uint32_t ForwardUntilX ( int32_t  desiredX)

Forward Until X goal.

Odometry command to Go straight until X goal has been reached. This routine will run until goal is met.

Parameters
desiredXdesired X position in units of 0.0001cm
Returns
0 for success, nonzero is failure (crash=bump sensor or 0xFF=going wrong way)

◆ ForwardUntilXStart()

void ForwardUntilXStart ( int32_t  thedesiredX)

start going Forward Until X

Odometry command to Go straight until X goal has been reached. This routine will start the command, but return immediately

Parameters
thedesiredXdesired X position in units of 0.0001cm
Returns
none

◆ ForwardUntilXStatus()

uint32_t ForwardUntilXStatus ( void  )

check status of Forward Until X command

Odometry command to check status of Go straight until X command. Assumes ForwardUntilXStart has been issued

Parameters
none
Returns
true if done or error, false if still running ok

◆ ForwardUntilY()

uint32_t ForwardUntilY ( int32_t  desiredY)

Forward Until Y goal.

Odometry command to Go straight until Y goal has been reached. This routine will run until goal is met.

Parameters
desiredYdesired Y position in units of 0.0001cm
Returns
0 for success, nonzero is failure (crash=bump sensor or 0xFF=going wrong way)

◆ ForwardUntilYStart()

void ForwardUntilYStart ( int32_t  thedesiredY)

start going Forward Until Y

Odometry command to Go straight until Y goal has been reached. This routine will start the command, but return immediately

Parameters
thedesiredYdesired Y position in units of 0.0001cm
Returns
none

◆ ForwardUntilYStatus()

uint32_t ForwardUntilYStatus ( void  )

check status of Forward Until Y command

Odometry command to check status of Go straight until Y command. Assumes ForwardUntilYStart has been issued

Parameters
none
Returns
true if done or error, false if still running ok

◆ FuzzyChar()

char FuzzyChar ( fuz_t  fuz)

convert fuzzy variable to ASCII character

Fuzzy logic display helper function return 'a' + (25*fuz)/255;

Parameters
fuzis a fuzzy variable having values from 0(false) to 255(true)
Returns
ASCII character from 'a' to 'z'

◆ ifft()

void ifft ( complex_t v,
int  n,
complex_t tmp 
)

Inverse fft.

discrete Inverse Fast Fourier Transform, Converts frequency to time domain
Assume the input is complex data with components k=0 to n-1
Index 0 <= k < n-1 complex components of frequency f=k/fs
E.g., k=0 represents the DC component of the input
Place n complex values into the array v
Typically the index n/2 <= k < n are complex conjugates of the first half
Call ifft() and the results are returned back in array v
If the input is real only, then the transform will contain

Parameters
varray of input data in complex form
nsize of the two arrays 2, 4, 8, ..., 2048
tmptemporary array of data in complex form
Returns
none
Note
n is a power of two from 2 to 2048

◆ LeftRightFuzzification()

fuz_t LeftRightFuzzification ( int32_t  crisp,
const int32_t  MIN,
const int32_t  LEFT,
const int32_t  RIGHT,
const int32_t  MAX 
)

Fuzzification.

Fuzzy logic fuzzification, converting crisp input to fuzzy variable.
If crisp is less than MIN, then fuzzy is false.
If crisp is between MIN and LEFT, then fuzzy is linear.
If crisp is between LEFT and RIGHT, then fuzzy is true.
If crisp is between RIGHT and max, then fuzzy is linear.
If crisp is greater than MAX, then fuzzy is false.
255
|.................... -—
|................. / ......
|.............. / ........... \
|........... / ................. \
|........ / ....................... \
|-----— ...........................------—
0.....MIN ... LEFT RIGHT.... MAX

Note
Constants must be ordered: MIN<LEFT<RIGHT<MAX. Constants must not be equal.
Parameters
crispis a crisp input
MINis threshold value for the crisp input
LEFTis a second threshold value for the crisp input
RIGHTis a third threshold value for the crisp input
MAXis a fourth threshold value for the crisp input
Returns
fuzzy value

◆ Mag1()

int32_t Mag1 ( void  )

magnitude of the first frequency

Calculate magnitude of the first frequency

Parameters
none
Returns
magnitude at frequency f1

◆ Mag2()

int32_t Mag2 ( void  )

magnitude of the second frequency

Calculate magnitude of the second frequency

Parameters
none
Returns
magnitude at frequency f2

◆ MaxFuzzification()

fuz_t MaxFuzzification ( int32_t  crisp,
const int32_t  MIN,
const int32_t  MAX 
)

Fuzzification.

Fuzzy logic fuzzification, converting crisp input to fuzzy variable.
If crisp is less than MIN, then fuzzy is false.
If crisp is between MIN and MAX, then fuzzy is linear.
If crisp is greater than MAX, then fuzzy is true.
255
|........................------—
|...................... /
|................... /
|................ /
|............. /
|---------—
0..........MIN.......MAX

Note
MIN must be less than MAX
Parameters
crispis a crisp input
MINis threshold value for the crisp input
MAXis another threshold value for the crisp input
Returns
fuzzy value

◆ Median()

int8_t Median ( int8_t  x)

3-wide median filter

3-wide median filter
Includes a 3-deep MACQ of last three samples

Parameters
xnew data sample
Returns
median of the last three samples
Note
1 usec running at 80 MHz

◆ Median3()

int8_t Median3 ( int8_t  u1,
int8_t  u2,
int8_t  u3 
)

3-wide median filter

3-wide median filter

Parameters
u1new data sample
u2new data sample
u3new data sample
Returns
median of u1 u2 u3

◆ Median5()

int8_t Median5 ( int8_t  x)

5-wide median filter

5-wide median filter
Includes a 5-deep MACQ of last five samples

Parameters
xnew data sample
Returns
median of the last five samples
Note
11 usec running at 80 MHz
Warning
Median5 and Median7 use the same MACQ

◆ median5()

uint32_t median5 ( uint32_t  u[5])

5-wide median filter

5-wide median filter

Parameters
uan array of 5 samples
Returns
median of the samples

◆ Median7()

int8_t Median7 ( int8_t  x)

7-wide median filter

7-wide median filter
Includes a 7-deep MACQ of last seven samples

Parameters
xnew data sample
Returns
median of the last seven samples
Note
16 usec running at 80 MHz
Warning
Median5 and Median7 use the same MACQ

◆ min32()

int32_t min32 ( int32_t  n1,
int32_t  n2,
int32_t  n3 
)

minimum

32-bit signed minimum

Parameters
n1is a 32-bit signed number
n2is a 32-bit signed number
n3is a 32-bit signed number
Returns
minimum of n1 n2 n3

◆ MinFuzzification()

fuz_t MinFuzzification ( int32_t  crisp,
const int32_t  MIN,
const int32_t  MAX 
)

Fuzzification.

Fuzzy logic fuzzification, converting crisp input to fuzzy variable.
If crisp is less than MIN, then fuzzy is true.
If crisp is between MIN and MAX, then fuzzy is linear.
If crisp is greater than MAX, then fuzzy is false.
255
|-------—
|........... \
|.............. \
|................. \
|.................... \
|....................... -------—
0..........MIN.......MAX

Note
MIN must be less than MAX. Constants must not be equal.
Parameters
crispis a crisp input
MINis threshold value for the crisp input
MAXis another threshold value for the crisp input
Returns
fuzzy value

◆ NoiseReject()

int32_t NoiseReject ( int32_t  x)

removes random noise from audio signal

Run noise reject filter
Rxx2 is 0 if uncorrelated (noise)
Rxx2 is 128 if correlated (signal)
Rxx2 is -128 if correlated (signal); this does not occur with sound

Parameters
xinput to filter
Returns
output of filter, (Rxx2*x)/128

◆ NoiseReject_Init()

void NoiseReject_Init ( void  )

Initialization of noise reject filter.

Initialization of noise reject filter
compare audio signal with itself two samples ago
Rxx(2) = (1/N) sum{x(n)x(n-2)} in limit as N-> infinity
Approximate infinite sum with IIR filter
Rxx2 = (127*Rxx2 +x(n)x(n-2) )/128

  • K is the attack ratio (how fast it responds)
  • M is the scale
  • t0 = x(n)/32
  • t1 = x(n-1)/32
  • t2 = x(n-2)/32
    Parameters
    none
    Returns
    none

◆ not()

fuz_t not ( fuz_t  u1)

Complement.

Fuzzy logic complement

Parameters
u1is a fuzzy variable having values from 0(false) to 255(true)
Returns
255-u1

◆ Odometry_Get()

void Odometry_Get ( int32_t *  x,
int32_t *  y,
int32_t *  theta 
)

Get the current robot position.

Get the current robot position.

Parameters
xis pointer to store x position of the robot (units of 0.0001cm)
yis pointer to store y position of the robot (units of 0.0001cm)
thetais pointer to store angle (or direction) of the robot (units of 2*pi/16384 radians)
Returns
none
Note
Assumes Odometry_Init() has been called at least once
Typically Odometry_Update() is being called periodically (so LCount and RCount are less than 30)

◆ Odometry_GetAngle()

int32_t Odometry_GetAngle ( void  )

Get theta angle.

Fetch value of the current theta angle of the robot

Parameters
none
Returns
position units of 2*pi/16384 radians

◆ Odometry_GetX()

int32_t Odometry_GetX ( void  )

Get X position.

Fetch value of the current X position of the robot

Parameters
none
Returns
position in units of 0.0001cm

◆ Odometry_GetY()

int32_t Odometry_GetY ( void  )

Get y position.

Fetch value of the current y position of the robot

Parameters
none
Returns
position in units of 0.0001cm

◆ Odometry_Init()

void Odometry_Init ( int32_t  initx,
int32_t  inity,
int32_t  initTheta 
)

Initialize odometry module.

Initialize odometry module by specifying the initial position/angle of the robot. Angles range from (-pi to +pi) signified by -8192 to +8191.

Parameters
initxinitial x position of the robot (units of 0.0001cm)
inityinitial y position of the robot (units of 0.0001cm)
initThetainitial angle of the robot (units of 2*pi/16384 radians)
Returns
none

◆ Odometry_SetPower()

void Odometry_SetPower ( uint32_t  fast,
uint32_t  slow 
)

Set power levels.

Specifies two power levels to use during odometry task, and PWM levels must be between 0 to 14,998. Obviously, the power level must be high enough to move robot

Parameters
fastPWM level for moving forward
slowPWM level for turning
Returns
none

◆ Odometry_Update()

void Odometry_Update ( int32_t  LCount,
int32_t  RCount 
)

Compute new position/angle of the robot.

Inputs are wheel tachometer counts (n counts/rotation), and outputs are private global variable of new position/angle

Parameters
LCountnumber of left wheel tachometer counts from the last update
RCountnumber of right wheel tachometer counts from the last update
Returns
none

◆ or()

fuz_t or ( fuz_t  u1,
fuz_t  u2 
)

Fuzzy or.

Fuzzy logic or

Parameters
u1is a fuzzy variable
u2is a fuzzy variable
Returns
maximum of u1 u2

◆ or3()

fuz_t or3 ( fuz_t  u1,
fuz_t  u2,
fuz_t  u3 
)

Fuzzy or.

Fuzzy logic or

Parameters
u1is a fuzzy variable
u2is a fuzzy variable
u3is a fuzzy variable
Returns
maximum of u1 u2 u3

◆ sin540()

int32_t sin540 ( int32_t  theta)

binary fixed-point sin

binary fixed-point sin****************
e.g., 359.3degrees (2pi radians) theta=539 sin540(539) = -763 (-0.0116)
e.g., 270 degrees (3pi/4 radians) theta=405 sin540(405) = -65536 (-1)
e.g., 180 degrees (pi radians) theta=270 sin540(270) = 0 (0)
e.g., 90 degrees (pi/2 radians) theta=135 sin540(135) = 65536 (+1)
e.g., 45 degrees (pi/4 radians) theta= 67 sin540(67) = 46071 (sqrt(2)/2)
e.g., 0 degrees (0 radians) theta= 0 sin540(0) = 0 (0)

Parameters
theta0 to 539, angle is in units 2*pi/540 = 0.011635528 radians (0 to 2pi)
Returns
-65536 to +65536, fixed point resolution 1/65536

◆ SoftLeftUntilTh()

uint32_t SoftLeftUntilTh ( int32_t  desiredTh)

Soft Left Until Theta.

Odometry command to soft left until theta goal has been reached. This routine will run until goal is met.

Parameters
desiredThdesired theta position in units of 2*pi/16384 radians
Returns
0 for success, nonzero is failure (crash=bump sensor or 0xFF=going wrong way)

◆ SoftLeftUntilThStart()

void SoftLeftUntilThStart ( int32_t  thedesiredTh)

start going Forward Until Y

Odometry command to soft left until theta goal has been reached. This routine will start the command, but return immediately

Parameters
thedesiredThdesired theta position in units of 2*pi/16384 radians
Returns
none

◆ StopUntilBumperTouched()

void StopUntilBumperTouched ( void  )

Stop and wait until bumper touched.

Stop and wait until bumper touched

Parameters
none
Returns
none
Note
uses bump.c

◆ umin32()

uint32_t umin32 ( uint32_t  u1,
uint32_t  u2 
)

minimum

32-bit unsigned minimum

Parameters
u1is a 32-bit unsigned number
u2is a 32-bit unsigned number
Returns
minimum of u1 u2

◆ UpdatePosition()

void UpdatePosition ( void  )

update position

Take wheel counts and update position

Parameters
none
Returns
none
Note
Must be called periodically so wheel counts are 5 to 20. If both wheel counts are routinely below 5, update less frequently. If either wheel count is routinely above 20, update more frequently.

◆ WaitUntilBumperTouched()

void WaitUntilBumperTouched ( void  )

Wait until bumper touched.

Wait until bumper touched

Parameters
none
Returns
none
Note
uses bump.c