Hi, our team has been having troubles with our autonomous where we use functions to make it so that all the motors are spinning at the same time and we usethe startRotateTo command. But when we try running auto and we have multiple fucntions, it only runs the first one and stops running.
One thing I’m noticing right away is that you’re using
startRotateTo()
without waiting for a motor to reach the desired position, which means that the setpoints that you set in
drivefwd()
will be overwritten almost immediately by those in
drivebwd()
. If I’m understanding what your possible intentions are, you’ll want to wait until the motors reach their position in both
drivefwd()
and
drivebwd()
before your code continues. In that case, you’ll want to use the rotateTo() method whenever you want your code to wait for a single motor (in this case, you’d probably put it on Motor4, and your code would wait for Motor4 to reach its setpoint)
Adding to that explanation… As @epedemont said, but more so with drivebwd(). Your program ends immediately after drivebwd() is called. So you set the motors to head somewhere and immediately turn them off, well before they get to their target. If you’re actually completing drivefwd(), it’s probably that the motors won’t take a new startRotateTo() instruction until the old one is complete; it’s unexpected to me but not unreasonable. If this is the case, you get lucky with drivefwd(). Do as @epedemont suggested.