Still trynna work my autonomous lol

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 :slight_smile:

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);

1 Like

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.

2 Likes

I think they mean rotations. But idk for sure

1 Like

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.
1 Like

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();
}
4 Likes

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

2 Likes

oooooooooooooo, thank you!