Turning inconsistencies

So whenever I turn it’s wildly inaccurate I tried using the gyro but couldn’t get it to work any other ideas

1 Like

wait do those all start at the same time, with only a wait keeping them apart :sob:

Yes whenever I run it as one line of code it skips lines occasionally.

Each When Started hat is a different thread and, if my memory serves me well, I think that the limit is 8. I count 17 in the snippet.

I can’t event begin to talk about the coding pattern.

1 Like

Okay if i were to get rid of it and put it in one line of code it skips lines any ideas how to fix that

I’m not sure what you mean about skipping lines. Can you show some examples?

You have numerous threads with various wait times all sending commands to the same motors. It’s very feasible that they are stepping on each other.

The brain has a thread pool that can hold 64 threads (when started hats) but only run 4 (IQ v1) or 8 (IQv2) at a time, and this program is trying to share resources between 17.

I would recommend:

  1. Make backup copy of your code
  2. Remove all of the waits (unless you have some significant delay required)
  3. Stack your command in the order you want them to run. The arrow on the right of the motion functions specifies if that command should wait to compete before running the next command (blocking). Ex: To start an intake and then drive forward - set the intake to ‘and don’t wait’. Then the drive will immediately happen.
  4. IMO, I would set your parameters to reasonable numbers. Setting torque to 1000% demonstrates poor programming.
  5. If you have a 100 RPM motor set it to 100 RPM for max speed. If there is an flaw in the underlying system and you set crazy numbers, it may cause your robot to do unexpected things. The team that writes the underlying system tries to account for students doing this but it is still possible to have side affects.

For the gyro, I would recommend that you make a simple program with just the drivetrain defined with the gyro. Issue one line of code for the robot to either drive forward or to turn 90 degrees. See how accurate it is and then look at the settings on the brain to see what numbers is gyro is showing. Test that the hardware is working as expected and then move to your code.

1 Like

So I have it set to drive forward while Intaking then drive back and turn the drive along the wall so one we saw was that it would just never turn and continue the rest of the code

more or less correct.
For IQ generation 1, the thread pool is 4 threads and 64 events can be registered, so yes, at most only 4 of the events can run at the same time.

For IQ generation 2, the thread pool is 8 threads and 75 events can be registered.

The “when started” hats do not use event resources, but they do start a thread. On IQ1 you can have perhaps 3 “when started” (IIRC, it may be 4), on IQ2 that increases to perhaps 10 or 12 (again, I forget exactly)

I had thought we had limited the number of “when started” hats in VEXcode, guess that changed at some point.

2 Likes

Well while that might be the case it’s the only way that I’ve found for it to not skip lines

I’m not sure I understand can you show a video of someone doing this or something

This sounds like a Timeout issue. If you tell a robot to drive 50 inches and it hits the wall at 45 inches, the robot will continue to try to reach 50 and never give up (and never move on to the next step).

To solve this problem you can set a Timeout value which tells the program to give up if the destination is not reached withing N seconds. Below is an example.

1 Like

I can try that but it will do the rest of the code just not the turning