Skip to content

Commit

Permalink
Added new functions and debugged some functions
Browse files Browse the repository at this point in the history
  • Loading branch information
AIIrondev committed Jul 9, 2024
1 parent f6c0570 commit 9b24e47
Show file tree
Hide file tree
Showing 12 changed files with 219 additions and 601 deletions.
16 changes: 0 additions & 16 deletions Code/calibration.fll

This file was deleted.

8 changes: 8 additions & 0 deletions Code/conf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": "2.2.2",
"calibrate" : "\nasync def calibrate(speed=1000, acceleration=1000):\n if (distance_sensor.distance(port.C) < 110):\n print('Calibration not possible! | Distance to small!')\n elif (distance_sensor.distance(port.C) > 110):\n try:\n await drive(-1, 14, speed, acceleration)\n distance0 = distance_sensor.distance(port.C)\n await drive(10, 14, speed, acceleration)\n distance1 = distance_sensor.distance(port.C)\n calibration = distance0 - distance1\n #print('Calibration done!')\n print(calibration)\n wait(0.5)\n except:\n print('Calibration not possible! | Error!')",
"module": "\nasync def module(degrees=0, speed=1110, acceleration=10000):\n if (degrees > 0):\n await motor.run_for_degrees(motor_module, degrees, speed, acceleration=acceleration)\n elif (degrees < 0):\n await motor.run_for_degrees(motor_module, degrees, speed, acceleration=acceleration)\n elif (degrees == 0):\n print('Error')",
"motor": "\nasync def drive(distance=0, multiplier=14, speed=1000, acceleration=1000):\n if (distance > 0):\n degrees = multiplier*(distance - calibration)\n await motor_pair.move_for_degrees(pair, degrees, 0, velocity=speed, acceleration=acceleration)\n elif (distance < 0):\n degrees = multiplier*(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')\n\n\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')\n \n\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 = []\nai_data = []\n\ndef write_ai_data(file):\n with open('{file}', 'w') as f:\n for line in ai_data:\n f.write(line)"
}
Loading

0 comments on commit 9b24e47

Please sign in to comment.