Programming Help!

Hello! We program for V5 in C++ and were looking for some assistance. Sometimes in our autonomous, our intake gets stuck and it’s unable to complete the program. In driver control, we just reverse the intake and it fixes itself. Is there any way to put some kind of “if unable to complete, do this” function in?

It sounds like you are trying to move your intake x rotations but it never reaches that value after it is stuck. The easiest way to fix this is to add a time exit to your loop.

int start = pros::millis();
while (sensorValue < targetValue) {
     /* run intake */
     if (pros::millis() - start < 1000) 
          break;
}
/* stop intake */
1 Like

Thanks, this makes sense! But can you explain the pros::millis command? I’m not used to seeing a pros function, we don’t use C++ pro

I haven’t used this, but I believe motor.setTimeout(1000, timeUnits::msec) will set the motor to do that after 1000 milliseconds.

It’s because the pros namespace is not part of VCS. The equivalent command in VCS or Robot Mesh Studio would be vex::timer::system(). (Though I am unsure if it is a static method in VCS like it is in RMS.)

Oh my bad. I wasn’t sure what system you were using (PROS, RMS, or VCS) so I responded with what I was comfortable with.

No worries! My fault for not specifying