LibVexBot Documentation

0.4

LibVexBot is an API (Application Program Interface) library for programming Vex robot controllers using SDCC.

The API consists of functions for each logical group of devices, such as analog sensors, digital sensors, LED output devices, motors, timers, etc.

The goal of the library is to make programming Vex robots easier and more organized without sacrificing the near-optimal speed and flexibility of the C language.

LibVexBot can be used to program the Vex under any operating system and hardware that runs SDCC. This includes all major PC operating systems such as Mac (Intel or PowerPC), most Unix systems, and Windows (Cygwin recommended). You can use the editor or IDE of your choice and build the code with the included Makefiles.

The basic format of a LibVexBot program is as follows:

  #include <vexbot.h>

  void    main(void)
  { 
      // Initialize the Vex controller
      vex_init();

      // Set up your robot config here

      // Main loop: Begins in RC (remote control) mode.
      while ( 1 )
      {
          if ( rc_new_data_available() )
          {
              rc_routine();
              if ( condition1 )
                  autonomous_routine1();
              if ( condition2 )
                  autonomous_routine2();
          }
      }
  }

The program begins in remote controlled (RC) mode. The rc_routine() function processes information from the remote control unit and sensors, and controls the motors and servos using the API functions described under the Modules section of this document.

The robot can also operate in autonomous mode, where it is in complete control of itself, and ignores inputs from the RC unit. The robot makes its own decisions based on sensor input or a predefined sequence of actions.

It is highly recommended that you always begin your programs in RC mode, and use some sort of input to trigger autonomous routines. The Vex controller is a dedicated processor, which means that it holds and runs exactly one program. This program begins executing as soon as it is uploaded to the controller. Hence, if your robot runs the autonomous routine immediately, it could take off across the room with the programming cable still attached. How the autonomous routines are triggered is up to you. The RC routine or main program could watch for a particular button or joystick movement on the RC unit, or a sensor such as a push button.


Generated on Sat May 23 08:43:58 2009 for LibVexBot by  doxygen 1.5.8