-
Notifications
You must be signed in to change notification settings - Fork 0
/
wheelchairController.py
66 lines (57 loc) · 2.05 KB
/
wheelchairController.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#------------------ Importing Libraries -----------------
'''URL hnadling'''
import urllib.request
#------------------ Importing Libraries -----------------
#------------------ Variable Initializations ------------
#defines the local IP address for the ESP controller
#(needs to be defined for each ESP and may change with differing networks)
root_url = "http://10.129.110.181"
#------------------ Variable Initializations ------------
#------------------ URL Request Function ----------------
def sendRequest(url):
"""
Sends a request to the specified URL.
Parameters:
url (str): The URL to send the request to.
Returns:
None
"""
n = urllib.request.urlopen(url) #send request to ESP
#------------------ URL Request Function ----------------
#------------------ Motor Control Functions -------------
def motorForward():
"""
Moves the motor forward by sending a request to the ESP via IP.
"""
#sends "forward" keyword to ESP via IP
#print("Moving forward")
sendRequest(root_url + "/forward")
def motorBackward():
"""
Moves the motor backward by sending a "backward" keyword to the ESP via IP.
"""
#sends "backward" keyword to ESP via IP
#print("Moving backward") #confirms function execution
sendRequest(root_url + "/backward")
def turnLeft():
"""
Turns the motor left by sending a "left" keyword to the ESP via IP.
"""
#sends "left" keyword to ESP via IP
#print("Turning Left") #confirms fucntion execution
sendRequest(root_url + "/left")
def turnRight():
"""
Turns the motor right by sending a "right" keyword to the ESP via IP.
"""
#sends "right" keyword to ESP via IP
#print("Turning Right") #confirms fucntion execution
sendRequest(root_url + "/right")
def motorStop():
"""
Stops the motor by sending a "stop" keyword to the ESP via IP.
"""
#sends "stop" keyword to ESP via IP
#print("Stopping") #confirms fucntion execution
sendRequest(root_url + "/stop")
#------------------ Motor Control Functions -------------