Announcement

Collapse
No announcement yet.

"parallel" linear op mode in Blocks?

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

  • "parallel" linear op mode in Blocks?

    We're working on an autonomous program and are wondering if it is possible to set up a loop that runs in 'parallel' to a linear op mode (or vice versa) in Blocks. The practical example is getting a servo to repeatedly switch between set positions while the robot is following a separate finite list of commands. Think of it as juggling while walking from place to place: I have a loop that controls servos doing the juggling, and a linear section for the wheel motors that controls movement from point to point. I would like to walk and juggle at the same time. It would be OK if attention is alternated between both tasks 'rapidly enough'; I just don't want to stop juggling for the five or ten seconds it takes to move from A to B, then stop moving from B to C for five seconds while I juggle, etc.

    Is such a thing possible in Blocks? We're still new to this...

  • #2
    I don't know of any way to literally create parallel threads in Blocks. A similar effect can be obtained however, by creating a main loop in an op mode and have it repeatedly call two or more Blocks functions. Each function could run as a state machine, proceeding through a sequence of states. Each function would return regularly to the main loop which would check if opModeIsActive or isStopRequested. The main loop could also call Telemetry.update to transfer any telemetry that the functions had generated.

    Comment


    • #3
      I have posted a BLK file that can be uploaded into your Blocks environment. The op mode doesn't do anything but contains comments that give hints on how three functions might be executed in pseudo parallel. You will find the file at https://ortop.org/ftc/BlocksProgramm...rogramming.blk

      Comment


      • #4
        Thanks very much! We'll look into this approach. We're guessing that the function blocks would include a bunch of if/then statements to respond to various timer/sensor/encoder inputs.

        Comment


        • #5
          Also, the concrete example of the BLK file was very helpful.

          Comment


          • #6
            Originally posted by FTC13830 View Post
            Thanks very much! We'll look into this approach. We're guessing that the function blocks would include a bunch of if/then statements to respond to various timer/sensor/encoder inputs.
            Yes, that's correct. Each function may also need a variable that helps it keep track of its state -- where in a sequence it is.

            Comment

            Working...
            X