Template for PrimitivesIndex

Overview

The goX.tea file included in the aGarcia subdirectory of the Garcia download is a template for a TEA file that implements a primitive on the Moto 1.0 processor.  This file doesn't actually implement a task.  Instead it just illustrates the common file structure and can be used as a starting point if a user wishes to write a custom primitive.  It is also informative if a user wishes to modify an existing primitive.  When reading this page, it is helpful to have the goX.tea open in a text editor and follow along in the code.

File Structure

At the top of the file is an include statement for the gCommon.tea file.  Next, masks are defined for sensors pairs to be enabled by the primitive.  The template creates a mask for all sensor pairs.  A dummy execute routine shows where a user should put a subroutine to do the actual work.  Finally, the main routine does all the initialization, calls the execute routine, and performs clean-up tasks.

The Main Routine

This routine must return an int that is one of the supported error codes found in the aGarciaDefs.tea file.  Input may be defined by the user.  This example template takes only one input parameter.  Prior to any other work, the main routine can initialize default velocity and acceleration parameters if desired.

Based on the input, the primitive can begin execution or go straight to clean up.  For example, a primitive that is told to move a distance of 0 doesn't have to do anything at all and can simply go straight to the clean-up tasks at the end of the routine.

If the input is valid, the primitive can configure the monitors to check for the desired end conditions and enable the desired pairs of sensors.  Before doing any motion, the primitive must clear any old error result and re-enable the monitors.  A pause will permit any network traffic and commands to be processed properly before attempting a motion.

Once a motion is complete, the primitive can turn off the sensors it is not using and disable the monitors.  The final step is to return the status result of the primitive.  When running the Garcia API on a host computer, the primitive simply exits and returns the status result.  When running primitives as subroutines in a multitasking TEA application within the robot itself, the status result must also be passed back to the user's calling routine.  This will be performed by the final aMulti_Signal subroutine call.


version: 1.0, build 80903
© Copyright 1994-2008 Acroname, Inc., Boulder, Colorado.  All rights reserved.