Tested Line Following with different track shape

This commit is contained in:
Tanja Sukal 2023-09-25 17:33:31 +02:00
parent 3817fdcef0
commit 3db1a54419
3 changed files with 11 additions and 11 deletions

View File

@ -12,8 +12,8 @@ from ev3dev2.led import Leds
cs_right = ColorSensor(INPUT_4) cs_right = ColorSensor(INPUT_4)
cs_left = ColorSensor(INPUT_2) cs_left = ColorSensor(INPUT_2)
# Motors are outputs # Motors are outputs
m_left = Motor(OUTPUT_B) m_left = Motor(OUTPUT_A)
m_right = Motor(OUTPUT_C) m_right = Motor(OUTPUT_D)
leds = Leds() leds = Leds()
# The motor is initialized to run counter-clockwise (gegen den Uhrzeigersinn) # The motor is initialized to run counter-clockwise (gegen den Uhrzeigersinn)

View File

@ -12,8 +12,8 @@ from ev3dev2.led import Leds
cs_right = ColorSensor(INPUT_4) cs_right = ColorSensor(INPUT_4)
cs_left = ColorSensor(INPUT_2) cs_left = ColorSensor(INPUT_2)
# Motors are outputs # Motors are outputs
m_left = Motor(OUTPUT_B) m_left = Motor(OUTPUT_A)
m_right = Motor(OUTPUT_C) m_right = Motor(OUTPUT_D)
leds = Leds() leds = Leds()
# The motor is initialized to run counter-clockwise (gegen den Uhrzeigersinn) # 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' m_left.polarity = 'inversed'
# Defined inputs for the given experiment / enviroment # Defined inputs for the given experiment / enviroment
Line = 1 # min. reflection meassured of line Line = 3 # min. reflection meassured of line
Floor = 30 # max. reflection meassured of floor Floor = 35 # max. reflection meassured of floor
max_speed_percent = 50 # maximum wanted speed percentage (highest possible value 100%) max_speed_percent = 40 # maximum wanted speed percentage (highest possible value 100%)
# calculate range # calculate range
range = (Floor - Line) range = (Floor - Line)
@ -41,12 +41,12 @@ while True:
m_l_speed_percent= max_speed_percent*cs_l_percent m_l_speed_percent= max_speed_percent*cs_l_percent
m_r_speed_percent= max_speed_percent*cs_r_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 # 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 m_l_speed_percent = 0
leds.set_color("LEFT", "AMBER") leds.set_color("LEFT", "AMBER")
else: else:
leds.set_color("LEFT", "GREEN") leds.set_color("LEFT", "GREEN")
if m_r_speed_percent > 100: if m_r_speed_percent >= 100:
m_r_speed_percent = 0 m_r_speed_percent = 0
leds.set_color("RIGHT", "AMBER") leds.set_color("RIGHT", "AMBER")
else: else:

View File

@ -13,8 +13,8 @@ But the program should work with all robots that have one driven wheel per side.
#### Motors #### 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'` 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** * **Left** Motor: Connected to output-port **A**
* **Right** Motor: Connected to output-port **C** * **Right** Motor: Connected to output-port **D**
#### Sensors #### Sensors