I’m a relatively new robotics coach with little programming experience and I need some help assisting a student of mine with his code. Honestly, he is much more capable of coding in Vexcode Pro V5 Text-Based Coding than I am, but he has hit a roadblock.
Details about his bot/code: He is working with a standard clawbot and he has added a vex v5 inertial sensor to the drivetrain. He has successfully worked with the sensor already. Currently, he is working on programming the controller. The code he is currently working on is supposed to get the robot to turn 90 degrees upon pressing the “A” button, raise the class upon pressing the “UP” button, and lower the claw upon pressing the “DOWN” button. The last two functions are working properly, but whenever he presses the “A” button, the robot spins indefinitely.
Here is the code he wrote:
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
while(true){
if(Controller1.ButtonA.pressing()){
Drivetrain.turnFor(right, 90, degrees, 50, velocityUnits::pct);
}
if(Controller1.ButtonUp.pressing()){
armMotor.spinFor(forward, 90,degrees,50,velocityUnits::pct);
}
if(Controller1.ButtonDown.pressing()){
armMotor.spinFor(reverse,90,degrees,50,velocityUnits::pct);
}
}
}
Again, I’ll be honest in stating that he is much more advanced at writing the code than I am (and as a 6th grader at that!). He is also using a Drivetrain.turnFor code, which I am unfamiliar with. When I went to the Robotics training at Carnegie Mellon (3 years ago - and most of that knowledge has faded a bit due to the pandemic), we were coding the drivetrain as individual left and right motors. I thought that might be part of the issue, and recommended he try that route, but he said that would interfere with the internial sensor in some way.
Any assistance at all you can give us in the matter would be greatly appreciated. Thank you in advance!