PLTW Teacher here. We decided to get ahead of the game and upgrade to V5 now rather than buy legacy stuff as it gets phased out. Right now i’m trying to develop content for my students to start completing some of the PLTW projects. When we were using RobotC, as a requirement, I would typically have my students run an emergency stop loop as a concurrent task to their main code using the stopAllTasks function like the example below. :
I did this so that if their code didn’t work while disconnected from the computer they could hit a button near the outside of their system rather than try to power cycle the cortex. Basically the estop task would start at the beginning of the main task and loop alongside it, constantly checking for the estop bump switch. That way the code could do its thing without interruption and be killed if the estop was pressed.
My big question is how to perform a similar concurrent task in the VCS C++ pro where the concurrent task will constantly check for that bump switch and terminate the main task if it is pressed. Any help is good help.
The power buttons on V5 can be used to stop a program if you hold them. That kind of nullifies the need for an emergency stop task. Just hold down the power button on the controller and the program will stop running. I am not however aware of how you would write the code for a stop.
Thanks! I finally got it working. As a heads up the disableAll() function isn’t working in VCS. I’m not sure if it just hasn’t been added yet or what, but I was able to use the motor.stop() function in place of it and that did the trick. For the time being it looks like each motor will need to be disabled independently, but this is a good work around for now.
couple of points.
You should consider switching over to VEXcode if you have a ROBOTC background and are already using C++ Pro in VCS. preview 3 is the latest.
I’ve not yet enabled a stopAllTasks() type function in the VEX sdk, it’s a bit more complicated with the V5, still some debate as to whether that should also remove any event handlers that have been installed. It may be available with VEXcode preview 4, I don’t know when if/when VCS will get an update so it’s stuck on the August version of the SDK for now.
We do not have a disableAll() method in the VEX SDK, that’s something RobotMesh added to their implementation of the API.