X drive code problems

Having trouble with out code:
#include “robot-config.h”
vex::brain brain;
vex::motor fr_motor(vex::PORT9, vex::gearSetting::ratio6_1, true);
vex::motor fl_motor(vex::PORT10, vex::gearSetting::ratio6_1, false);
vex::motor bl_motor(vex::PORT8, vex::gearSetting::ratio6_1, false);
vex::motor br_motor(vex::PORT7, vex::gearSetting::ratio6_1,false);
vex::controller con(vex::controllerType::primary);
int main() {
while(true) {
bl_motor.spin(vex::directionType::fwd, con.Axis2.value() + con.Axis4.value() - con.Axis1, vex::velocityUnits::pct);
fl_motor.spin(vex::directionType::fwd, con.Axis2.value() + con.Axis4.value() + con.Axis1, vex::velocityUnits::pct);
br_motor.spin(vex::directionType::fwd, con.Axis2.value() - con.Axis4.value() +con.Axis1, vex::velocityUnits::pct);
fr_motor.spin(vex::directionType::fwd, con.Axis2.value() - con.Axis4.value() - con.Axis1, vex::velocityUnits::pct);
}
}
It says there is an error in the first like with motor bl. Error being “invalid operands to binary expression” Any Ideas?

try move

vex::motor fr_motor(vex::PORT9, vex::gearSetting::ratio6_1, true);
vex::motor fl_motor(vex::PORT10, vex::gearSetting::ratio6_1, false);
vex::motor bl_motor(vex::PORT8, vex::gearSetting::ratio6_1, false);
vex::motor br_motor(vex::PORT7, vex::gearSetting::ratio6_1,false);
vex::controller con(vex::controllerType::primary);

to robot-config.h

you gotta left click on robot-config.h on the left panel of vexcode. Cut and paste from vex.cpp to robot-config.h

con.Axis1 is not a number. You need to call its value method like you do for the other two axes. The error message was complaining that you were trying to do “number plus number minus joystick axis”, which doesn’t match its rules about what can be added and subtracted.

Thank you. Ill give it a go

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.