C271A1 Error during thread

I’m getting the subject error when running a program to tend CNCs. I’ve had it before but fixed it using wait and/or sync() nodes in the thread. This time it’s not working.

I’ve rebooted polyscope and it worked once after that but failed the very next part.

The error:

The original code:
image

Added syncs and waits in all variations I could:
image

I have other programs with the exact same threads and they usually work fine. I’ve had some of these same errors but adding the waits has always fixed it.

Is there something else I should be looking at?

Might need to have sync() outside the if-statement

Basically any time you create a thread you need to end it with a sync() command. This uses up any physical time remaining after the code is complete. Currently if that statement is false it sits there and doesn’t know what to do (at least this is how I see it, it could be trying to run it several hundreds/thousands of times within the controller time step (500Hz or 0.002sec) but again not sure how Polyscope operates)

This is the structure for a thread:

Thread_1
   # Any code
   |
   |_
sync()

Not sure why the sync() isn’t internal to the Thread node but currently you have to add the script yourself (there’s probably a reason they don’t, but I’m learning as I go)

Anyways hope that helps and best of luck!

1 Like

Thanks much. I didn’t know where they sync() was supposed to go. I shut the TP down for a half hour while I did other things and came back and it’s working (without the sync()).

I added it to the end of the thread and will run them like that from now on. Hopefully that takes care of it.

Thanks again for the heads up on where to pup the sync()

FYI for anyone else having this issue:

Started the bots up this morning and keep getting the same alarm.

Turns out my sync() node was in the wrong place per @michael.r.mercer 's post above.

I put it here:
image
Should have been here:
image

I keep getting this error but I am using no threads in the program. I am incrementing a variable after a few relative moves and then using a loop + a switch case to go to a different starting waypoint before the relative moves.

If I manually set the variable referenced in the switch case then it goes through the all the moves just fine, but when it is incremented it will move to the second waypoint and then give this error. I tried adding a 0.01 second wait after the waypoint and that got rid of this protective stop but now it just sits on the wait forever.

What background tasks is the robot doing that I cannot see in polyscope?

You will also get it in the main sequence, if you have some code looping without any delay at all.

If you’re stuck on a wait, it’s because there’s no expression that is true in the switch/if, which the robot can proceed to. :slight_smile:

I have just got the same error after introducing a non related change. Solved after adding sync() at the end of each Thread