Has anyone else experienced Vex code randomly skipping over functions in autonomous

I don’t think its the code as it also skips over functions like task::sleep() or task.resume(). Also, everything worked for the first couple of times running the autonomous, but it seems that every time the program builds and uploads, the program ignores a new function.

My current solution is to just copy paste the ignored function twice. but then new functions start skipping. An even weirder part of this is that there is a very slim chance that it doesn’t skip over the function(about 1 in 10 attempts)

Any ideas before I switch to pros?

Run make clean and then reupload. But also I highly recommend switching to PROS. It holds your hand a little less but its a lot better imo.

Seriously ? That was helpful.

14 Likes

Please provide the code and we can figure out the issues.

9 Likes

make clean fixes broken builds 90% of the time for me. Also OP was talking about switching to PROS, so its not like I was just plugging PROS for no reason. And it is a bit less hand holdy; the api reference is not in the program and the best way to upload code with pros is the CLI, which newer programmers might not be as comfortable with.

The problem is not with your programming environment - it’s a problem with your code. Attempting to switch to pros at this point in time will not be helpful. As James says, you will need to share your code with us before we can help further.

From the limited information you have given us (please provide more), I can only guess that your problem comes from an abuse of tasks.

13 Likes

I have 3 tasks running during the auto- one for tracking, one a debug task that runs 10 times a second and another that I turn on and off to index a ball. I tried turning off the debug one but it still bugged out.

sure, perhaps it does with PROS. We do not have a “make clean” with VEXcode, it’s not necessary.

same request, I can’t let you know what the problem is without seeing the code.

Virtually all problems like this are related to mis use of tasks and/or events. Perhaps this topic would help.

6 Likes

is there not a directory filled with object files to speed up subsequent builds?

sure there is. but if you keep needing to use make clean then it just means your build system is setup incorrectly. With most projects I work on I can go for months without ever needing to do that.
But this has nothing to do with the issues the OP has, so lets just drop it.

8 Likes
task DebugTask(debug);
task AutoSelectTask(selectAuto);
task trackingTask(a);
task OutakeUntil(outtakeUntil);

these are the 4 tasks i use, I stop the select Auto when the autonomous code starts

Here is the part of the auto I was running

    Drive.PIDMoveTo(10, 0, 0, 600, 0, 60);
    intakes.spin(127);
    task::sleep(1000);
    tower.stop();
    intakes.stop();
    //FIRST BALL
    OutakeUntil.resume();
    //SECOND TOWER
    Drive.TurnTo(2, 0, 0, 1000, 90);
    Drive.PIDMoveTo(10, 0, 0, 2000, 2, 90.0f);
    OutakeUntil.suspend();
    tower.stop();
    intakes.stop();
    Drive.TurnTo(2, 0, 0, 1000, 180);
    intakes.spin(127);
    Drive.PIDMoveTo(10, 0, 0, 1000, 3, 180.0f);
    tower.spin(127,spitBall,1000);
    tower.stop();
    Drive.setAngle(180);
    //SECOND BALL
    tower.spin(-127, spitBall);
    intakes.spin(-127);
    Drive.PIDMoveTo(10, 0, 0, 1700, 2, 180.0f);
    OutakeUntil.resume();
    Drive.TurnTo(2, 0, 0, 800, 90);
    //THIRD TOWER
    Drive.PIDMoveTo(10, 0, 0, 1800, 5, 90.0f);
    OutakeUntil.suspend();
    tower.stop();
    intakes.stop();
    Drive.TurnTo(2, 0, 0, 1000, 135);
    Drive.PIDMoveTo(10, 0, 0, 1800, 6, 135.0f);
    intakes.spin(127);
    intakes.spin(127);
    tower.spin(127, spitBall,1000);
    tower.stop();
    intakes.stop();

If you see a command twice, it is because it won’t run if it isn’t put twice.

  RightIntake.spin(directionType::fwd,speed,velocityUnits::pct);
  LeftIntake.spin(directionType::fwd,speed,velocityUnits::pct);

that is everything in the intakes.spin function that skips

tell me if you need anything else;

what is “intakes” ? a motor ? a motor group ? intakes.spin(127) is not a valid function for either of those classes so I assume you have written your own.

Is something else possible controlling the motors that are part that class ?

Perhaps attach the whole program (zip up the folder).

2 Likes

I’m not sure this is your problem, but I think there are better ways to control your intakes rather than start/stop a task like that (which may have side effects) - just use a global variable to message the intake task. Rapidly manipulating short-lived tasks can be a bug breeding ground.

7 Likes

Intakes is a class of just two motors and a few functions controlling the motors: spin/stop

the task “outakeUntil” is the only other thing that could control the intakes, but its not running whenever intakes.spin is called

Well my assumption is that something is sending a command to the intake motors and overwriting whatever you send in the spin command.
or perhaps this command, tower.spin(127, spitBall,1000), happens very fast and you then move onto the intakes.stop() command.
If you want to send me the whole program in a DM I will have a look (if using VEXcode Pro then zip up the whole folder).

5 Likes

Do you sleep your pid code?

Related to this, @jpearman would you know of any reason that a segment of code might be skipped over while using the autonomous switch but not at all when running from the controller? I had an issue where a command would be skipped over every other time (roughly) when using the switch but never with the controller. Pre auton was cleared for testing but that didn’t fix the issue. Jw since this thread was started and reminded me of it

you mean using the programing skills run on the controller menu ?
There’s no reason for it to do anything weird. But most issues related to this come from incorrect use of tasks and events as I said above. I would need to see the code (or preferably a simple example that demonstrates the problem).

I have looked at @MrCuddles code and made a couple of recommendations, I have not heard if this has solved any issues yet.

One problem in the OP’s code was the use of

Brain.Screen.render(true,false);

don’t pass any parameters to that call. They are for development and very special use really and may cause scheduler issues. Always call as (if you need to use it at all, it’s really only needed when doing complex screen updates to avoid flicker)

Brain.Screen.render();
3 Likes

Yeah running skills from the controller menu presented no issues, but when running from the switch the first command was skipped every other time or so. But only the first command, and none others. Everything was fine except for that first command. Idk if I still have the set up, I could look, but it was super strange and I was jw

It’s not really possible to skip commands. We are dealing with C/C++ code that is compiled, the functions will be called. If the command is expecting to use a sensor, the sensor may take time to initialize, for example, 3wire sensors have to be configured so they may not be available for the first 100mS or so after the code runs, but it sounds like you have the opposite problem. Again, usually this is because driver control had time to run for whatever reason for a short amount of time.

5 Likes