/*   @(#) $Header: rollingchassis.h,v  $
 * Author:
 *	"Allen Brown" <abrown@peak.org>
 *
 * Copyright (C) 2008 Allen Brown
 *
 * License:
 *   This program is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU General Public License
 *   as published by the Free Software Foundation; either version 2
 *   of the License, or (at your option) any later version.
 *   
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *   
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the
 *     Free Software Foundation, Inc.,
 *     51 Franklin Street, Fifth Floor,
 *     Boston, MA  02110-1301, USA.
 */
#ifndef rollingchassis_h
  #define rollingchassis_h

  // Action command values
  #define ROLL_GO2XY_S 7
  #define ROLL_GO2XY_G 6
  #define ROLL_HEAD_S 5
  #define ROLL_HEAD_O 4
  #define ROLL_HEAD_G 3
  #define ROLL_STOP 2
  #define ROLL_NOP 1
  #define ROLL_END 0

  // Return Values
  #define ROLL_OK 0
  #define ROLL_ENDED -1
  #define ROLL_ERROR -2

  #include "varsizes.h"
  #include "go2coord2.h"
  #include "API.h"
  typedef struct
  {
    unsigned8 action;
    int32 x_target, y_target;
    int16 heading_target;
    int8 flagval;
  } rolling_row_t;

  //typedef rolling_row_t[ROLLING_SIZE] rolling_array_t;

  /*
   * rollingchassis() uses the go2coord2.c funtions to drive
   *   a robot around.
   * returns: ROLL_OK, ROLL_ERROR, or ROLL_ENDED.
   *   ROLL_ENDED: the listed commands have all been executed.
   *	Command execution will restart at the beginning of the array.
   * array: Command objectives are specified here.  Each row of the
   *	array contains a rolling_row_t struct.  Each struct specifies
   *	one objective for the robot.
   *   array row struct fields:
   *	  action: Action to be taken by the robot. "Action command
   *		values" listed above specifies the specific command
   *		type.  The additional values in the struct (listed
   *		below) qualify that action.
   *	  x_target, y_target: target location for "GO" commands.
   *	  heading_target: target heading for "HEAD" commands.
   *	  flagval: Value returned in the "flag" variable.
   *		See "flag" below.
   * go2pt: Pointer to a go2coord object.  See go2coord2.h.
   *	The user is expected to create this object based on the
   *	instructions listed there.
   * x,y,heading: The location of the robot on the field.
   *	See navigate.h.
   * flag: When any action is executed, the flagval struct
   *	field value is copied to this variable.  This is
   *	useful if you wish to coordinate driving actions
   *	with other actions such as moving a robotic arm.
   */
  int8 rollingchassis(rolling_row_t array[], void *go2pt,
		    int32 x, int32 y, int16 heading, int8 *flag);
#endif
/*
 * $Log: rollingchassis.h,v $
 */

