-
Notifications
You must be signed in to change notification settings - Fork 85
Open
Description
- ev3dev version: PASTE THE OUTPUT OF
uname -rHERE - ev3dev-lang-python version: INSERT ALL VERSIONS GIVEN BY
dpkg-query -l {python3,micropython}-ev3dev*HERE
My version: the one downloaded from the lego Ev3 Website for education. 2.0
Attached is the code I am using. It is For the RoboCup junior rescue line competition. When running the code, the console gives a message saying there is an error using commands like .stop and .brake. The error is happening every second time. The message says something about the directory: Note. Couldn't access this website at school when preparing for comp and was unable to get the error msg.
File copied as unable to add.
#!/usr/bin/env pybricks-micropython
from pybricks.hubs import EV3Brick
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor,
InfraredSensor, UltrasonicSensor, GyroSensor)
from pybricks.parameters import Port, Stop, Direction, Button, Color
from pybricks.tools import wait, StopWatch, DataLog
from pybricks.robotics import DriveBase
from pybricks.media.ev3dev import SoundFile, ImageFile
# This program requires LEGO EV3 MicroPython v2.0 or higher.
# Click "Open user guide" on the EV3 extension tab for more information.
# Create your objects here.
ev3 = EV3Brick()
left_motor = Motor(Port.A)
right = Motor(Port.D)
robot = DriveBase(left_motor,right,wheel_diameter=55.5, axle_track=104)
color_left = ColorSensor(Port.S4)
color_right = ColorSensor(Port.S1)
#searchrescue = UltrasonicSensor(Port.S3)
#retrieveright = Motor(Port.C)
#retrieveleft = Motor(Port.B)
# Write your program here.
#In this program, the robot sees all color as shades of gray. If both color sensors detect white, the robot will move forward.
#If one sensor detects
while True:
#if color left detects white
if color_left.reflection() > 50:
#if both sensors detect white, drive
if color_right.reflection() > 50:
robot.drive(100,0)
#else if color right detects black, turn right
elif color_right.reflection() < 50:
right.stop()
left_motor.run(100)
#if color left detects black and;
elif color_left.reflection() < 50:
#color right detects white, turn left
if color_right.reflection() > 50:
robot.stop()
robot.drive(100,100)
#else if both sensor detect black, look for either can (both sensors green) or the hint (one sensor green)
elif color_right.reflection() < 50:
robot.stop()
if color_left.color() == Color.GREEN and color_right.color() == Color.GREEN:
robot.brake()
robot.straight(60)
robot.brake()
while capsulefound == 0:
if searchrescue.distance() < 100:
robot.straight(ultrasonic.distance-10)
#retrieve.run_target(40,90)
#find and follow green line to exit
#use color instead of reflected light intensity
robot.drive (40,0)
while outofspill == 0:
#robot will now run line following code with slight modifications to exit chem spill
if color_left.reflection() > 50 or color_right.reflection() > 50:
robot.straight(20)
robot.turn(-90)
elif color_left.color() == Color.GREEN and color_right.color() == Color.WHITE:
robot.drive(40,0)
elif color_left.color() == Color.GREEN and color_right.color() == Color.GREEN:
right.brake()
left_motor.run(40)
elif color_left.color() == Color.WHITE:
left_motor.brake()
right.run(40)
elif color_left.color() == Color.GREEN and color_right.color() == Color.BLACK:
robot.brake()
robot.turn(90)
robot.straight(40)
robot.brake()
robot.turn(90)
retrieveright.run_target(40,-90)
retrieveleft.run_target(40,-90)
robot.turn(-90)
outofspill = 1
capsulefound = 1
else:
robot.turn(10)
if color_left.color() == Color.GREEN:
robot.brake()
robot.straight(10)
robot.turn(-90)
elif color_right.color() == Color.GREEN:
robot.brake()
robot.straight(10)
robot.turn(90)
else:
robot.straight(40)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels