forked from martinferianc/Robotics-EIE3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvirtual_interface.py
More file actions
83 lines (62 loc) · 1.95 KB
/
virtual_interface.py
File metadata and controls
83 lines (62 loc) · 1.95 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import random
import matplotlib.pyplot as plt
import time
class pidParameters():
def __init__(self):
self.minOutput = 0
self.minOutput = 0
self.k_p = 0
self.k_i = 0
self.k_d = 0
class MotorParams():
def __init__(self):
self.maxRotationAcceleration = 0
self.maxRotationSpeed = 0
self.feedForwardGain = 0
self.minPWM = 0
self.pidParameters = pidParameters()
class Interface:
def __init__(self):
self.sensors = {}
pass
def initialize(self):
return True
def motorEnable(self,port):
return True
def MotorAngleControllerParameters(self):
return MotorParams()
def setMotorAngleControllerParameters(self,port, params):
return True
def setMotorRotationSpeedReference(self,motors, speeds):
return True
def sensorEnable(self,port, sensor_type):
self.sensors[port] = sensor_type
return True
def getSensorValue(self,port):
if self.sensors[port] == "SENSOR_ULTRASONIC":
# Insert some random function here
return (random.randint(1,11)*8,0)
else:
return (0,0)
def getMotorAngles(self,ports):
return [(1,0) for x in ports]
def increaseMotorAngleReferences(self,ports, distances):
return 1
def motorAngleReferencesReached(self,ports):
time.sleep(0.2)
return 1
def setMotorRotationSpeedReferences(self,ports,speeds):
return True
def setMotorPwm(self,port, value):
return True
def startLogging(self,logfile):
print("Logging started.")
return True
def stopLogging(self):
print("Logging stopped.")
return True
def terminate(self):
raw_input("Press enter to close all plots.")
plt.close('all')
print("Shutting down robot.")
return True