#include "../h/rccl.h"
#include "../h/rtc.h"
#include "../h/hand.h"
#include "../h/umac.h"

extern struct how how;
extern struct chg chg;
int sensor;

pumatask()
{
	TRSF_PTR z, b1, fing;
	POS_PTR  p1;
	int fingfn();
	int q;

	fing = newtrans("FING",fingfn);
	z = gentr_rot("Z",  0.,  0., 864., zunit, 0.); /* at the base */
	b1 = gentr_rot("B1", 600. , 300., 500., yunit, 180.);

	b1->fn = hold;
	p1 = makeposition("P1" , z, t6, fing, EQ, b1, TL, fing);

	OPEN;
	printf("hand the sensor to the beast\n");
	printf("press return when ready : ");
	getchar();

	CLOSE;
	printf("press return to start : ");
	getchar();
	sensor = adcopen(7);

	movecart(p1, 400, 1500);
	for (; ; ) {
		movecart(p1, 200, 20000);
		waitfor(completed);
		QUERY(q); if (q == 'n') break;
	}
	movejnts(park, 400, 1500);
}

#define CV      .01

fingfn(t)
TRSF_PTR t;
{
	t->p.z = CV * how.adcr[sensor];
}
