T-ramp tested, seems like it works fine
This commit is contained in:
@@ -34,12 +34,12 @@ typedef struct{
|
||||
|
||||
static pars G = {
|
||||
.ramptype = "d",
|
||||
.dT = 100000,
|
||||
.dT = 10000,
|
||||
};
|
||||
|
||||
static limits_t limits = {
|
||||
.min = {.coord = -1e6, .speed = 0.1, .accel = 0.1},
|
||||
.max = {.coord = 1e6, .speed = 1e3, .accel = 10.},
|
||||
.max = {.coord = 1e6, .speed = 1e3, .accel = 50.},
|
||||
.jerk = 10.
|
||||
};
|
||||
|
||||
@@ -56,6 +56,7 @@ static int move(moveparam_t *tag){
|
||||
if(!tag) ERRX("move(): needs target");
|
||||
moveparam_t curpos;
|
||||
movestate_t curstate = model->get_state(&curpos);
|
||||
if(curstate == ST_MOVE) printf("Current state: moving; recalculte new parameters\n");
|
||||
if(!move_to(tag)){
|
||||
WARNX("move(): can't move to %g with max speed %g", tag->coord, tag->speed);
|
||||
return FALSE;
|
||||
@@ -91,7 +92,7 @@ int main(int argc, char **argv){
|
||||
if(!coordslog) ERR("Can't open %s", G.xlog);
|
||||
} else coordslog = stdout;
|
||||
if(G.dT < 1) G.dT = 1;
|
||||
fprintf(coordslog, "# time coordinate speed acceleration\n");
|
||||
fprintf(coordslog, "time coordinate speed acceleration\n");
|
||||
ramptype_t ramp = RAMP_AMOUNT;
|
||||
if(*G.ramptype == 'd' || *G.ramptype == 'D') ramp = RAMP_DUMB;
|
||||
else if(*G.ramptype == 't' || *G.ramptype == 'T') ramp = RAMP_TRAPEZIUM;
|
||||
@@ -100,13 +101,22 @@ int main(int argc, char **argv){
|
||||
model = init_moving(ramp, &limits);
|
||||
if(!model) ERRX("Can't init moving model: check parameters");
|
||||
Tstart = nanot();
|
||||
moveparam_t target = {.speed = 100., .coord = 1000};
|
||||
moveparam_t target = {.speed = 10., .coord = 20.};
|
||||
if(move(&target)) monit(0.5);
|
||||
for(int i = 0; i < 10; ++i){
|
||||
target.coord = -target.coord;
|
||||
if(move(&target)) monit(1.);
|
||||
}
|
||||
target.coord = 0.; target.speed = 20.;
|
||||
if(move(&target)) monit(100.);
|
||||
return 0;
|
||||
if(move(&target)) monit(1.);
|
||||
target.speed = 15.;
|
||||
target.coord = 30.;
|
||||
if(move(&target)) monit(1.);
|
||||
target.coord = 0.;
|
||||
if(move(&target)) monit(1.5);
|
||||
target.speed = 500.;
|
||||
if(move(&target)) monit(2.5);
|
||||
target.coord = -100.;
|
||||
if(move(&target)) monit(4.);
|
||||
target.coord = 0.; target.speed = -200.;
|
||||
target.coord = 0.; target.speed = 20.;
|
||||
if(move(&target)) monit(1e6);
|
||||
usleep(5000);
|
||||
fclose(coordslog);
|
||||
|
||||
Reference in New Issue
Block a user