diff --git a/Code/conf.json b/Code/conf.json index 732c1eb..9ef71d3 100644 --- a/Code/conf.json +++ b/Code/conf.json @@ -5,6 +5,6 @@ "motor": "\nasync def drive(distance=0, multiplier=14, speed=1000, acceleration=1000):\n if (distance > 0):\n degrees = (distance * calibration)\n await motor_pair.move_for_degrees(pair, degrees, 0, velocity=speed, acceleration=acceleration)\n elif (distance < 0):\n degrees = distance * calibration\n await motor_pair.move_for_degrees(pair, degrees, 0, velocity=speed, acceleration=acceleration)\n elif (distance == 0):\n print('Null Value Error')\nasync def tank(degrees=0, left_speed=1000, right_speed=1000, acceleration=1000):\n #180 degrees = 90 Grad\n if (degrees > 0):\n await motor_pair.move_tank_for_degrees(pair, -degrees, left_speed, -right_speed, acceleration=acceleration)\n elif (degrees < 0):\n await motor_pair.move_tank_for_degrees(pair, degrees, -left_speed, right_speed, acceleration=acceleration)\n elif (degrees == 0):\n print('Null Value Error')\nasync def obstacle(distance=0, speed=1000, acceleration=1000):\n if (distance > 0):\n while distance_sensor.distance(port.C) > distance:\n await drive(2, 14, speed, acceleration)\n print('Obstacle detected!')\n elif (distance <= 0):\n print('Null Value Error')", "sensor": "\nasync def switch(switch=False):\n while switch == False:\n if (force_sensor.force(force_module) >= 50):\n switch = True\n return True", "variables": "\npair = motor_pair.PAIR_1\nmotor_pair.pair(pair, port.F, port.B)\nmotor_module = port.E\nmotor_module1 = port.A\nforce_module = port.D\ncalibration = 1\naverage = 111\ntimes = 1\ntimes1 = 1\naverage_calibration = []\naverage_obs = []", - "ai": "\ndata = [\n {'Calibration': 1.0, 'Akku': 100, 'Wheelusage': 1.0, 'Multiplication': 1.00},\n {'Calibration': 1.0, 'Akku': 900, 'Wheelusage': 0.9, 'Multiplication': 1.10},\n {'Calibration': 1.0, 'Akku': 800, 'Wheelusage': 0.8, 'Multiplication': 1.25},\n {'Calibration': 0.9, 'Akku': 100, 'Wheelusage': 1.0, 'Multiplication': 1.10},\n {'Calibration': 1.1, 'Akku': 100, 'Wheelusage': 1.0, 'Multiplication': 0.95}\n]\ndef euclidean_distance(point1, point2):\n multiplication = 0.0\n for key in point1:\n if key != 'Multiplication':\n multiplication += (point1[key] - point2[key]) ** 2\n return math.sqrt(multiplication)\ndef knn_predict(data, new_data_point, k=3):\n multiplication = []\n for item in data:\n dist = euclidean_distance(new_data_point, item)\n multiplication.append((dist, item['Multiplication']))\n multiplication.sort(key=lambda x: x[0])\n neighbors = multiplication[:k]\n total_multiplication = sum(neighbor[1] for neighbor in neighbors)\n predicted_multiplication = total_multiplication / k\n return predicted_multiplication", + "ai": "\ndata = [\n {'Calibration': 1.0, 'Akku': 100, 'Wheelusage': 1.0, 'Multiplication': 1.00},\n {'Calibration': 1.0, 'Akku': 900, 'Wheelusage': 0.9, 'Multiplication': 1.10},\n {'Calibration': 1.0, 'Akku': 800, 'Wheelusage': 0.8, 'Multiplication': 1.25},\n {'Calibration': 0.9, 'Akku': 100, 'Wheelusage': 1.0, 'Multiplication': 1.10},\n {'Calibration': 1.1, 'Akku': 100, 'Wheelusage': 1.0, 'Multiplication': 0.95}\n]\ndef euclidean_distance(point1, point2):\n multiplication = 0.0\n for key in point1:\n if key != 'Multiplication':\n multiplication += (point1[key] - point2[key]) ** 2\n return math.sqrt(multiplication)\ndef knn_predict(data, new_data_point, k=3):\n multiplication = []\n for item in data:\n dist = euclidean_distance(new_data_point, item)\n multiplication.append((dist, item['Multiplication']))\n multiplication.sort(key=lambda x: x[0])\n neighbors = multiplication[:k]\n total_multiplication = sum(neighbor[1] for neighbor in neighbors)\n predicted_multiplication = total_multiplication / k\n calibration = predicted_multiplication\n return predicted_multiplication", "switch": "\nasync def switch(switch=False):\n while switch == False:\n if (force_sensor.force(force_module) >= 50):\n switch = True\n return True" } \ No newline at end of file diff --git a/Code/file_test.py b/Code/file_test.py index ef09b6a..4483768 100644 --- a/Code/file_test.py +++ b/Code/file_test.py @@ -95,6 +95,7 @@ def knn_predict(data, new_data_point, k=3): neighbors = multiplication[:k] total_multiplication = sum(neighbor[1] for neighbor in neighbors) predicted_multiplication = total_multiplication / k + calibration = predicted_multiplication return predicted_multiplication print('Running main Function')