sets/ev3/home: refactor

This commit is contained in:
Antoni Luong Pham
2021-01-15 10:06:13 +01:00
committed by Laurens Valk
parent 53b23662a5
commit 6d80d5e596
16 changed files with 50 additions and 42 deletions
+1 -1
View File
@@ -3,5 +3,5 @@
"files.eol": "\n",
"debug.openDebug": "neverOpen",
"editor.rulers": [79],
"python.linting.enabled": true
"python.linting.flake8Enabled": true
}
+1 -1
View File
@@ -3,5 +3,5 @@
"files.eol": "\n",
"debug.openDebug": "neverOpen",
"editor.rulers": [79],
"python.linting.enabled": true
"python.linting.flake8Enabled": true
}
+1 -1
View File
@@ -3,5 +3,5 @@
"files.eol": "\n",
"debug.openDebug": "neverOpen",
"editor.rulers": [79],
"python.linting.enabled": true
"python.linting.flake8Enabled": true
}
+1 -1
View File
@@ -3,5 +3,5 @@
"files.eol": "\n",
"debug.openDebug": "neverOpen",
"editor.rulers": [79],
"python.linting.enabled": true
"python.linting.flake8Enabled": true
}
+1 -1
View File
@@ -3,5 +3,5 @@
"files.eol": "\n",
"debug.openDebug": "neverOpen",
"editor.rulers": [79],
"python.linting.enabled": true
"python.linting.flake8Enabled": true
}
+1 -1
View File
@@ -3,5 +3,5 @@
"files.eol": "\n",
"debug.openDebug": "neverOpen",
"editor.rulers": [79],
"python.linting.enabled": true
"python.linting.flake8Enabled": true
}
+9 -11
View File
@@ -16,17 +16,15 @@ class Bobb3e:
lift_motor_port: str = Port.A,
ir_sensor_port: str = Port.S4, ir_beacon_channel: int = 1):
self.ev3_brick = EV3Brick()
self.drive_base = \
DriveBase(
left_motor=
Motor(port=left_motor_port,
positive_direction=Direction.COUNTERCLOCKWISE),
right_motor=
Motor(port=right_motor_port,
positive_direction=Direction.COUNTERCLOCKWISE),
wheel_diameter=self.WHEEL_DIAMETER,
axle_track=self.AXLE_TRACK)
left_motor = Motor(port=left_motor_port,
positive_direction=Direction.COUNTERCLOCKWISE)
right_motor = Motor(port=right_motor_port,
positive_direction=Direction.COUNTERCLOCKWISE)
self.drive_base = DriveBase(left_motor=left_motor,
right_motor=right_motor,
wheel_diameter=self.WHEEL_DIAMETER,
axle_track=self.AXLE_TRACK)
self.lift_motor = Motor(port=lift_motor_port,
positive_direction=Direction.CLOCKWISE)
+1 -1
View File
@@ -3,5 +3,5 @@
"files.eol": "\n",
"debug.openDebug": "neverOpen",
"editor.rulers": [79],
"python.linting.enabled": true
"python.linting.flake8Enabled": true
}
+1 -1
View File
@@ -3,5 +3,5 @@
"files.eol": "\n",
"debug.openDebug": "neverOpen",
"editor.rulers": [79],
"python.linting.enabled": true
"python.linting.flake8Enabled": true
}
+1 -1
View File
@@ -3,5 +3,5 @@
"files.eol": "\n",
"debug.openDebug": "neverOpen",
"editor.rulers": [79],
"python.linting.enabled": true
"python.linting.flake8Enabled": true
}
+1 -1
View File
@@ -3,5 +3,5 @@
"files.eol": "\n",
"debug.openDebug": "neverOpen",
"editor.rulers": [79],
"python.linting.enabled": true
"python.linting.flake8Enabled": true
}
+1 -1
View File
@@ -3,5 +3,5 @@
"files.eol": "\n",
"debug.openDebug": "neverOpen",
"editor.rulers": [79],
"python.linting.enabled": true
"python.linting.flake8Enabled": true
}
+14 -14
View File
@@ -14,20 +14,20 @@ class RemoteControlledTank:
left_motor_port: Port = Port.B, right_motor_port: Port = Port.C,
polarity: str = 'normal',
ir_sensor_port: Port = Port.S4, ir_beacon_channel: int = 1):
self.driver = \
DriveBase(
left_motor=Motor(port=left_motor_port,
positive_direction=
Direction.CLOCKWISE
if polarity == 'normal'
else Direction.COUNTERCLOCKWISE),
right_motor=Motor(port=right_motor_port,
positive_direction=
Direction.CLOCKWISE
if polarity == 'normal'
else Direction.COUNTERCLOCKWISE),
wheel_diameter=wheel_diameter,
axle_track=axle_track)
if polarity == 'normal':
left_motor = Motor(port=left_motor_port,
positive_direction=Direction.CLOCKWISE)
right_motor = Motor(port=right_motor_port,
positive_direction=Direction.CLOCKWISE)
else:
left_motor = Motor(port=left_motor_port,
positive_direction=Direction.COUNTERCLOCKWISE)
right_motor = Motor(port=right_motor_port,
positive_direction=Direction.COUNTERCLOCKWISE)
self.driver = DriveBase(left_motor=left_motor,
right_motor=right_motor,
wheel_diameter=wheel_diameter,
axle_track=axle_track)
self.ir_sensor = InfraredSensor(port=ir_sensor_port)
self.ir_beacon_channel = ir_beacon_channel
@@ -1,5 +1,8 @@
{
"folders": [
{
"path": "bobb3e"
},
{
"path": "dinor3x"
},
@@ -11,8 +14,15 @@
},
{
"path": "mr_b3am"
},
{
"path": "robodoz3r"
},
{
"path": "wack3m"
}
],
"settings": {
"debug.openDebug": "neverOpen"
}
+1 -1
View File
@@ -3,5 +3,5 @@
"files.eol": "\n",
"debug.openDebug": "neverOpen",
"editor.rulers": [79],
"python.linting.enabled": true
"python.linting.flake8Enabled": true
}
+5 -5
View File
@@ -17,7 +17,7 @@ class Wack3m:
middle_motor_port: str = Port.A,
touch_sensor_port: str = Port.S1, ir_sensor_port: str = Port.S4):
self.ev3_brick = EV3Brick()
self.left_motor = Motor(port=left_motor_port,
positive_direction=Direction.CLOCKWISE)
self.right_motor = Motor(port=right_motor_port,
@@ -167,10 +167,10 @@ class Wack3m:
self.ev3_brick.screen.print(
'Avg. Time: {:.1f}s'.format(average_response_time))
self.ev3_brick.speaker.play_file(
file=SoundFile.FANTASTIC
if average_response_time <= 1
else SoundFile.GOOD_JOB)
if average_response_time <= 1:
self.ev3_brick.speaker.play_file(file=SoundFile.FANTASTIC)
else:
self.ev3_brick.speaker.play_file(SoundFile.GOOD_JOB)
self.ev3_brick.speaker.play_file(file=SoundFile.GAME_OVER)