The RoboMentors will introduce you to the concept of parallel beams, which allow the robot to execute more than one block at the same time.
What you will learn:
- How to use the spool tool to set execution “threads”
- How to plan which blocks to put in parallel
- What to be careful about when doing more than one action at the same time
- How to combine movements to lift and flip objects
We, as humans, are able to do more than one thing at a time: we can walk and look around and also have a conversation, or we can play games such as basketball, where we watch the ball and run after it, or dribble with it and so on.
It turns out the software for the robot allows us to have it do the same type of combined activities. We can have it start some motion, ask its sensors if something is happening, and for instance start another motion, all that at the same time.
A simple example would be of a robot with some type of arm: we want it to drive forward, and eventually stop, and, at the same time, to swing his arm. So we want the two blocks, one for driving and one for arm swinging, to start at the same time.
Doing that is very simple — the spool with the gray wire which connects blocks to be executed one after the other allows us to pull one more wire from an already plugged wire, and thus plug it into a new block, “on the side”. Then, when the block right before the two wires is completed, these two following blocks become active at the same time, and the robot does them simultaneously.
The only thing we need to be careful about is to decide which one of the “branches” continues into the rest of the program. The software for the robot does not allow “merging” of the branches. Allowing that would be complicated, because we don’t always know in advance which branch finishes first, which one finishes next and so on. Introducing a “wait until other branches are done” block is fairly complicated, so it was decided not to offer this.
So, in our example, we need to have a good idea of the robot first completes the swing or first finishes driving. Sometimes it may not matter, because we would just be preparing the robot, so we would gain time by doing things at once. What would follow would have to be clearly after the main action, for instance after driving, we would need to turn.
We still have to be careful for instance to allow for enough space around the robot, if we were swinging say in order to tuck his arm in, so he can pass through some narrow space.
Finally, of course, more than two blocks can be executed at the same time — we can spool-into-execution other blocks, the same way.
One of the more difficult tasks coming up quite often at competitions is the flipping of an object. Sometimes these objects are free, sometimes they are attached with some form of hinge (simple or perhaps more complex). The common part of all these tasks is the need to have a part of the robot get under the object or grab the object, and then somehow lift it and flip it.
A simple way to do that is to design a mechanism capable of moving a part up, and attach a narrow wedge to that part:
Then all the robot needs to do is to advance with the wedge in the low position, to have it slide under the object to be lifted, and then to lift it up:
All this is not entirely simple, however, because the object to be lifted behaves as if it is on a hinge: it will describe a circle as it is being lifted up (and for some missions, objects to be lifted and flipped are even set on hinges). If the robot first drives into and under the object with the wedge and then stops, and only lifts its wedge up, then shortly the object will escape the wedge, and fall back. The wedge would go up in a straight line, and the edge of the object will continue on a circle, so away from the wedge.
The solution to this problem is to have a compound movement: as the robot lifts its wedge, the robot also drives further towards the object, at the same time. Then the tip of the wedge always remains under the object until it is lifted all the way up. So, this is a very good example for the necessity of parallel beams. The robot is set in driving forward motion, and, at the same time, the motor lifting the wedge attachment is set in motion, at the appropriate speed.
Of course, this has to be adjusted, according to various gears used, to have both motions gently complete during the same time.