Lesson Modules
Teaching Tips:
Objectives of this module is to engage the students into the topic of using robotic arms having multiple processes working on a single task and why it is importent to synchronize them.
If two processes working on the same object in the production line are out of sync, the object might be picked up from a wrong location, missplaced or wrongly grabbed by the other process.
Watch the following video showing Tesla automated production line:
According to Tesla:
"Every Model 3 is being built on the Model 3 production line, which is fully installed, powered on, producing vehicles, and increasing in automation every day. However, every vehicle manufacturing line in the world has both manual and automated processes".
The following are examples of some of usegaes for the robotic arms in a veriety of fields:
Robofusion- robotic ice cream machine:
RoboCoaster- robotic roller coaster
Kuka- Film production (Making of Sherlock Holms)
Moley Robotics- Robotic kitchen
FarmBot- Robotic Garden
The following is an example of multiple robotic arms perfectly synchronized while working on the same car on a production line.
Volkswagen education using robotic arms:
Teaching Tips:
Objectives: This module will analyze an example of synchronizing multiple processes working on a single task.
The module will cover different synchronization methods and identify critical section, resource, mutual execution, spinlock, barries and semaphores.
In the video 3 different processes are involved manipulating the position of the blocks: Robotic Arm, Conveyor Belt and a Human.
The robotic arm gets an input from the distance sensor that there is an object approaching on the conveyor belt.
The robotic arm stopes the conveyor belt and pickes up the object from a pre-set location.
Once the object has been picked up, the robotic arm, drops it in a specific location and signals the conveyor belt to start motion.
Where it can go wrong if the processes are out of sync:
- The belt is moving too fast for the distance sensor to signal the real time location- by the time it signals the location, it is already changed and will be picked up from a wrong location.
- The distane sensor signals the wrong coordinates- the block is picked up from a wrong location
- The distance sensor doesn't signal at all- the robotic arm will be waiting for the signal and will not make an attempt to pick up the block.
- The location of the belt or the robotic arm is moved- the robotic arm will pickup the block from a wrong location
- The belt doesn't stop the moment the object reaches the distance sensor- the block won't be picked up from the right location.
Watch the following video of a robotic arm pick ups blocks baced on their location:
In this video we can see a robotic arm using a distance sensor to locate the coordinates of the following block moving on a conveyor belt.
- One
- two
- three
- four
- five
- Robotic Arm
- Conveyor Belt
- Additional Robotic Arm
- Human
- Blocks
- Distance Sensor
- Color Sensor
The blocks are called critical resource.
Critical resource-is a resource shared among processes
The algorithm that is used to move the blocks in every process is called critical section.
Critical section- is a code that access a critical resource.
Knowing when the block is ready to be picked up and at what location is managing the synchroinzation between the processes.
The robotic arm is waiting for a signal that the previous process as finished it's job and the critical resource is available for a full access.
This behaviour is called mutual execution.
Mutual execution- only one process may be executing a critical section with respect to a particular critical resource at a time.
The answer to the question above describes a behavior that is called Spinlock.
The robotic arm is checking the data stored in the distance sensor in a loop.
Once the conveyor belt has finished it's task and the block is located in the correct position, the distance sensor can see the block.
The moment it is detected by the sensor, the robotic arm will be notified that the critical resource is available now by checking the distance sensor value in the next loop iteraction.
Spinlock- is a way to keep track on the availability of a critical resource.
A process that needs to get an access to the critical resource checks a variable that hold the information regarding the availability of the resource.
If the critical source is not yet available, the process will wait in a loop ("spin") and check again later.
Since the process remains active but is not performing a useful task, the use of such a lock is a kind of busy waiting.
Once acquired, spinlocks will usually be held until they are explicitly released.
There might be a need in your solution to know when more than one process has completed their jobs and procede only if those processes has finished.
This method of synchronization is called barriers.
Barrier- is a type of synchronization method. A barrier for a group of processes means any process must stop at this point and cannot proceed until all other processes reach this barrier.
In case of multiple robotic arms are allowed to manipulate the block at the same time, use semaphoes to limit the access to more than the maximum allowed.
Semaphores- similar to a spinlock for multiple processes if allowed to access to a critical resource at the same time with a limitation of a maximum processes at the same time.
The implementation for that can use multiple variables as a spinlocks if there is a need to keep track on each one of the processes, or to use a common accomulated variable to keep track of number of processes currently accessing the critical resource.
Teaching Tips:
Objectives: Further exercise of the manipulator and process synchronization by designing a program in which the manipulator stacks the objects bases on their colors in combination with the pipeline and human interaction.
This module covers computer science fundamentals as variable and mathematical operation, sequences, events, conditions, loops.
Watch the following video of a robotic arm sorting blocked based on their colors:
Let's code!
In order to create a color sorting algorithm, we need to break down the program into smaller sigments.
Each sigment is a function with a single job.
The following are some code samples as a reference.
Color reading:
Color sensor related blocks can be found under DobotAPI -> Additional menu.
In order to activate the color sensor reading, use the SetColorSensor block.
Change the value to ON and the port to the port number the sensor is connected to (GP5):
The color sensor can recognize only the following colors: Red, Green and Blue.
Use the IdentifyColor mathod to query the sensor regarding the color of the object currently presented.
Change the value to r in order to read the red color, g for green and b for the blue color.
The mathod will return 1 if the requested color has been recognized, or 0 if a different color has been recognized.
0 will be also returned if the sensor cannot see the object.
It is recommended to read the sensor once and store the reading inside a variable to be used multiple times later on if needed.
Since the sensor can only recognize 1 out of the 3 colors at any given point, only 1 variable (red, green or blue) can be equale to 1 if any.
Works only about 5mm to 1cm distance with no-reflection objects. If you put near it near than 5mm, can't tell the color
Distance reading:
When an object has been found on the conveyor belt, grab it and read it's color:
Setup initial coordinations and variables:
Teaching Tips:
Question 1: What was the coolest thing you learned today? Write your answer in the box, and see it appear which your classmates answers!
Any answer will do here. If time permits, have a short discussion with students about their answers.
Question 2: Check the concepts you understand. Don’t worry, this isn’t for a grade, it’s just so your teacher can check the classes’ understanding.
This is the students' self-assessment of their understanding of the material. You will see a bar graph once all the poll answers are submitted.
Question 3: Did your code worked as expected?
Any answer will do here. If time permits, have a short discussion with students about their answers.
Question 4: If you could set up another experiment using different way of synchronization, how would you do it?
Any answer will do here. If time permits, have a short discussion with students about their answers.
- Critical Resource
- Critical Section
- Mutual Execution