Getting WPILib

Unzip WPILib into C:\WPILib for all the examples to work. When creating projects it is best to refer to the linker, include, and library files from the C:\WPILib directory - that way updating WPILib will update all programs linked with it.

Current version with Vex and FRC 2004-2007 support

Version 20080122

Exposes a few camera functions that will allow users to send their own commands to the camera. Commands are sent to the camera in ASCII mode and T-Packets are received in binary. This is for debugging and allows you to see the robot to camera exchanges by calling SetCameraDebugMode(1). Doing this will make all the CmdToCamera commands echo along with the camera responses. These should work OK, since the functions have been used internally and have just been changed from static to global. So let me know if you have any problems.

The functions are:

unsigned char ResetCameraState(void);
unsigned
char CmdToCamera(const rom char *format, ...);

These functions are part of BuiltIns.h so it doesn't conflict with any existing easyC code.

An example of using the CmdToCamera function is here (taken from WPILib camera module):

static unsigned char SetColor( unsigned char redMin,
   
unsigned char redMax,
   
unsigned char greenMin,
   
unsigned char greenMax,
   
unsigned char blueMin,
   
unsigned char blueMax )
{
       
return CmdToCamera("ST % % % % % %", redMin, redMax, greenMin, greenMax, blueMin, blueMax);
}

The arguments are inserted into the commands as integer strings and sent to the camera. The function returns 1 for success (ACK received from camera) and 0 for failure (timeout or other error). You should reset the camera first, then send whatever commands that are needed, then call StartCamera to get it back in tracking mode.

Version 2007011601

Problems with the automatic build and the file "BuiltIns.h" was missing from previous versions. It's there now.

Version 20070109

This version adds Vex support, functions to control the camera debug modes, built-in support for the 80, 150, and 300 degree/sec Analog Devices gyros with dead band setting functions, graphical display functions when used with the easyC Pro terminal window, and a number of other enhancements. This is the version that is used with easyC Pro.

Version 20061222

This version adds a Vex directory (beta) to the download.

  1. There are a few changes in the function definitions so check out the Builtins.h and UserAPI.h files.
  2. In addition there is a change to the way competition mode works. Calling SetCompetitionMode(mode) with a 0 runs without competition mode and only your main function is called. Calling it with a value of n where n > 0  runs with an autonomous period of n seconds followed by an unlimited operator control period. In this mode, the autonomous period starts when the transmitter is turned on and stops when the transmitter is turned off. The Vex SetCompetitionMode function takes two arguments, the first is the mode (and autonomous period time) and the second argument is the OperatorControlTime.
  3. The radio functions have two ports that correspond to the two receiver ports on the Vex controller.
  4. There are now graphic display functions included that will be documented shortly and will work with the easyC loader.

Please let me know what problems you find. It has been tested with a bunch of the VEX

Version 060218

This version adds the following features to the CMUCam handling:

  1. The camera will now immediately fail initialization if it doesn't receive an acknowledgement after 5 tries. No further camera initialization will be attempted in that case - this makes the startup time if the camera is damaged much faster (about 3 seconds from power up).
  2. There is a new function:

unsigned char GetCameraStatus(void)

that returns a zero if any of the camera initialization fails. This function can be called after any of the camera initialization functions. If you are using EasyC, the function definition is included in BuiltIns.h and you should be sure to include that file.

If you decide to try this version, please post something on ChiefDelphi indicating whether or not it worked for you. In my testing it seems to handle the case of the camera disconnected from the serial adapter or the serial adapter removed from the robot controller.

Version 060207

The only difference between this version and the previous one is the inclusion of the function:

void InitializeCamera(CameraInitializationData *c);

This function allows you to pass the address of a CameraInitializationData structure to set up the camera parameters. The function was always there and available, just missing the definition in the include.

Version 060204

Changed camera capture data functions to have a one second timeout. Whenever a call to capure/copy camera data is made, the code waits 1 second for valid data to arrive. This is only checked prior to the first packet being received and is designed to handle the case where the camera is initialized, started, and a packet captured before one actually arrives. In the previous version it would wait forever for valid data - but if the camera is somehow broken or disabled, then the robot might hang waiting for valid data. If the timeout occurs, zeros will be returned for all camera data - including the packet number.

There was a problem with setting camera servo values where if the middle digit of a 3 digit value was zero, it would not be sent to the camera. This has been fixed.

There are two new functions to read the main and backup battery in 1/100ths of volt. The functions are:

unsigned GetBackupBattery(void)    and

unsigned GetMainBattery(void)

The serial port function names were inadvertently changed in the rush to get the code out. They are now names as published in the documentation. If you are using the camera and no explicit serial port code this should not effect anything you are doing.

And as always, please let me know if you find something wrong.

Version 060122

Modified Motor function to be aware of the deadband in the Victor 884 speed controllers. The Victor 884 has a built-in deadband that runs from 117-137 of PWM values sent to it. The Motor function will now take values from 0-127 and 0-(-127) and scale them to fit into the actual working range of the Victor which is 23-116 and 138-232. This means that values sent to the motors will tend to be more continuous without the discontinuity in the range. The Motor function is used by Drive and Motors so if you use these functions, the change will be seen in those functions as well.

There is another function added, unsignd char GetPacketNumber(void) that returns the OI packet number. Each time a new packet is received from the master processor this number is incremented. It is only a 8 bit value so it wraps around every 256 packets, but it provides an indication of when there is new data received.

Version 060119

Added the compressor support with background checking of the pressure switch. Call:

InitPressureSwitch(unsigned char pressureSwitchPort, unsigned char relayPort);

where pressureSwitchPort has the pressure switch connected and is checked every 500ms. The relayPort is turned on/forward if the pressure switch is closed indicating low pressure otherwise it is turned off. This should only be called once - usually in the Initialize function and it will operate for the rest of the program.

 

Orignal Version - as released initially.