Thoughts on why function won't fully execute when called from button.pressing()

Hopefully this is an easy one… for some reason when drive2Target is evoked by the controller the robot only jerks - does nothing. Apparently it’s not completing b/c it seems 2b locking up the task.

} else if (Controller1.ButtonR1.pressing()) { 
  drive2Target(dist2Cube);

The function works when called from auton:

void drive2Target(double target) { // drive by spin

  wait(200,msec);
  double deg2target = (dist_mm - target - 40) / 0.866666;
  
  rDrive(deg2target, deg2target, Dist.distance(vex::distanceUnits::mm)/target * 8 ,Dist.distance(vex::distanceUnits::mm)/target * 8 , 1);

} // end drive2Target

rDrive does not seem to be a built in function. Can you show us its code?

1 Like

sure! I know f() works b/c it’s called from other buttons…

void rDrive(double lDeg, double rDeg, double l, double r, bool b) { // drive by relative distance
  wait(0.2, seconds);   //let robot settle
  rDeg = rDeg * -1;
  L_Drive.rotateFor(lDeg * adjField, vex::rotationUnits::deg, l, vex::velocityUnits::pct, false);
  R_Drive.rotateFor(rDeg * adjField, vex::rotationUnits::deg, r, vex::velocityUnits::pct, b);
} // end rDrive

the rDeg is reversed b/c of a weird thing we’ve wrestled w/V5 in the past. Hoping new firmware/code will ‘fix’ this…