/*-=-=-=-=-=-=-=-=-=-=-=- 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.		    *
 *									    *
 *-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
#ifndef _POTCAL_H_
#define _POTCAL_H_

/* control structure used by monitor function to estimate position from
   continuous potentiometer readings.
 */

#include "../h/maxjnts.h"

typedef struct {
	int n;			/* number of samples */
	int spurious;		/* number of spurious datams */
	double sumEnc;		/* sum of encoder values */
	double sumPot;		/* sum of pot values */
	double sumEncEnc;	/* sum of encoder values squared */
	double sumEncPot;	/* sum of encoder values times pot values */
	int firstEnc;		/* first encoder value */
	int lastEnc;		/* last encoder value */
} LINE_DATA;

typedef struct {
	/* info set by the planning task */

	int initialize;		/* initialization flag */
	int jntSelect;		/* mask selecting joints to sample */
	int sampleStart[MAXJNTS]; /* sampling start point */
	int sampleStop[MAXJNTS]; /* sampling stop point */
	int setCalibMode;	/* set calibration mode when sampling done */
	int testMode;		/* use fake pot data for testing */

	/* info set by the montior function */

	int sampling;		/* mask saying who is being sampled */
	int complete;		/* mask saying when sampling is complete */
	LINE_DATA data[MAXJNTS];/* data for estimating pot/enc line */
} POTCAL;	

#endif
