Im trying to start learning how to code an Autonomous. using v5, im simply just trying to have my robot drive back then forward again. But all it does is jerk back just a tad, i believe its trying to run both at the same time, i may be mistaken. Any and all help is appreciated.
while (true){
FLDrv.startRotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
BLDrv.startRotateTo(108,rotationUnits::deg,500,velocityUnits::pct);
FRDrv.startRotateTo(108,rotationUnits::deg,500,velocityUnits::pct);
BRDrv.startRotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
task::sleep(1000);
FLDrv.startRotateTo(108,rotationUnits::deg,500,velocityUnits::pct);
BLDrv.startRotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
FRDrv.startRotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
BRDrv.startRotateTo(108,rotationUnits::deg,500,velocityUnits::pct);
}
Jonah9623:
Im trying to start learning how to code an Autonomous. using v5, im simply just trying to have my robot drive back then forward again. But all it does is jerk back just a tad, i believe its trying to run both at the same time, i may be mistaken. Any and all help is appreciated.
while (true){
FLDrv.startRotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
BLDrv.startRotateTo(108,rotationUnits::deg,500,velocityUnits::pct);
FRDrv.startRotateTo(108,rotationUnits::deg,500,velocityUnits::pct);
BRDrv.startRotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
task::sleep(1000);
FLDrv.startRotateTo(108,rotationUnits::deg,500,velocityUnits::pct);
BLDrv.startRotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
FRDrv.startRotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
BRDrv.startRotateTo(108,rotationUnits::deg,500,velocityUnits::pct);
}
You are correct. Startrotateto doesn’t wait for it to finish before going to the next line. By using rotate to you can make it wait
FLDrv.startRotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
BLDrv.rotateTo(108,rotationUnits::deg,500,velocityUnits::pct,true);
This will force the program to wait for this motor to finish before continuing
DanDanrevolution:
You are correct. Startrotateto doesn’t wait for it to finish before going to the next line. By using rotate to you can make it wait
FLDrv.startRotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
BLDrv.rotateTo(108,rotationUnits::deg,500,velocityUnits::pct,true);
This will force the program to wait for this motor to finish before continuing
so this should do what i want?
FLDrv.startRotateTo(-1008,rotationUnits::deg,500,velocityUnits::pct);
BLDrv.rotateTo(1008,rotationUnits::deg,500,velocityUnits::pct);
FRDrv.rotateTo(1008,rotationUnits::deg,500,velocityUnits::pct);
BRDrv.rotateTo(-1008,rotationUnits::deg,500,velocityUnits::pct);
task::sleep(1000);
FLDrv.rotateTo(1008,rotationUnits::deg,500,velocityUnits::pct);
BLDrv.rotateTo(-1008,rotationUnits::deg,500,velocityUnits::pct);
FRDrv.rotateTo(-1008,rotationUnits::deg,500,velocityUnits::pct);
BRDrv.rotateTo(1008,rotationUnits::deg,500,velocityUnits::pct);
Jonah9623:
so this should do what i want?
FLDrv.startRotateTo(-1008,rotationUnits::deg,500,velocityUnits::pct);
BLDrv.rotateTo(1008,rotationUnits::deg,500,velocityUnits::pct);
FRDrv.rotateTo(1008,rotationUnits::deg,500,velocityUnits::pct);
BRDrv.rotateTo(-1008,rotationUnits::deg,500,velocityUnits::pct);
task::sleep(1000);
FLDrv.rotateTo(1008,rotationUnits::deg,500,velocityUnits::pct);
BLDrv.rotateTo(-1008,rotationUnits::deg,500,velocityUnits::pct);
FRDrv.rotateTo(-1008,rotationUnits::deg,500,velocityUnits::pct);
BRDrv.rotateTo(1008,rotationUnits::deg,500,velocityUnits::pct);
Not exactly. You would want this.
start rotate to (start rotating)
start rotate to (start rotating)
start rotate to (start rotating)
rotate to (also rotate but don’t continue until this is done)
Normally the first three motors will finish at about the same time as the last. This effectively makes the all of them rotate stop and then rotate the other direction and stop
DanDanrevolution:
Not exactly. You would want to alternate start rotate to and rotate to.
start rotate to (start rotating)
start rotate to (start rotating)
start rotate to (start rotating)
rotate to (also rotate but don’t continue until this is done)
Normally the first three motors will finish at about the same time as the last
i wish for the four wheels in the first segment to go at the same time, and the same for the last four,
alternating like so
FLDrv.startRotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
BLDrv.rotateTo(108,rotationUnits::deg,500,velocityUnits::pct);
FRDrv.startRotateTo(108,rotationUnits::deg,500,velocityUnits::pct);
BRDrv.rotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
task::sleep(1000);
FLDrv.startRotateTo(108,rotationUnits::deg,500,velocityUnits::pct);
BLDrv.rotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
FRDrv.startRotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
BRDrv.rotateTo(108,rotationUnits::deg,500,velocityUnits::pct);
task::sleep(1000);
just results in a very odd left move- right move- left move- right move
Jonah9623:
i wish for the four wheels in the first segment to go at the same time, and the same for the last four,
alternating like so
FLDrv.startRotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
BLDrv.rotateTo(108,rotationUnits::deg,500,velocityUnits::pct);
FRDrv.startRotateTo(108,rotationUnits::deg,500,velocityUnits::pct);
BRDrv.rotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
task::sleep(1000);
FLDrv.startRotateTo(108,rotationUnits::deg,500,velocityUnits::pct);
BLDrv.rotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
FRDrv.startRotateTo(-108,rotationUnits::deg,500,velocityUnits::pct);
BRDrv.rotateTo(108,rotationUnits::deg,500,velocityUnits::pct);
task::sleep(1000);
just results in a very odd left move- right move- left move- right move
That is why you only want the last one to be a rotate to.
I didn’t realise you were doing a 4 motor drive this would be what you want
start rotate to (start rotating)
start rotate to (start rotating)
start rotate to (start rotating)
rotate to (also rotate but don’t continue until this is done)
Normally the first three motors will finish at about the same time as the last. This effectively makes the all of them rotate stop and then rotate the other direction and stop at the same time.