CPE313 Week6
CPE313 Week6
Robotics Technology
Dr. Mohannad Farag
2021-2022, Semester I
Lesson overview
In this lesson, you will learn how to improve your robot's decision-making capability using conditional statements and nested
loops. You will use sensor data from the robot's environment to control the actions of the robot. This programming technique
will allow you to create shorter and easily maintainable programs. Also, you will learn how to use the Electromagnet gripper on
the VR Robot to pick up and drop disks to solve the Disk Mover challenge and Disk maze challenge.
Learning objectives
1. Identify how to use different conditional statements in Python.
2. Identify dictionary data type.
3. Identify that algorithms are made up of sequence, selection, and iteration
4. Identify how to use nested conditional/ control statements in Python.
5. Describe why to use an Electromagnet gripper in robots.
Keywords
https://www.educba.com/if-statement-in-python/
Introduction: Autonomous Orchard Tractor
• As an autonomous tractor, looking for hazards is important for both avoiding damage to the robot and for
the safety of others.
• Using sensors, the robot continually looks for unexpected obstacles in its path.
• When it sees one, it responds by altering its course if possible or stopping to wait until it is safe to continue.
Automated Tractor Obstacle Detection
How can the robot make decisions?
https://www.educba.com/conditional-statements-in-python/?source=leftnav
Types of Conditional Statements
• Some of the mutable data types in Python are list, dictionary, set and user-defined
classes.
• On the other hand, some of the immutable data types are int, float, decimal, bool,
string, tuple, and range.
https://towardsdatascience.com/https-towardsdatascience-com-python-basics-mutable-vs-immutable-objects-829a0cb1530a
Python Dictionaries
https://www.w3schools.com/python/python_dictionaries.asp
Properties Python Dictionaries
Dictionary Items
https://www.w3schools.com/python/python_dictionaries.asp
Properties Python Dictionaries
Dictionary Length
https://www.w3schools.com/python/python_dictionaries.asp
Properties Python Dictionaries
https://www.w3schools.com/python/python_dictionaries.asp
Properties Python Dictionaries
type()
https://www.w3schools.com/python/python_dictionaries.asp
Create switch statement in python using dictionary
• Python language does not have a direct
switch statements. But it could be
implemented using Dictionary.
Solution video
Electromagnetic gripper in robots
Robot End Effector
https://www.destaco.com/products/end-
effectors#:~:text=End%20effectors%2C%20also%20known%20as,that%20interact https://ars.els-cdn.com/content/image/1-s2.0-S0921889018300952-gr4.jpg
%20with%20the%20environment.
Some Types of Robotic End Effector
magnet.energize(BOOST) magnet.energize(DROP)
Week 6 Challenge
Week 6 Challenge 1: Disk Mover Challenge
1. Create a new Text Project named as week6.task2.
2. Use the Electromagnet to pick up and drop nine disks: three blue, three
red, and three green disks into the matching-colored goals.
3. Solving the Disk Mover Challenge requires the VR Robot to complete
repetitive actions using conditional and control statements.
4. Once all nine disks are in the proper goals, the challenge is complete.
5. Draw the flowchart of the pseudocode first.
6. Submit your code to MS teams in a word (docx.) format.
Note:
• Do not use the hard-coded approach.
• The solution video has the VR Robot run into the wall beside the Solution video
Disk Mover playground
green goal. Try to prevent this behavior in your solution.