grefranchise.blogg.se

End all tasks
End all tasks





So, you should lock access to the “drive” function, so that ONLY ONE THREAD can control motor power at a time. This means the program could attempt to stop the motors WHILE ANOTHER TASK is in the process of applying power.

end all tasks

However, if you DO have multiple tasks running, it is possible that multiple tasks are attempting to control the motors AT THE SAME TIME. You mention TASKS, but the code you provide is in the “main” task - there’s only one of those. However, there is another potential problem that requires attention. THEN, you can can stop tasks at leisure by other means. Now, when you respond to the button for emergency shut off, you set eStop to true, then call “drive( 0, 0)”, and then ALL TASKS THAT MIGHT DRIVE WILL AUTOMATICALLY APPLY ZERO POWER. You no longer need to do this at the top of a loop. With this, EVERY place you “drive” the bot, you’re checking for epower. assume some global emergency power flag exists If EVERYWHERE in your application you’re writing “drive” to power the drive train, then the drive function becomes the place where you can globally control that power. Your main goal is that there should be ONE SINGLE PLACE TO CONTROL POWER. Everywhere you’re currently setting motor power for two motors (and in some systems FOUR separate motors), you can merely code:

end all tasks

This is more convenient everywhere you code changes in drive power.

end all tasks

It is typical that such constructs are “drive” concepts. What you need to think carefully about is this construct: Let me give you a viewpoint from a developer with many years of experience. I’m a volunteer in a local Vex robotics club, a parent to a member there, and a software engineer (so I teach programming to the club members). I’m new to the board, so let me introduce myself a bit here.







End all tasks