Announcement

Collapse
No announcement yet.

ROBOTC Graphical Multitasking

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • ROBOTC Graphical Multitasking

    Can someone help me to give me an example of multitasking in ROBOTC Graphical?

  • #2
    I've only seen this done with 'non-graphical' code in RobotC by a few of our advanced students who did Middle School VEX EDR. It was a bit tricky for them to figure out and understand. Involving lots of reading VEX Forum posts with trial & error.

    There doesn't appear to be the equivalent options in the Graphical interface, but the target audience for the Graphical interface is for students that are being introduced to programming.
    Last edited by gbr; 10-26-2017, 01:41 PM.

    Comment


    • #3
      Sounds like ModKit would work well for you. It is like Scratch in that you can multitask just by creating different sets of blocks.

      Comment


      • #4
        We are also trying to do some multitasking in regular Robot C.

        They have an elevator that they hit a button and it runs until it hits a bump/touch sensor. This works however while the elevator is traveling they cannot update their drive wheels. They would like the elevator to travel and still be able to keep drive control.

        We've tried putting the elevator code in it's own task 1 and driver control in task 2 same thing happens.

        Anyone been able to do something like this successfully while waiting on a touch sensor or other multitasking?

        Comment


        • #5
          Is the driver control task also giving that motor commands? While the elevator is lifting it shouldn't be telling that motor anything.

          You can do a while loop in regular graphical robotc. When you push the button it goes to a while loop that executes everything except the arm control for the elevatiors. Just leave out the command for the arm control for the elevator. Have that while loop run while the bumper is not pressed.

          It's not as elegant but could be a useful solution.

          Comment


          • #6
            If you use commands like "setMotorTarget" or "setMotor" instead of "forward" or "moveMotor" you will be able to perform simultaneous motor operations and perform if() and while() tests on sensors at the same time. If you look in the HELP for RobotC VEX IQ Graphical, the "Simple Behaviors" will move a motor, but will stall (block) the program in place while they do. The commands under the "Motor Commands" category will order the motor to do something, but then return control to your program while the processor in the smart motor executes the command. So you are essentially multitasking, really it's distributed control.

            BTW, both the simple behaviors and motor commands ultimately call the same function that executes in the smart motor processor. However, the Motor Commands place the following after the command to wait until the move is complete before giving control back to your program.

            do {sleep(100); while(!getMotorZeroVelocity(nMotorIndex)) sleep(1);} while(false)
            Last edited by TriDragon; 11-14-2017, 08:39 AM.

            Comment


            • #7
              This is an example of how you could do it. The program will have to wait until the the arm gets in position before it can continue, though. If you take out the waituntil, the armcontrol command will take over motor 10.

              Comment

              Working...
              X