So here we go again. I want to figure out this time how to make my autonomous (which is by turns not time) be able to go ex. 2.5 turns and not have to be a whole number ex. 2.
my void:
void goForward(int x){
LF.startRotateFor(x,turns);
RF.startRotateFor(x,turns);
RB.startRotateFor(x,turns);
LB.rotateFor(x,turns);
LF.stop();
RF.stop();
LB.stop();
}
my autonomous rn:
Competition.autonomous(autonomous);
forwardPick(2);
change the (int x) to a (float x)
then in the main program how would I put it so it can go as ex 2.5 turns?
wouldnāt you just write
goForward(2.5)
i dont really get what your asking sorry
when I type in 2.5 is says "implicit conversacion from ādoubleā to āintā changes value from 2.5 to 2
sorry iāve never really used VEXcode blocks specifically so donāt know if what iāve tried doesnāt work.
here is the API doc for RotateFor:
You need to specify your units in this case ārevā
RightMotor.rotateFor(RevolutionsToMove, rotationUnits::rev);
Iām using vex code text but aight
yeah revolutions to move is not a command
Sorry you wanted startRotateFor which also takes a parameter for units that can be ārevā. Did i misunderstand what you mean by āturnsā?
also note that the ārotationā parameter is a ādoubleā not a float.
I think they mean rotations. But idk for sure
by turns I mean rotations
Then you need to tell the function rotationUnits::rev
From the API page
vex.rotationUnits
Enum
The measurement units for rotation values.
Name | Description |
---|---|
deg | A rotation unit that is measured in degrees. |
rev | A rotation unit that is measured in revolutions. |
raw | A rotation unit that is measured in raw data form. |
can you make an example of it?
Typically the left drive motors are normal rotation and the right drive motors are reversed rotation. So you would have defined setReversed(true) on the right side motors. The first three motor calls use startRotateFor b/c they are non-blocking and allow the subsequent function calls to proceed. The last rotateFor call is blocking so that motor has to finish its number of revolutions before it allows program execution to continue. Then all the motors stop.
Standard disclaimer, I donāt program in VexCode and this code is untested but should be pretty close to working.
void goForward (double revs) {
LF.startRotateFor(revs, rotationUnits::rev);
LB.startRotateFor(revs, rotationUnits::rev));
RF.startRotateFor(revs, rotationUnits::rev));
RB.RotateFor(revs, rotationUnits::rev));
LF.stop();
LB.stop();
RF.stop();
RB.stop();
}
I still have the same problem, I always knew how to make it by turns my problem is that I want to be able to do 1 turn and a half.
what are revolutions in this case, are they full 360 degree turns?
They are full 360 turns of the motor.
what @voss.robert said plus
1 rev = 360 deg = ā¦
1800 ticks/rev with 36:1 gears
900 ticks/rev with 18:1 gears
300 ticks/rev with 6:1 gears
oooooooooooooo, thank you!