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"
|
#define | PI 3.14159265358979 |
|
|
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...
|
|
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
-
tempString | The format string. |
double ElapsedTime |
( |
double |
startTime | ) |
|
Find the elapsed time since a specified time.
- Parameters
-
startTime | The starting time |
- Returns
- How long it has been since the starting time
int emptyString |
( |
char * |
string | ) |
|
Ignore empty string.
- Parameters
-
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
-
normalizedValue | The normalized value (in the -1 to +1 range) |
minRange | The minimum of the range (0 is default) |
maxRange | The 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
-
panServo | The servo object to move |
sinStart | The position on the sine wave to begin the pan |
Initialize pan parameters.
- Parameters
-
period | The 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
-
inputFile | filename to read |
outputString | one string |
lineNumber | if 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
-
position | The position in the range, starting at 0 |
range | The 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
-
tempString | The format string. |
void ShowActivity |
( |
char * |
fmt, |
|
|
|
... |
|
) |
| |
Displays an activity indicator to console.
Call this function like you would call printf.
- Parameters
-
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
-
period | length of time to complete a complete wave |
sinStart | Where to start the sine wave (0.0 = 2 pi, pi/2 = 1.0, etc.) |
void stripString |
( |
char * |
string | ) |
|
Remove special characters from string.
- Parameters
-