So by all logic, this basic tank drive program should be working. However, only the front two motors move, and the front left is inverted. I have tried reversing the power, but this does nothing as it seems my programs do not update when i download them. What am I doing wrong here?
code for driver:
void setDrive(int left, int right){
FR = right;
FL = left;
BR = right;
BL = left;
}
void setDriveMotors(){
int leftJoystick = controller1.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
int rightJoystick = controller1.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y);
if(abs(leftJoystick) < 10)
leftJoystick = 0;
if(abs(rightJoystick) < 10)
rightJoystick = 0;
setDrive(leftJoystick, rightJoystick);
}
PR13ST
March 21, 2020, 5:55am
2
Your leftJoystick and rightJoystick variable types have to be float or double instead of int.
I changed them, but now no motors move at all
rpm
March 21, 2020, 4:24pm
4
what does your motor constructor look like?
pros::Motor::Motor ( const std::uint8_t port,
const pros::motor_gearset_e_t gearset,
const bool reverse,
const pros::motor_encoder_units_e_t encoder_units )
the overload operator (not a fan of using it) is an int8_t with a range -127 to 127,
https://pros.cs.purdue.edu/v5/api/cpp/motors.html#operator-overloads
but int should work.
you can also add this to see what values are getting to setDrive
char mystr[14];
sprintf(mystr,"L=%d R=%d",leftJoystick,rightJoystick );
controller1.setText(0,0,mystr);
just make sure you have at least 50ms of delay in your loop
Is there a pros::delay(xx); in your opcontrol while loop?
Are your motors being driven anywhere else.
2 Likes