a1tD0000007EOQ8IAO

Robotic Arm- Process Synchronization

  • 7-12 grade

Lesson Description:

Learn about syncronizing processes, functional modules such as variables, mathematical calculation, cycle structure and design a program in which the manipulator stacks the objects bases on their colors in combination with the pipeline and human interaction.


 

Standards Covered

CCSS.MATH.PRACTICE.MP1

Make sense of problems and persevere in solving them.

CCSS.MATH.PRACTICE.MP2

Reason abstractly and quantitatively.

HS-ETS1-2

Design a solution to a complex real-world problem by breaking it down into smaller, more manageable problems that can be solved through engineering.

HS-ETS1-3

Evaluate a solution to a complex real-world problem based on prioritized criteria and trade-offs that account for a range of constraints, including cost, safety, reliability, and aesthetics as well as possible social, cultural, and environmental impacts.

TEKS $111.39 (1)(D)

communicate mathematical ideas, reasoning, and their implications using multiple representations, including symbols, diagrams, graphs, and language as appropriate;

TEKS $111.39 (1)(E)

create and use representations to organize, record, and communicate mathematical ideas;

TEKS $111.39 (1)(F)

analyze mathematical relationships to connect and communicate mathematical ideas;

TEKS §126.31 (1)(D)

create algorithms for the solution of various problems;

TEKS §126.33 (4)(B)

TEKS §126.33 (4)(F)

design a solution to a problem

image description

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".



What other field can be optimized by using robotic arms? Choose only ONE field


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:



What can happen if one of those processes gets out of sync?


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.

How many different processes manipulating the position of the blocks in the video?
  • One
  • two
  • three
  • four
  • five

Identify all the processes involved in manipulating the blocks
  • Robotic Arm
  • Conveyor Belt
  • Additional Robotic Arm
  • Human
  • Blocks
  • Distance Sensor
  • Color Sensor

State all the points of conflicts that can go wrong if one or all the processes are out of sync


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.

How does the robotic arm know when and where to pick up the blocks from?

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.


If you would like to accelerate the production and add an additional robotic arm to pickup the blocks, how would you sync all the processes?

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:

Describe in your words the pseudo-code of the videos



Identify the critical resource. Use ONE word

Identify the critical sections

Describe the mutual execution


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

robotic arm reading a color sensor

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.



What was the coolest thing you learned today?  Write your answer in the box, and see it appear which your classmates answers!

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.
  • Critical Resource
  • Critical Section
  • Mutual Execution

Did your code work as expected?

If you could set up another experiment with a different synchronization method, how would you do it?