/*   @(#) $Header: go2coord.h,v  abrown Exp $
 * Author:
 *	"Allen Brown" http://brown.armoredpenguin.com/~abrown/contact.html
 * Description:
 *   Header file for navigation program.
 *
 * Copyright (C) 2006,2007,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 GO2COORD_H
  #define GO2COORD_H

  #include "varsizes.h"

// ----------------------------------------------------------
  void *go2coord_new( int16 *power_left, int16 *power_right );
  // We need pointers to the variables where the motor power
  // is controlled.  This function returns a pointer to
  // the object.  All calls to go2coord_target() and go2coord_update()
  // must provide this object pointer as the first parameter.
// ----------------------------------------------------------
  void go2coord_target( void* go2_data, int32 x_target, int32 y_target,
			int16 err_dist, int16 err_heading,
			int16 power_fast, int16 power_slow,
			int16 power_reverse);
  // The target is the coordinates where we are sending the robot.
  // Err is how much slop allowed in the x,y,heading.  Too small and
  //  the robot will not know it's arrived.  Too large and it's path
  //  will be sloppy.  You will need to experiment.
  // power_* are the values to apply to power_left,power_right.
  //  These will range from -127 to 127.  In particular, power_slow
  //  is the number to apply to the motor which is ahead to allow
  //  the other side to catch up.
// ----------------------------------------------------------
  int16 go2coord_update( void* go2_data, int32 x_curr, int32 y_curr,
			 int16 heading_curr );
  // x_curr and y_curr are the current coordinate of the robot.
  // Typically these will be values returned by a call to navigate_xy().
  // heading_curr is the current heading.  Typically returned by
  // navigate_heading().
  // All of these parameters must be in the same units as the target
  // and err parameters given to go2coord_target() above.
// ----------------------------------------------------------
// go2coord_update() return values:
#define GO2PLEFT 1	// Pirouette left.
#define GO2PRIGHT 2	// Pirouette right.
#define GO2SLEFT 3	// Steer left.
#define GO2SRIGHT 4	// Steer right.
#define GO2DLEFT 5	// Drift left.  Power straight.
#define GO2DRIGHT 6	// Drift right.  Power straight.
#define GO2STRAIGHT 7	// Straight ahead.
#define GO2DONE 0	// Done!
#define GO2ERROR -1	// Something seriously wrong.
// ----------------------------------------------------------
#endif
/*
 * $Log: go2coord.h,v $
 * Revision 1.2  2006/03/05 21:02:59  abrown
 * go2coord_update(): Recompute target heading each time.  Check for
 * success before testing for corrections.  Major rewrite of the test data.
 *
 * Revision 1.1  2006/02/24 02:07:41  abrown
 * Given navigation data, this controls the robot to go to coordinates on field.
 *
 */

