Tested Line Following with different track shape
This commit is contained in:
parent
3817fdcef0
commit
3db1a54419
@ -12,8 +12,8 @@ from ev3dev2.led import Leds
|
||||
cs_right = ColorSensor(INPUT_4)
|
||||
cs_left = ColorSensor(INPUT_2)
|
||||
# Motors are outputs
|
||||
m_left = Motor(OUTPUT_B)
|
||||
m_right = Motor(OUTPUT_C)
|
||||
m_left = Motor(OUTPUT_A)
|
||||
m_right = Motor(OUTPUT_D)
|
||||
leds = Leds()
|
||||
|
||||
# The motor is initialized to run counter-clockwise (gegen den Uhrzeigersinn)
|
||||
|
@ -12,8 +12,8 @@ from ev3dev2.led import Leds
|
||||
cs_right = ColorSensor(INPUT_4)
|
||||
cs_left = ColorSensor(INPUT_2)
|
||||
# Motors are outputs
|
||||
m_left = Motor(OUTPUT_B)
|
||||
m_right = Motor(OUTPUT_C)
|
||||
m_left = Motor(OUTPUT_A)
|
||||
m_right = Motor(OUTPUT_D)
|
||||
leds = Leds()
|
||||
|
||||
# The motor is initialized to run counter-clockwise (gegen den Uhrzeigersinn)
|
||||
@ -21,9 +21,9 @@ m_right.polarity = 'inversed' # use 'normal' to initialize it to run clockwise
|
||||
m_left.polarity = 'inversed'
|
||||
|
||||
# Defined inputs for the given experiment / enviroment
|
||||
Line = 1 # min. reflection meassured of line
|
||||
Floor = 30 # max. reflection meassured of floor
|
||||
max_speed_percent = 50 # maximum wanted speed percentage (highest possible value 100%)
|
||||
Line = 3 # min. reflection meassured of line
|
||||
Floor = 35 # max. reflection meassured of floor
|
||||
max_speed_percent = 40 # maximum wanted speed percentage (highest possible value 100%)
|
||||
|
||||
# calculate range
|
||||
range = (Floor - Line)
|
||||
@ -41,12 +41,12 @@ while True:
|
||||
m_l_speed_percent= max_speed_percent*cs_l_percent
|
||||
m_r_speed_percent= max_speed_percent*cs_r_percent
|
||||
# make sure percentage is not higher than possible (100%) and signal it through lights
|
||||
if m_l_speed_percent > 100:
|
||||
if m_l_speed_percent >= 100:
|
||||
m_l_speed_percent = 0
|
||||
leds.set_color("LEFT", "AMBER")
|
||||
else:
|
||||
leds.set_color("LEFT", "GREEN")
|
||||
if m_r_speed_percent > 100:
|
||||
if m_r_speed_percent >= 100:
|
||||
m_r_speed_percent = 0
|
||||
leds.set_color("RIGHT", "AMBER")
|
||||
else:
|
||||
|
@ -13,8 +13,8 @@ But the program should work with all robots that have one driven wheel per side.
|
||||
#### Motors
|
||||
|
||||
The used robot drives forward when the wheels turn counter-clockwise. `polarity = 'inversed'` If you use a robot with a clockwise direction of rotation, you need to change the settings in the program. `polarity = 'normal'`
|
||||
* **Left** Motor: Connected to output-port **B**
|
||||
* **Right** Motor: Connected to output-port **C**
|
||||
* **Left** Motor: Connected to output-port **A**
|
||||
* **Right** Motor: Connected to output-port **D**
|
||||
|
||||
#### Sensors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user