Cleanup and bug fix

This commit is contained in:
2019-05-19 10:37:28 +02:00
parent d80bf49905
commit 804c1a90fd
3 changed files with 34 additions and 33 deletions
+4 -2
View File
@@ -129,7 +129,9 @@ class Robot:
return None, 0
def get_entry(self, x, y):
wanted = self.Entry(x, y, 0, 0, 0, 0)
wanted = self.Entry(x, y, 0, Robot.Servo(0, Robot.Servo.Geometry(0, 0, 0)),
Robot.Servo(0, Robot.Servo.Geometry(0, 0, 0)),
Robot.Servo(0, Robot.Servo.Geometry(0, 0, 0)))
_return, i = self._is_contained(wanted)
return _return
@@ -153,7 +155,7 @@ class Robot:
for entry in entries:
coordinates = entry.split(":")[0]
servos = entry.split(":")[1]
new = self.Entry(float(coordinates[0]), float(coordinates[1]), float(servos[0]), float(servos[1]),
new = self.Entry(float(coordinates[0]), float(coordinates[1]), -1, float(servos[0]), float(servos[1]),
float(servos[2]))
self.database.append(new)
+3 -4
View File
@@ -1,7 +1,6 @@
import math
import csv
geometry = {
"servo0min": 0.5,
"servo0max": 2.5,
@@ -18,7 +17,7 @@ geometry = {
"servo4min": 0.5,
"servo4max": 2.5,
"servo4mid": 1.5
}
}
arms = {
0: 0.84,
1: 10.26,
@@ -83,7 +82,7 @@ def get_ms(servo, angle):
val_min = geometry[minimum]
val_max = geometry[maximum]
val_mid = geometry[middle]
change = 1/90
change = 1 / 90
if val_min > val_max:
change *= -1
ms = (angle * change + val_mid)
@@ -138,6 +137,6 @@ for steps in range(1, 0, -0.2):
for servo4 in range(pos[4][0], pos[4][1], steps):
coordinate = []
coordinate.append(get_pos([servo1, servo2, servo3, servo4]))
#coordinate.append(get_efficency([servo0, servo1, servo2, servo3, servo4]))
# coordinate.append(get_efficency([servo0, servo1, servo2, servo3, servo4]))
if coordinate in db:
if db[coordinate][]
+4 -4
View File
@@ -223,9 +223,9 @@ class argvReader:
:param filepath: filepath of the file to which the position should be written to
:return: The angles of servo0 to servo3 seperated by a ','
"""
with open(filepath, 'w') as file:
with open(filepath, 'w') as _file:
string = "{},{},{},{}".format(servo0actual, joy_it.servo1.deg, joy_it.servo2.deg, joy_it.servo3.deg)
file.write(string)
_file.write(string)
def deserialize(self, filepath):
"""
@@ -235,8 +235,8 @@ class argvReader:
"""
global servo0actual
try:
with open(filepath, 'r') as file:
string = file.readline()
with open(filepath, 'r') as _file:
string = _file.readline()
string = string.split(",")
servo0actual = float(string[0])
joy_it.servo1.set_angle(float(string[1]))