This commit is contained in:
2025-07-24 15:31:40 +03:00
parent 133863e47f
commit 8f36f89d7a
10 changed files with 102 additions and 87 deletions

View File

@@ -184,8 +184,8 @@ void chk0(int ncycles){
if(!getPos(&M, NULL)) signals(2);
if(M.X.val || M.Y.val){
WARNX("Mount position isn't @ zero; moving");
double zero = 0.;
Mount.moveTo(&zero, &zero);
coordpair_t zero = {0., 0.};
Mount.moveTo(&zero);
waitmoving(ncycles);
green("Now mount @ zero\n");
}

View File

@@ -92,11 +92,12 @@ int main(int argc, char **argv){
signal(SIGINT, signals); // ctrl+C - quit
signal(SIGQUIT, signals); // ctrl+\ - quit
signal(SIGTSTP, SIG_IGN); // ignore ctrl+Z
double tagx = DEG2RAD(45.) + M.X.val, tagy = DEG2RAD(45.) + M.Y.val;
if(MCC_E_OK != Mount.moveTo(&tagx, &tagy))
coordpair_t tag = {.X = DEG2RAD(45.) + M.X.val, .Y = DEG2RAD(45.) + M.Y.val};
if(MCC_E_OK != Mount.moveTo(&tag))
ERRX("Can't move to 45, 45");
dumpmoving(fcoords, 30., G.Ncycles);
Mount.moveTo(&M.X.val, &M.Y.val);
tag.X = M.X.val; tag.Y = M.Y.val;
Mount.moveTo(&tag);
dumpmoving(fcoords, 30., G.Ncycles);
signals(0);
return 0;

View File

@@ -168,7 +168,8 @@ int main(int argc, char **argv){
// and go back with 7deg/s
move(0., 0., 7.);
// be sure to move @ starting position
Mount.moveTo(&M.X.val, &M.Y.val);
coordpair_t tag = {.X = M.X.val, .Y = M.Y.val};
Mount.moveTo(&tag);
// wait moving ends
pthread_join(dthr, NULL);
signals(0);

View File

@@ -146,24 +146,25 @@ int main(int argc, char **argv){
tagX = 0.; tagY = DEG2RAD(G.amplitude);
}
double t = Mount.currentT(), t0 = t;
double divide = 2., rtagX = -tagX, rtagY = -tagY;
coordpair_t tag = {.X = tagX, .Y = tagY}, rtag = {.X = -tagX, .Y = -tagY};
double divide = 2.;
for(int i = 0; i < G.Nswings; ++i){
Mount.moveTo(&tagX, &tagY);
Mount.moveTo(&tag);
DBG("CMD: %g", Mount.currentT()-t0);
t += G.period / divide;
divide = 1.;
waithalf(t);
DBG("Moved to +, t=%g", t-t0);
DBG("CMD: %g", Mount.currentT()-t0);
Mount.moveTo(&rtagX, &rtagY);
Mount.moveTo(&rtag);
t += G.period;
waithalf(t);
DBG("Moved to -, t=%g", t-t0);
DBG("CMD: %g", Mount.currentT()-t0);
}
double zero = 0.;
tag = (coordpair_t){.X = 0., .Y = 0.};
// be sure to move @ 0,0
Mount.moveTo(&zero, &zero);
Mount.moveTo(&tag);
// wait moving ends
pthread_join(dthr, NULL);
#undef SCMD

View File

@@ -88,8 +88,8 @@ int main(int _U_ argc, char _U_ **argv){
return 1;
}
if(MCC_E_OK != Mount.init(Config)) ERRX("Can't init mount");
coordval_pair_t M;
if(!getPos(&M, NULL)) ERRX("Can't get current position");
coordval_pair_t M, E;
if(!getPos(&M, &E)) ERRX("Can't get current position");
if(G.coordsoutput){
if(!G.wait) green("When logging I should wait until moving ends; added '-w'");
G.wait = 1;
@@ -100,28 +100,27 @@ int main(int _U_ argc, char _U_ **argv){
logmnt(fcoords, NULL);
if(pthread_create(&dthr, NULL, dumping, NULL)) ERRX("Can't run dump thread");
}
printf("Mount position: X=%g, Y=%g\n", RAD2DEG(M.X.val), RAD2DEG(M.Y.val));
M.X.val = RAD2DEG(M.X.val);
M.Y.val = RAD2DEG(M.Y.val);
printf("Mount position: X=%g, Y=%g; encoders: X=%g, Y=%g\n", M.X.val, M.Y.val,
RAD2DEG(E.X.val), RAD2DEG(E.Y.val));
if(isnan(G.X) && isnan(G.Y)) goto out;
double *xtag = NULL, *ytag = NULL, xr, yr;
double _7deg = RAD2DEG(7.);
if(!isnan(G.X)){
xr = DEG2RAD(G.X);
if(G.relative) xr += M.X.val;
xtag = &xr;
// set max speed
Mount.setSpeed(&_7deg, NULL);
coordpair_t tag;
if(isnan(G.X)){
if(G.relative) G.X = 0.;
else G.X = M.X.val;
}
if(!isnan(G.Y)){
yr = DEG2RAD(G.Y);
if(G.relative) yr += M.Y.val;
ytag = &yr;
Mount.setSpeed(NULL, &_7deg);
if(isnan(G.Y)){
if(G.relative) G.Y = 0.;
else G.Y = M.Y.val;
}
printf("Moving to ");
if(xtag) printf("X=%gdeg ", G.X);
if(ytag) printf("Y=%gdeg", G.Y);
printf("\n");
Mount.moveTo(xtag, ytag);
if(G.relative){
G.X += M.X.val;
G.Y += M.Y.val;
}
printf("Moving to X=%gdeg, Y=%gdeg\n", G.X, G.Y);
tag.X = DEG2RAD(G.X); tag.Y = DEG2RAD(G.Y);
Mount.moveTo(&tag);
if(G.wait){
sleep(1);
waitmoving(G.Ncycles);