My autonomous runs great until the driveToPoint function by okapilib. The robot drives to the first point and then it just freezes where it is at in the program. It doesn’t run the next print statement but it runs the print statement before the driveToPoint. Does anybody know what my problem is?
void autonomous() {//after start comp
chassis->setState({0_in, 0_in, 0_deg});//reset
flipOut();
strafe(11);
intakeMoveVoltage(12000);
rollerMoveVoltage(12000);
pros::c::lcd_print(1 , "First Move Started");
chassis->driveToPoint({34_in, 10_in});
pros::c::lcd_print(1 , "First Move Completed");
chassis->driveToPoint({50_in, 0_in});
pros::c::lcd_print(2 , "Second Move Completed");
flywheelMoveVoltage(12000);
pros::delay(2000);
intakeMoveVoltage(0);
rollerMoveVoltage(0);
flywheelMoveVoltage(0);
}
Is that the full parameters for driveToPoint? The okapilib documentation says that you need a boolean to indicate whether or not it is driving to the point backwards.
I think it should look something like: chassis->driveToPoint(34_in, false, 10_in);
link to the documentation: okapi::DefaultOdomChassisController class | OkapiLib A PROS library for programming VEX robots
Let me know if this helps you!
I realized another problem could be that you are trying to print new text onto an already filled line, and the computer may not like that, so it kills the action immediately. Perhaps either clear that line or put the pros::c::lcd_print(2 , "First Move Completed");
on line 3 (as I did so for you)? I am not sure, but this could be another fix for the issue.
This didn’t work but thanks for the response!
My guess is that the PID that controls the driveToPoint goes close to the point, and it gets so close that it has super small values being inputted to the motors. Then the command is still running, but the motors aren’t strong enough to keep moving the robot and it doesn’t move to the point, resulting in the robot being stuck, sending small values to the motors, but not getting a response.
I would go through and tune the PID variables if you haven’t already.
2 Likes
Thanks I’ll try I’ll test that out right now!
My custom strafe function was causing problems and when I took it out everything worked. Thanks for all the help!
4 Likes