I just made the switch to using two controllers the other day, and I’ve noticed a few issues that have arisen as a result. When using one controller, it was easy to hit the button to open the claw on our robot and then back up away from a cube or skyrise piece as the claw closed (it is set to send about 20 units of power or whatever you call it to the claw always to help it grip heavier things), although now that one controller is doing the claw opening and another is doing the backing up, We’ll need to be able to keep the claw open while the other driver reacts and drives backwards. I currently have all of the commands entered as “else if” functions, and it doesn’t allow the two controllers to send two commands at once, even if they are pertaining to different motors.
How should I edit the programming to allow for multiple commands at once? I can post the current code tomorrow sometime if that would be helpful too.
You need to create separate tasks. One does the driving and one does the claw and other stuff. Assuming its robotc, you can create a task just like the user or main one. Then you can have StartTask(name of other task) in the user one.
One can defend for Easy C, but that cannot change the fact that currently easy c cannot multitask… Multitasking makes your loops significantly neater. You first declare a task, then use startTask(); and stopTask(); to control them.
So the key to the whole multiple loops thing is to have multiple “while” components? I tried just substituting some of the “else if” commands with “if” commands and it caused all kinds of weird things to happen. The motors switched on and off rapidly and it had kind of a sputtering effect.
On the other hand, it wouldn’t let me separate each controller’s code into its own “while(true) loop”
I’d hate to ask any of you to write out too much code because I’m a complete coding noob, but if I could just get an example of how I should edit the current program to give each controller its own “loop”, whatever that is, and not cause it to sputter and generally mess up.
Alright so I’m totally stuck here. I tried putting each thing in their own tasks (arm lifts in one loop, wheel movements in another, etc.) but nothing worked. I tried putting each in its own while(true) loop, and that only ran the first program. I tried making each movement be under its own if statement as opposed to an else if like they had been, but that didn’t work.
How exactly am I supposed to do this? I get that there is a huge debate over whether or not to use Easy C and the deep philosophical junk behind whether to “multitask” or not, whatever that means, but I’m just a programming noob looking for some help understanding what I’m even supposed to type into the program before our team’s competition tomorrow.
Is it something like:
task usercontrol ()
if (vexRT[Btn5D] == 1)
//motor stuffs blah blah blah
else if (vexRT[Btn5U] == 1)
//blah blah blah
blah blah blah
task something else however that works ()
//if,else if, else, all that good stuff
I can’t find any resources on what exactly i’m supposed to do here and I have no more ideas on what to do. Any useful help would be appreciated.