WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
BaeUtilities.cpp File Reference

Utility functions. More...

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdarg.h>
#include "Vision/BaeUtilities.h"
#include "Servo.h"
#include "Timer.h"

Macros

#define PI   3.14159265358979
 

Functions

void SetDebugFlag (DebugOutputType flag)
 Set the debug flag to print to screen, file on cRIO, both or neither. More...
 
void dprintf (const char *tempString,...)
 Debug print to a file and/or a terminal window. More...
 
double RangeToNormalized (double position, int range)
 Normalizes a value in a range, used for drive input. More...
 
float NormalizeToRange (float normalizedValue, float minRange, float maxRange)
 Convert a normalized value to the corresponding value in a range. More...
 
float NormalizeToRange (float normalizedValue)
 
void ShowActivity (char *fmt,...)
 Displays an activity indicator to console. More...
 
double SinPosition (double *period, double sinStart)
 Calculate sine wave increments (-1.0 to 1.0). More...
 
double ElapsedTime (double startTime)
 Find the elapsed time since a specified time. More...
 
void panInit ()
 Initialize pan parameters. More...
 
void panInit (double period)
 
void panForTarget (Servo *panServo)
 Move the horizontal servo back and forth. More...
 
void panForTarget (Servo *panServo, double sinStart)
 
int processFile (char *inputFile, char *outputString, int lineNumber)
 Read a file and return non-comment output string. More...
 
int emptyString (char *string)
 Ignore empty string. More...
 
void stripString (char *string)
 Remove special characters from string. More...
 

Detailed Description

Utility functions.

Function Documentation

void dprintf ( const char *  tempString,
  ... 
)

Debug print to a file and/or a terminal window.

Call like you would call printf. Set functionName in the function if you want the correct function name to print out. The file line number will also be printed.

Parameters
tempStringThe format string.
double ElapsedTime ( double  startTime)

Find the elapsed time since a specified time.

Parameters
startTimeThe starting time
Returns
How long it has been since the starting time
int emptyString ( char *  string)

Ignore empty string.

Parameters
stringto check if empty
float NormalizeToRange ( float  normalizedValue,
float  minRange,
float  maxRange 
)

Convert a normalized value to the corresponding value in a range.

This is used to convert normalized values to the servo command range.

Parameters
normalizedValueThe normalized value (in the -1 to +1 range)
minRangeThe minimum of the range (0 is default)
maxRangeThe maximum of the range (1 is default)
Returns
The value in the range corresponding to the input normalized value
void panForTarget ( Servo panServo)

Move the horizontal servo back and forth.

Parameters
panServoThe servo object to move
sinStartThe position on the sine wave to begin the pan
void panInit ( )

Initialize pan parameters.

Parameters
periodThe number of seconds to complete one pan
int processFile ( char *  inputFile,
char *  outputString,
int  lineNumber 
)

Read a file and return non-comment output string.

Call the first time with 0 lineNumber to get the number of lines to read Then call with each lineNumber to get one camera parameter. There should be one property=value entry on each line, i.e. "exposure=auto"

Parameters
inputFilefilename to read
outputStringone string
lineNumberif 0, return number of lines; else return that line number
Returns
int number of lines or -1 if error
double RangeToNormalized ( double  position,
int  range 
)

Normalizes a value in a range, used for drive input.

Parameters
positionThe position in the range, starting at 0
rangeThe size of the range that position is in
Returns
The normalized position from -1 to +1
void SetDebugFlag ( DebugOutputType  flag)

Set the debug flag to print to screen, file on cRIO, both or neither.

Parameters
tempStringThe format string.
void ShowActivity ( char *  fmt,
  ... 
)

Displays an activity indicator to console.

Call this function like you would call printf.

Parameters
fmtThe format string
double SinPosition ( double *  period,
double  sinStart 
)

Calculate sine wave increments (-1.0 to 1.0).

The first time this is called, it sets up the time increment. Subsequent calls will give values along the sine wave depending on current time. If the wave is stopped and restarted, it must be reinitialized with a new "first call".

Parameters
periodlength of time to complete a complete wave
sinStartWhere to start the sine wave (0.0 = 2 pi, pi/2 = 1.0, etc.)
void stripString ( char *  string)

Remove special characters from string.

Parameters
stringto process