SlideShare a Scribd company logo
1 of 7
Download to read offline
import RPi.GPIO as GPIO
import time
#from AlphaBot import AlphaBot
import smbus
class AlphaBot(object):
def __init__(self,in1=12,in2=13,ena=6,in3=20,in4=21,enb=26,IRR=16,IRL=19):
self.IN1 = in1
self.IN2 = in2
self.IN3 = in3
self.IN4 = in4
self.ENA = ena
self.ENB = enb
self.IRR = IRR #left infrared sensor
self.IRL = IRL #right infrared sensor
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(self.IN1,GPIO.OUT)
GPIO.setup(self.IN2,GPIO.OUT)
GPIO.setup(self.IN3,GPIO.OUT)
GPIO.setup(self.IN4,GPIO.OUT)
GPIO.setup(self.ENA,GPIO.OUT)
GPIO.setup(self.ENB,GPIO.OUT)
self.forward()
self.PWMA = GPIO.PWM(self.ENA,500)
self.PWMB = GPIO.PWM(self.ENB,500)
self.PWMA.start(50)
self.PWMB.start(50)
# gpio for infrared sensor
#GPIO.setmode(GPIO.BOARD)
GPIO.setup(self.IRR, GPIO.IN,GPIO.PUD_UP)
GPIO.setup(self.IRL, GPIO.IN,GPIO.PUD_UP)
# Initialize camera
#cap = cv2.VideoCapture(0)
# Define target coordinates
#target_x = 200
#target_y = 200
# Define function to move robot forward
def forward(self):
GPIO.output(self.IN1,GPIO.HIGH)
GPIO.output(self.IN2,GPIO.LOW)
GPIO.output(self.IN3,GPIO.LOW)
GPIO.output(self.IN4,GPIO.HIGH)
# Define function to move robot backward
def backword(self):
GPIO.output(self.IN1,GPIO.LOW)
GPIO.output(self.IN2,GPIO.HIGH)
GPIO.output(self.IN3,GPIO.HIGH)
GPIO.output(self.IN4,GPIO.LOW)
# Define function to turn robot left
def left(self):
GPIO.output(self.IN1,GPIO.LOW)
GPIO.output(self.IN2,GPIO.LOW)
GPIO.output(self.IN3,GPIO.LOW)
GPIO.output(self.IN4,GPIO.HIGH)
time.sleep(0.5)
# Define function to turn robot right
def right(self):
GPIO.output(self.IN1,GPIO.HIGH)
GPIO.output(self.IN2,GPIO.LOW)
GPIO.output(self.IN3,GPIO.LOW)
GPIO.output(self.IN4,GPIO.LOW)
time.sleep(0.5)
# Define function to stop robot
def stop(self):
GPIO.output(self.IN1,GPIO.LOW)
GPIO.output(self.IN2,GPIO.LOW)
GPIO.output(self.IN3,GPIO.LOW)
GPIO.output(self.IN4,GPIO.LOW)
# Define function to check for obstacles
def check_obstacle():
ir1_value = GPIO.input(IRL)
ir2_value = GPIO.input(IRR)
if ir1_value == 0 or ir2_value == 0:
return True
else:
return False
Ab = AlphaBot()
IRR = 16
IRL = 19
TRIG_PIN = 17
ECHO_PIN = 5
SPEED_OF_SOUND = 34300 # cm/s
INCHES_PER_CM = 0.3937 # inches/cm
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(IRR,GPIO.IN,GPIO.PUD_UP)
GPIO.setup(IRL,GPIO.IN,GPIO.PUD_UP)
GPIO.setup(TRIG_PIN, GPIO.OUT)
GPIO.setup(ECHO_PIN, GPIO.IN)
Ab.stop()
#covert the measure from cm to inch
def measure_distance_inch():
GPIO.output(TRIG_PIN, True)
time.sleep(0.00001)
GPIO.output(TRIG_PIN, False)
start_time = time.time()
while GPIO.input(ECHO_PIN) == 0:
if (time.time() - start_time) > 0.1:
return -1
echo_start_time = time.time()
while GPIO.input(ECHO_PIN) == 1:
if (time.time() - start_time) > 0.1:
return -1
echo_end_time = time.time()
echo_duration = echo_end_time - echo_start_time
distance_cm = (echo_duration * SPEED_OF_SOUND) / 2
distance_inch = distance_cm * INCHES_PER_CM
return distance_inch
try:
while True:
distance = measure_distance_inch()
print(f"Distance: {distance} in") #Print the distance of the Ultrasonic Sensor
time.sleep(1)
while True:
DR_status = GPIO.input(IRR)
DL_status = GPIO.input(IRL)
if((DL_status == 1) and (DR_status == 1)) and (distance>4):
Ab.forward()
print("forward")
elif((DL_status == 0) and (DR_status == 1)) and (distance<3):
Ab.right()
print("right")
elif((DL_status == 1) and (DR_status == 0)) and (distance<3):
Ab.left()
print("left")
else:
Ab.stop()
print("stop")
except KeyboardInterrupt:
GPIO.cleanup();
Design a software system using python for AlphaBot mobile robot( using raspberry pi) to follow
a pre-planned path [( 0 , 0 ) , ( 20 , 0 ) , ( 20 , 20 ) , ( 0 , 20 ) and get from starting point to the
final destination while navigating through obstacles using two infrared sensors, camara(to detect
moving obstacles only), and ultrasonic sensor.( the below code is to detect the obstacles using 2
infrared sensors and get the the distance value|using ultrasonic sensor. Please finish this code for
the missing part, which are detecting moving obstacles using a camera sensor and keeping the
mobile robot to stay and follow the pre-planning path after avoiding any type of obstacle). Thank
you GPI0. setup(self.IRL, GPI0.IN, GPI0.PUD_UP)
import RPi-GPIO as GPIO import time #from AlphaBot import AlphaBot imp.pdf

More Related Content

Similar to import RPi-GPIO as GPIO import time #from AlphaBot import AlphaBot imp.pdf

CODING IN ARDUINO
CODING IN ARDUINOCODING IN ARDUINO
CODING IN ARDUINOS Ayub
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Ismar Silveira
 
Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Tom Paulus
 
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdfQ1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdfabdulrahamanbags
 
Show Us: SS7 Update
Show Us: SS7 UpdateShow Us: SS7 Update
Show Us: SS7 UpdateESUG
 
operating system ubuntu,linux,MacProgram will work only if you g.pdf
operating system ubuntu,linux,MacProgram will work only if you g.pdfoperating system ubuntu,linux,MacProgram will work only if you g.pdf
operating system ubuntu,linux,MacProgram will work only if you g.pdfaptcomputerzone
 
Fourier project presentation
Fourier project  presentationFourier project  presentation
Fourier project presentation志璿 楊
 
Python for Scientific Computing -- Ricardo Cruz
Python for Scientific Computing -- Ricardo CruzPython for Scientific Computing -- Ricardo Cruz
Python for Scientific Computing -- Ricardo Cruzrpmcruz
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers ToolboxStefan
 
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + ProcessingRoberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + ProcessingDemetrio Siragusa
 
Programming simple games with a raspberry pi and
Programming simple games with a raspberry pi andProgramming simple games with a raspberry pi and
Programming simple games with a raspberry pi andKellyn Pot'Vin-Gorman
 
SENDER It is a helmet that contains a sensor for gases, vital s.pdf
SENDER  It is a helmet that contains a sensor for gases, vital s.pdfSENDER  It is a helmet that contains a sensor for gases, vital s.pdf
SENDER It is a helmet that contains a sensor for gases, vital s.pdfalertshoeshingkimand
 
Getting Started with Raspberry Pi - USC 2013
Getting Started with Raspberry Pi - USC 2013Getting Started with Raspberry Pi - USC 2013
Getting Started with Raspberry Pi - USC 2013Tom Paulus
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1Little Tukta Lita
 

Similar to import RPi-GPIO as GPIO import time #from AlphaBot import AlphaBot imp.pdf (20)

CODING IN ARDUINO
CODING IN ARDUINOCODING IN ARDUINO
CODING IN ARDUINO
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4
 
Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013Getting Started With Raspberry Pi - UCSD 2013
Getting Started With Raspberry Pi - UCSD 2013
 
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdfQ1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
Q1 Consider the below omp_trap1.c implantation, modify the code so t.pdf
 
Show Us: SS7 Update
Show Us: SS7 UpdateShow Us: SS7 Update
Show Us: SS7 Update
 
ESUG15: SS7 Update
ESUG15: SS7 UpdateESUG15: SS7 Update
ESUG15: SS7 Update
 
operating system ubuntu,linux,MacProgram will work only if you g.pdf
operating system ubuntu,linux,MacProgram will work only if you g.pdfoperating system ubuntu,linux,MacProgram will work only if you g.pdf
operating system ubuntu,linux,MacProgram will work only if you g.pdf
 
Python 1 liners
Python 1 linersPython 1 liners
Python 1 liners
 
Fourier project presentation
Fourier project  presentationFourier project  presentation
Fourier project presentation
 
Python for Scientific Computing -- Ricardo Cruz
Python for Scientific Computing -- Ricardo CruzPython for Scientific Computing -- Ricardo Cruz
Python for Scientific Computing -- Ricardo Cruz
 
Sysprog 12
Sysprog 12Sysprog 12
Sysprog 12
 
Sysprog 12
Sysprog 12Sysprog 12
Sysprog 12
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers Toolbox
 
Fabric robots
Fabric robotsFabric robots
Fabric robots
 
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + ProcessingRoberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
Roberto Gallea: Workshop Arduino, giorno #2 Arduino + Processing
 
FINISHED_CODE
FINISHED_CODEFINISHED_CODE
FINISHED_CODE
 
Programming simple games with a raspberry pi and
Programming simple games with a raspberry pi andProgramming simple games with a raspberry pi and
Programming simple games with a raspberry pi and
 
SENDER It is a helmet that contains a sensor for gases, vital s.pdf
SENDER  It is a helmet that contains a sensor for gases, vital s.pdfSENDER  It is a helmet that contains a sensor for gases, vital s.pdf
SENDER It is a helmet that contains a sensor for gases, vital s.pdf
 
Getting Started with Raspberry Pi - USC 2013
Getting Started with Raspberry Pi - USC 2013Getting Started with Raspberry Pi - USC 2013
Getting Started with Raspberry Pi - USC 2013
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
 

More from Stewart29UReesa

Note- Can someone help me with the Public boolean add(E value) method.pdf
Note- Can someone help me with the Public boolean add(E value) method.pdfNote- Can someone help me with the Public boolean add(E value) method.pdf
Note- Can someone help me with the Public boolean add(E value) method.pdfStewart29UReesa
 
Note- E0- Equilibrium demand and supply for labour - DL- Demand for la.pdf
Note- E0- Equilibrium demand and supply for labour - DL- Demand for la.pdfNote- E0- Equilibrium demand and supply for labour - DL- Demand for la.pdf
Note- E0- Equilibrium demand and supply for labour - DL- Demand for la.pdfStewart29UReesa
 
need in c language Write a function called isIsoceles that accepts thr.pdf
need in c language Write a function called isIsoceles that accepts thr.pdfneed in c language Write a function called isIsoceles that accepts thr.pdf
need in c language Write a function called isIsoceles that accepts thr.pdfStewart29UReesa
 
need in c language Write the body of a function called sumRange that a.pdf
need in c language Write the body of a function called sumRange that a.pdfneed in c language Write the body of a function called sumRange that a.pdf
need in c language Write the body of a function called sumRange that a.pdfStewart29UReesa
 
Need help with this ASAP- This is Database systems- Please draw out th.pdf
Need help with this ASAP- This is Database systems- Please draw out th.pdfNeed help with this ASAP- This is Database systems- Please draw out th.pdf
Need help with this ASAP- This is Database systems- Please draw out th.pdfStewart29UReesa
 
Nheser- Thmus dependest artigert- Thetrus insepensient andigeta- both.pdf
Nheser- Thmus dependest artigert- Thetrus insepensient andigeta- both.pdfNheser- Thmus dependest artigert- Thetrus insepensient andigeta- both.pdf
Nheser- Thmus dependest artigert- Thetrus insepensient andigeta- both.pdfStewart29UReesa
 
Nikke has just received an amended assessment from the Australian Taxa.pdf
Nikke has just received an amended assessment from the Australian Taxa.pdfNikke has just received an amended assessment from the Australian Taxa.pdf
Nikke has just received an amended assessment from the Australian Taxa.pdfStewart29UReesa
 
Orange- Below is a sequence alignment with fixed differences for speci.pdf
Orange- Below is a sequence alignment with fixed differences for speci.pdfOrange- Below is a sequence alignment with fixed differences for speci.pdf
Orange- Below is a sequence alignment with fixed differences for speci.pdfStewart29UReesa
 
Nordic Multinationals Nordic countries have small populations ( 6 mill.pdf
Nordic Multinationals Nordic countries have small populations ( 6 mill.pdfNordic Multinationals Nordic countries have small populations ( 6 mill.pdf
Nordic Multinationals Nordic countries have small populations ( 6 mill.pdfStewart29UReesa
 
Nordic countries have small populations (6 million in Denmark- 9 milli.pdf
Nordic countries have small populations (6 million in Denmark- 9 milli.pdfNordic countries have small populations (6 million in Denmark- 9 milli.pdf
Nordic countries have small populations (6 million in Denmark- 9 milli.pdfStewart29UReesa
 
Ontinostatic typotension Vazodepressor Syncope Shuazanat SyncopeMoveme.pdf
Ontinostatic typotension Vazodepressor Syncope Shuazanat SyncopeMoveme.pdfOntinostatic typotension Vazodepressor Syncope Shuazanat SyncopeMoveme.pdf
Ontinostatic typotension Vazodepressor Syncope Shuazanat SyncopeMoveme.pdfStewart29UReesa
 
One of the concerns in severe ankle sprain is that the patient has sus.pdf
One of the concerns in severe ankle sprain is that the patient has sus.pdfOne of the concerns in severe ankle sprain is that the patient has sus.pdf
One of the concerns in severe ankle sprain is that the patient has sus.pdfStewart29UReesa
 
no more info Given the system represented by the equations- x1-x22x13.pdf
no more info  Given the system represented by the equations- x1-x22x13.pdfno more info  Given the system represented by the equations- x1-x22x13.pdf
no more info Given the system represented by the equations- x1-x22x13.pdfStewart29UReesa
 
On June 13- the board of directors of Siewert Incorporated declared a.pdf
On June 13- the board of directors of Siewert Incorporated declared a.pdfOn June 13- the board of directors of Siewert Incorporated declared a.pdf
On June 13- the board of directors of Siewert Incorporated declared a.pdfStewart29UReesa
 
On May 1- 2023- Romy and Vic formed a partnership contributing assets.pdf
On May 1- 2023- Romy and Vic formed a partnership contributing assets.pdfOn May 1- 2023- Romy and Vic formed a partnership contributing assets.pdf
On May 1- 2023- Romy and Vic formed a partnership contributing assets.pdfStewart29UReesa
 
On January 1- 2020- Fisher Corporation purchased 40 percent (90-000 sh.pdf
On January 1- 2020- Fisher Corporation purchased 40 percent (90-000 sh.pdfOn January 1- 2020- Fisher Corporation purchased 40 percent (90-000 sh.pdf
On January 1- 2020- Fisher Corporation purchased 40 percent (90-000 sh.pdfStewart29UReesa
 
need asap- thank you Symbols for Relational Aleebra Expressions and Ot.pdf
need asap- thank you Symbols for Relational Aleebra Expressions and Ot.pdfneed asap- thank you Symbols for Relational Aleebra Expressions and Ot.pdf
need asap- thank you Symbols for Relational Aleebra Expressions and Ot.pdfStewart29UReesa
 
On December 30- 2020- Inge Co-'s Board of Directors declared a 10- sto.pdf
On December 30- 2020- Inge Co-'s Board of Directors declared a 10- sto.pdfOn December 30- 2020- Inge Co-'s Board of Directors declared a 10- sto.pdf
On December 30- 2020- Inge Co-'s Board of Directors declared a 10- sto.pdfStewart29UReesa
 
On December 10- YR08 the board of directors of Apple Inc- declared a c.pdf
On December 10- YR08 the board of directors of Apple Inc- declared a c.pdfOn December 10- YR08 the board of directors of Apple Inc- declared a c.pdf
On December 10- YR08 the board of directors of Apple Inc- declared a c.pdfStewart29UReesa
 
Objective- Write syntactically correct while-for loops Given a list of.pdf
Objective- Write syntactically correct while-for loops Given a list of.pdfObjective- Write syntactically correct while-for loops Given a list of.pdf
Objective- Write syntactically correct while-for loops Given a list of.pdfStewart29UReesa
 

More from Stewart29UReesa (20)

Note- Can someone help me with the Public boolean add(E value) method.pdf
Note- Can someone help me with the Public boolean add(E value) method.pdfNote- Can someone help me with the Public boolean add(E value) method.pdf
Note- Can someone help me with the Public boolean add(E value) method.pdf
 
Note- E0- Equilibrium demand and supply for labour - DL- Demand for la.pdf
Note- E0- Equilibrium demand and supply for labour - DL- Demand for la.pdfNote- E0- Equilibrium demand and supply for labour - DL- Demand for la.pdf
Note- E0- Equilibrium demand and supply for labour - DL- Demand for la.pdf
 
need in c language Write a function called isIsoceles that accepts thr.pdf
need in c language Write a function called isIsoceles that accepts thr.pdfneed in c language Write a function called isIsoceles that accepts thr.pdf
need in c language Write a function called isIsoceles that accepts thr.pdf
 
need in c language Write the body of a function called sumRange that a.pdf
need in c language Write the body of a function called sumRange that a.pdfneed in c language Write the body of a function called sumRange that a.pdf
need in c language Write the body of a function called sumRange that a.pdf
 
Need help with this ASAP- This is Database systems- Please draw out th.pdf
Need help with this ASAP- This is Database systems- Please draw out th.pdfNeed help with this ASAP- This is Database systems- Please draw out th.pdf
Need help with this ASAP- This is Database systems- Please draw out th.pdf
 
Nheser- Thmus dependest artigert- Thetrus insepensient andigeta- both.pdf
Nheser- Thmus dependest artigert- Thetrus insepensient andigeta- both.pdfNheser- Thmus dependest artigert- Thetrus insepensient andigeta- both.pdf
Nheser- Thmus dependest artigert- Thetrus insepensient andigeta- both.pdf
 
Nikke has just received an amended assessment from the Australian Taxa.pdf
Nikke has just received an amended assessment from the Australian Taxa.pdfNikke has just received an amended assessment from the Australian Taxa.pdf
Nikke has just received an amended assessment from the Australian Taxa.pdf
 
Orange- Below is a sequence alignment with fixed differences for speci.pdf
Orange- Below is a sequence alignment with fixed differences for speci.pdfOrange- Below is a sequence alignment with fixed differences for speci.pdf
Orange- Below is a sequence alignment with fixed differences for speci.pdf
 
Nordic Multinationals Nordic countries have small populations ( 6 mill.pdf
Nordic Multinationals Nordic countries have small populations ( 6 mill.pdfNordic Multinationals Nordic countries have small populations ( 6 mill.pdf
Nordic Multinationals Nordic countries have small populations ( 6 mill.pdf
 
Nordic countries have small populations (6 million in Denmark- 9 milli.pdf
Nordic countries have small populations (6 million in Denmark- 9 milli.pdfNordic countries have small populations (6 million in Denmark- 9 milli.pdf
Nordic countries have small populations (6 million in Denmark- 9 milli.pdf
 
Ontinostatic typotension Vazodepressor Syncope Shuazanat SyncopeMoveme.pdf
Ontinostatic typotension Vazodepressor Syncope Shuazanat SyncopeMoveme.pdfOntinostatic typotension Vazodepressor Syncope Shuazanat SyncopeMoveme.pdf
Ontinostatic typotension Vazodepressor Syncope Shuazanat SyncopeMoveme.pdf
 
One of the concerns in severe ankle sprain is that the patient has sus.pdf
One of the concerns in severe ankle sprain is that the patient has sus.pdfOne of the concerns in severe ankle sprain is that the patient has sus.pdf
One of the concerns in severe ankle sprain is that the patient has sus.pdf
 
no more info Given the system represented by the equations- x1-x22x13.pdf
no more info  Given the system represented by the equations- x1-x22x13.pdfno more info  Given the system represented by the equations- x1-x22x13.pdf
no more info Given the system represented by the equations- x1-x22x13.pdf
 
On June 13- the board of directors of Siewert Incorporated declared a.pdf
On June 13- the board of directors of Siewert Incorporated declared a.pdfOn June 13- the board of directors of Siewert Incorporated declared a.pdf
On June 13- the board of directors of Siewert Incorporated declared a.pdf
 
On May 1- 2023- Romy and Vic formed a partnership contributing assets.pdf
On May 1- 2023- Romy and Vic formed a partnership contributing assets.pdfOn May 1- 2023- Romy and Vic formed a partnership contributing assets.pdf
On May 1- 2023- Romy and Vic formed a partnership contributing assets.pdf
 
On January 1- 2020- Fisher Corporation purchased 40 percent (90-000 sh.pdf
On January 1- 2020- Fisher Corporation purchased 40 percent (90-000 sh.pdfOn January 1- 2020- Fisher Corporation purchased 40 percent (90-000 sh.pdf
On January 1- 2020- Fisher Corporation purchased 40 percent (90-000 sh.pdf
 
need asap- thank you Symbols for Relational Aleebra Expressions and Ot.pdf
need asap- thank you Symbols for Relational Aleebra Expressions and Ot.pdfneed asap- thank you Symbols for Relational Aleebra Expressions and Ot.pdf
need asap- thank you Symbols for Relational Aleebra Expressions and Ot.pdf
 
On December 30- 2020- Inge Co-'s Board of Directors declared a 10- sto.pdf
On December 30- 2020- Inge Co-'s Board of Directors declared a 10- sto.pdfOn December 30- 2020- Inge Co-'s Board of Directors declared a 10- sto.pdf
On December 30- 2020- Inge Co-'s Board of Directors declared a 10- sto.pdf
 
On December 10- YR08 the board of directors of Apple Inc- declared a c.pdf
On December 10- YR08 the board of directors of Apple Inc- declared a c.pdfOn December 10- YR08 the board of directors of Apple Inc- declared a c.pdf
On December 10- YR08 the board of directors of Apple Inc- declared a c.pdf
 
Objective- Write syntactically correct while-for loops Given a list of.pdf
Objective- Write syntactically correct while-for loops Given a list of.pdfObjective- Write syntactically correct while-for loops Given a list of.pdf
Objective- Write syntactically correct while-for loops Given a list of.pdf
 

Recently uploaded

When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45MysoreMuleSoftMeetup
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxneillewis46
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...Sumit Tiwari
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxMohamed Rizk Khodair
 
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING IIII BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING IIagpharmacy11
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptxVishal Singh
 
Poster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdfPoster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdfAlexander Litvinenko
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Celine George
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptxPoojaSen20
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptxPoojaSen20
 

Recently uploaded (20)

Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
 
Word Stress rules esl .pptx
Word Stress rules esl               .pptxWord Stress rules esl               .pptx
Word Stress rules esl .pptx
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
IPL Online Quiz by Pragya; Question Set.
IPL Online Quiz by Pragya; Question Set.IPL Online Quiz by Pragya; Question Set.
IPL Online Quiz by Pragya; Question Set.
 
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...
Chapter 7 Pharmacosy Traditional System of Medicine & Ayurvedic Preparations ...
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING IIII BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
II BIOSENSOR PRINCIPLE APPLICATIONS AND WORKING II
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
Poster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdfPoster_density_driven_with_fracture_MLMC.pdf
Poster_density_driven_with_fracture_MLMC.pdf
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
Removal Strategy _ FEFO _ Working with Perishable Products in Odoo 17
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 

import RPi-GPIO as GPIO import time #from AlphaBot import AlphaBot imp.pdf

  • 1. import RPi.GPIO as GPIO import time #from AlphaBot import AlphaBot import smbus class AlphaBot(object): def __init__(self,in1=12,in2=13,ena=6,in3=20,in4=21,enb=26,IRR=16,IRL=19): self.IN1 = in1 self.IN2 = in2 self.IN3 = in3 self.IN4 = in4 self.ENA = ena self.ENB = enb self.IRR = IRR #left infrared sensor self.IRL = IRL #right infrared sensor GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(self.IN1,GPIO.OUT) GPIO.setup(self.IN2,GPIO.OUT) GPIO.setup(self.IN3,GPIO.OUT) GPIO.setup(self.IN4,GPIO.OUT) GPIO.setup(self.ENA,GPIO.OUT) GPIO.setup(self.ENB,GPIO.OUT) self.forward()
  • 2. self.PWMA = GPIO.PWM(self.ENA,500) self.PWMB = GPIO.PWM(self.ENB,500) self.PWMA.start(50) self.PWMB.start(50) # gpio for infrared sensor #GPIO.setmode(GPIO.BOARD) GPIO.setup(self.IRR, GPIO.IN,GPIO.PUD_UP) GPIO.setup(self.IRL, GPIO.IN,GPIO.PUD_UP) # Initialize camera #cap = cv2.VideoCapture(0) # Define target coordinates #target_x = 200 #target_y = 200 # Define function to move robot forward def forward(self): GPIO.output(self.IN1,GPIO.HIGH) GPIO.output(self.IN2,GPIO.LOW) GPIO.output(self.IN3,GPIO.LOW) GPIO.output(self.IN4,GPIO.HIGH) # Define function to move robot backward def backword(self):
  • 3. GPIO.output(self.IN1,GPIO.LOW) GPIO.output(self.IN2,GPIO.HIGH) GPIO.output(self.IN3,GPIO.HIGH) GPIO.output(self.IN4,GPIO.LOW) # Define function to turn robot left def left(self): GPIO.output(self.IN1,GPIO.LOW) GPIO.output(self.IN2,GPIO.LOW) GPIO.output(self.IN3,GPIO.LOW) GPIO.output(self.IN4,GPIO.HIGH) time.sleep(0.5) # Define function to turn robot right def right(self): GPIO.output(self.IN1,GPIO.HIGH) GPIO.output(self.IN2,GPIO.LOW) GPIO.output(self.IN3,GPIO.LOW) GPIO.output(self.IN4,GPIO.LOW) time.sleep(0.5) # Define function to stop robot def stop(self): GPIO.output(self.IN1,GPIO.LOW) GPIO.output(self.IN2,GPIO.LOW) GPIO.output(self.IN3,GPIO.LOW)
  • 4. GPIO.output(self.IN4,GPIO.LOW) # Define function to check for obstacles def check_obstacle(): ir1_value = GPIO.input(IRL) ir2_value = GPIO.input(IRR) if ir1_value == 0 or ir2_value == 0: return True else: return False Ab = AlphaBot() IRR = 16 IRL = 19 TRIG_PIN = 17 ECHO_PIN = 5 SPEED_OF_SOUND = 34300 # cm/s INCHES_PER_CM = 0.3937 # inches/cm GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(IRR,GPIO.IN,GPIO.PUD_UP) GPIO.setup(IRL,GPIO.IN,GPIO.PUD_UP) GPIO.setup(TRIG_PIN, GPIO.OUT) GPIO.setup(ECHO_PIN, GPIO.IN)
  • 5. Ab.stop() #covert the measure from cm to inch def measure_distance_inch(): GPIO.output(TRIG_PIN, True) time.sleep(0.00001) GPIO.output(TRIG_PIN, False) start_time = time.time() while GPIO.input(ECHO_PIN) == 0: if (time.time() - start_time) > 0.1: return -1 echo_start_time = time.time() while GPIO.input(ECHO_PIN) == 1: if (time.time() - start_time) > 0.1: return -1 echo_end_time = time.time() echo_duration = echo_end_time - echo_start_time distance_cm = (echo_duration * SPEED_OF_SOUND) / 2 distance_inch = distance_cm * INCHES_PER_CM return distance_inch try: while True: distance = measure_distance_inch() print(f"Distance: {distance} in") #Print the distance of the Ultrasonic Sensor
  • 6. time.sleep(1) while True: DR_status = GPIO.input(IRR) DL_status = GPIO.input(IRL) if((DL_status == 1) and (DR_status == 1)) and (distance>4): Ab.forward() print("forward") elif((DL_status == 0) and (DR_status == 1)) and (distance<3): Ab.right() print("right") elif((DL_status == 1) and (DR_status == 0)) and (distance<3): Ab.left() print("left") else: Ab.stop() print("stop") except KeyboardInterrupt: GPIO.cleanup(); Design a software system using python for AlphaBot mobile robot( using raspberry pi) to follow a pre-planned path [( 0 , 0 ) , ( 20 , 0 ) , ( 20 , 20 ) , ( 0 , 20 ) and get from starting point to the final destination while navigating through obstacles using two infrared sensors, camara(to detect moving obstacles only), and ultrasonic sensor.( the below code is to detect the obstacles using 2 infrared sensors and get the the distance value|using ultrasonic sensor. Please finish this code for the missing part, which are detecting moving obstacles using a camera sensor and keeping the mobile robot to stay and follow the pre-planning path after avoiding any type of obstacle). Thank you GPI0. setup(self.IRL, GPI0.IN, GPI0.PUD_UP)