#ifndef _TEACH_H_
#define _TEACH_H_

/*-=-=-=-=-=-=-=-=-=-=-=- RCCL/RCI Notice of Copyright -=-=-=-=-=-=-=-=-=-=-*
 *									    *
 *	Copyright (C) 1991 by John E. Lloyd.				    *
 *									    *
 *	Information on copyright permissions, as well as a complete	    *
 *	disclaimer of warranty, is given in the file COPYRIGHT.		    *
 *									    *
 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/

/*---------------------------------------------------------------------------
 *
 * DESCRIPTION:	Definitions and data structures used by the "teach"
 *		trajectory generator (which is located in teachCtrl.c).
 * 
 * AUTHOR/DATE:	John Lloyd, sometime after the death of Marcus Aurelius
 *
 * MODIFICATION HISTORY:
 *
 *--------------------------------------------------------------------------*/

#include "../h/robotTypes.h"

/* Different control modes */

#define JOINT_M 1			/* joint mode 			*/
#define FREE_M	2			/* free (zero gravity) mode 	*/
#define TOOL_M  3			/* tool coordinate mode 	*/
#define WORLD_M 4			/* world coordinate mode 	*/
#define COMP_M  5			/* computer mode (used only for */
					/*  teach pendant display)	*/
/* Motion states: */

#define STOPPED		0		/* Stopped (Not moving)		*/
#define TP_MOVE		1		/* Moving under pendant control */
#define CP_MOVE		2		/* Moving from keyboard command */

typedef struct {
	/* Parameter and state variable block used by, and private
	   to, the teach trajectory generator.
	 */
	float angleBaseSpeed[6];    /* nominal joint velocities */
	float trsl_base_speed;	    /* nominal translational velocity */
	float rad_base_speed;	    /* nominal rotational velocity */

	float angle_tick;	    /* speed scale factor that gets */
	float trsl_tick;	    /*  introduced when teach pendant is */
	float rot_tick;		    /*  in "tick" (very slow) mode */

	JNTS diff_angles;	    /* joint angle displacement to target */
	JNTS old_joints;	    /* previous cycle's joint values */
	char locked[6];		    /* joint is not in "free" mode */
	float output_torque[6];	    /* gravity compensated joint torques */
	DRIVEP drvp;		    /* DRIVE parameters to Cartesian target */

	int joint;		    /* joint number or Cartesian DOF */
	int joint_req;		    /* new 'joint' setting from pendant */
	int plus;		    /* direction of travel */
	int plus_req;		    /* new 'plus' setting from pendant */
	int mode;		    /* WORLD, TOOL, JOINT, or FREE */
	int mode_req;		    /* new 'mode' setting from pendant */

	float set_speed;	    /* speed scale setting */
	float set_speed_req;	    /* new 'set_speed' value from pendant */

	int panic_req;		    /* panic button hit on pendant */
	int tick;		    /* very low speed selected */
	int cmove_completed;	    /* FALSE if keyboard move in progress */

	float ctime;		    /* time counter for keyboard move */
	float time1;		    /* time to reach cruise velocity */
	float time2;		    /* time to begin decelerating */
	float time3;		    /* time to end motion */
	float a_rel;		    /* peak accel. divided by distance */
	float v_rel;		    /* peak velocity divided by distance */
    
	int limit_message;	    /* limit stop message sent to pendant */
	unsigned short display_word;/* display message on pendant */
	int last_display_mode;	    /* last mode displayed on pendant */

	float speed;		    /* output speed (ramped for accel) */
	int last_mode;		    /* previous mode setting */
	int block_pendant;	    /* busy ... ignore pendant input */ 
	
	int t6Computed;		    /* true if output T6 value was computed */

} TEACH_BLOCK;

#endif
