V5 rotation sensors

Hey I am having an issue with the rotation sensors and there is no references online so if you can help my code is below. I used this code for quads and it was fine until I changed it from quads to rotation sensors.

vex::rotation EncoderLeft = vex::rotation(vex::PORT18);

vex::rotation EncoderRight = vex::rotation(vex::PORT14);

void drivewintakes(double rotations, double intakesvalue){

Intake1.setVelocity(20, percentUnits::pct);

Intake2.setVelocity(200, percentUnits::pct);

Indexer1.setVelocity(intakesvalue, percentUnits::pct);

Intake1.spin(directionType::rev);

Intake2.spin(directionType::rev);

Indexer1.spin(directionType::fwd);

while(EncoderLeft < rotations && EncoderRight < rotations){

LM1.spinFor(-1*rotations, turns, 50, velocityUnits::pct,false);

LM2.spinFor(-1*rotations, turns, 50, velocityUnits::pct,false);

RM1.spinFor(rotations, turns, 50, velocityUnits::pct,false);

RM2.spinFor(rotations, turns, 50, velocityUnits::pct);

}

task::sleep(50);

Intake1.stop();

Intake2.stop();

Indexer1.stop(brake);

LM1.stop(coast);

LM2.stop(coast);

RM1.stop(coast);

RM2.stop(coast);

}
void drivewintakes(double rotations, double intakesvalue){

Intake1.setVelocity(20, percentUnits::pct);

Intake2.setVelocity(200, percentUnits::pct);

Indexer1.setVelocity(intakesvalue, percentUnits::pct);

Intake1.spin(directionType::rev);

Intake2.spin(directionType::rev);

Indexer1.spin(directionType::fwd);

while(EncoderLeft < rotations && EncoderRight < rotations){

LM1.spinFor(-1*rotations, turns, 50, velocityUnits::pct,false);

LM2.spinFor(-1*rotations, turns, 50, velocityUnits::pct,false);

RM1.spinFor(rotations, turns, 50, velocityUnits::pct,false);

RM2.spinFor(rotations, turns, 50, velocityUnits::pct);

}

task::sleep(50);

Intake1.stop();

Intake2.stop();

Indexer1.stop(brake);

LM1.stop(coast);

LM2.stop(coast);

RM1.stop(coast);

RM2.stop(coast);

}

Error: Invalid operands to binary expression

Formatted Code:

vex::rotation EncoderLeft = vex::rotation(vex::PORT18);

vex::rotation EncoderRight = vex::rotation(vex::PORT14);

void drivewintakes(double rotations, double intakesvalue){

Intake1.setVelocity(20, percentUnits::pct);

Intake2.setVelocity(200, percentUnits::pct);

Indexer1.setVelocity(intakesvalue, percentUnits::pct);

Intake1.spin(directionType::rev);

Intake2.spin(directionType::rev);

Indexer1.spin(directionType::fwd);

while(EncoderLeft < rotations && EncoderRight < rotations){

LM1.spinFor(-1*rotations, turns, 50, velocityUnits::pct,false);

LM2.spinFor(-1*rotations, turns, 50, velocityUnits::pct,false);

RM1.spinFor(rotations, turns, 50, velocityUnits::pct,false);

RM2.spinFor(rotations, turns, 50, velocityUnits::pct);

}

task::sleep(50);

Intake1.stop();

Intake2.stop();

Indexer1.stop(brake);

LM1.stop(coast);

LM2.stop(coast);

RM1.stop(coast);

RM2.stop(coast);

}
void drivewintakes(double rotations, double intakesvalue){

Intake1.setVelocity(20, percentUnits::pct);

Intake2.setVelocity(200, percentUnits::pct);

Indexer1.setVelocity(intakesvalue, percentUnits::pct);

Intake1.spin(directionType::rev);

Intake2.spin(directionType::rev);

Indexer1.spin(directionType::fwd);

while(EncoderLeft < rotations && EncoderRight < rotations){

LM1.spinFor(-1*rotations, turns, 50, velocityUnits::pct,false);

LM2.spinFor(-1*rotations, turns, 50, velocityUnits::pct,false);

RM1.spinFor(rotations, turns, 50, velocityUnits::pct,false);

RM2.spinFor(rotations, turns, 50, velocityUnits::pct);

}

task::sleep(50);

Intake1.stop();

Intake2.stop();

Indexer1.stop(brake);

LM1.stop(coast);

LM2.stop(coast);

RM1.stop(coast);

RM2.stop(coast);

}

What line does it give you the error for?

Please mention how to format code when you do this.

OP, you can format code by putting ``` above and below the text you want to format.

2 Likes

while(EncoderLeft < rotations && EncoderRight < rotations){

This is the code that give the error

EncoderLeft is the name of the sensor. It doesn’t return a value since it isn’t a method. You would have to say something line EncoderLeft.rotations() in order for it return a value.

1 Like

after that it says that there no member named in vex::rotation

In that case, use EncoderLeft.value();

use position() method. API is here

https://api.vexcode.cloud/v5/html/classvex_1_1rotation.html

1 Like