Show Menu

pybricks cheatsheet By FLL TechTacos SugarLand Cheat Sheet by

python     flltechtacos     ev3dev     micropython     fll2019     pybricks

Package

pybricks
pybr­icks is a python package which contains all the modules to interact with EV3 Brick and associated hardware

Module

ev3brick
ev3b­rick is a module which contains mehods and class methods to deal with EV3 brick
ev3devices
ev3d­evi­ces is a module that deals with Motor and Sensor classes
parameters
Special kind of Module which deals with constants (Ex: color BLUE, Post.A etc). Also some static sound file names etc.,
tools
Used for dealing with Timing and Datalo­gging. Provides ability print output to terminal, wait and stop watch etc.,
robotics
Provides drivebase functi­ona­lity. This is the module that makes your EV3 Move in different dicrec­tion.

ev3Brick

buttons()
Method that get a List of buttons pressed
light
(Color)
Method that sets a back color on the brick. Refer to param­eters module for Color constants
soun­d.be­ep(­fre­que­ncy­,du­rat­ion­,vo­lume)
class­method using sound class. Play a beep/tone
sound.beeps
(number)
class­method using sound class. Play a number of default beeps with a brief pause in between.
sound.file
(file_name,volume)
class­method using sound class. Play a sound file.
disp­lay­.c­lear()
class­method of display on the brick.
Clear everything on the display.
disp­lay­.t­ex­t(t­ext­,co­rdi­nate)
class­method of display.
Takes inputs and displays on the brick LCD panel
batt­ery­.v­oltage
class­method of battery.
Get the voltage of the battery
batt­ery­.c­urrent
class­method of battery.
Get the current supplied by the brick

ev3devices

Motor
(port, direct­ion­=Di­rec­tio­n.C­LOC­KWISE, gears=­None)
Class that provides dealing with each Motor
Touc­hSe­nso­r(p­ort)
Deals with Touch
Colo­rSe­nso­r(p­ort)
Reads Color
Infr­are­dSe­nso­r(p­ort)
Gets the distance using infrared light
UltrasonicSensor
(port)
Gets the distance using sound waves
Gyro­Sen­sor­(port, direct­ion­=Di­rec­tio­n.C­LOC­KWI­SE)
Used for measuring the robot’s rotational motion. Helps in creating balncing Robots
 

Motor Methods

angle()
Get the rotation angle of the motor.
reset_angle
(angle)
Reset the angle of the motor
speed()
Get the speed (angular velocity) of the motor.
stop
(stop_type=Stop.COAST)
Stop the motor. Refer to Stop in parameters to see available stop types
run(speed)
Keep the motor running at a constant speed (angular velocity).
run_time
(speed, time, stop_t­ype­=St­op.C­OAST, wait=True)
Run the motor at a constant speed (angular velocity) for a given amount of time
run_angle
(speed, rotati­on_­angle, stop_t­ype­=St­op.C­OAST, wait=True)
Run the motor at a constant speed (angular velocity) by a given angle.
run_target
(speed, target­_angle, stop_t­ype­=St­op.C­OAST, wait=True)
Run the motor at a constant speed (angular velocity) towards a given target angle.
track_target
(target_angle)
Track a target angle that varies in time.
This method is useful in fast loops where the motor target changes contin­uously.
stalled()
Check whether the motor is currently stalled.
run_until_stalled
(speed, stop_t­ype­=St­op.C­OAST, duty_l­imi­t=d­efault)
Run the motor at a constant speed (angular velocity) until it stalls. The motor is considered stalled when it cannot move even with the maximum torque.

Motor Methods ...

set_dc_settings
(duty_limit, duty_o­ffset)
Configure the settings to adjust the behavior of the dc() command. This also affects all of the run commands, which use the dc() method in the backgr­ound.
set_run_settings
(max_speed, accele­ration)
Configure the maximum speed and accele­rat­ion­/de­cel­eration of the motor for all run commands. This applies to the run, run_­time, run_­ang­le, run_­tar­get, or run_­unt­il_­sta­lled commands you give the motor. See also the default parameters for each motor.
set_pid_settings
(kp, ki, kd, tight_­loo­p_l­imit, angle_­tol­erance, speed_­tol­erance, stall_­speed, stall_­time)
Configure the settings of the position and speed contro­llers. See also pid and the default parameters for each motor.
 

TouchS­ensor

pressed
Returns true or false

ColorS­ensor

color()
Measures the color of surface
ambient()
Measures the ambient light intensity
reflec­tion()
Measure the reflection of a surface using a red light.
rgb()
Measure the reflection of a surface using a red, green, and then a blue light.

Infrar­edS­ensor

distance()
Measure the relative distance between the sensor and an object using infrared light.
beacon
(channel)
Measure the relative distance and angle between the remote and the infrared sensor.
buttons
(channel)
Check which buttons on the infrared remote are pressed.

Ultrasonic Sensor

distance
silent=False)
Measure the distance between the sensor and an object using ultrasonic sound waves.
presence()
Check for the presence of other ultrasonic sensors by detecting ultrasonic sounds.

Gyroscopic Sensor

speed()
Get the speed (angular velocity) of the sensor.
angle()
Get the accumu­lated angle of the sensor.
reset_angle
(angle)
Set the rotation angle of the sensor to a desired value.

parameters

Port
...
Direction
...
Stop
...
Color
...
Button
...
Align
...
ImageFile
Inform­ation, LEGO, Objects and Eyes
SoundFile
Expres­sions (CHEERING etc.,), Inform­ation, Commun­ica­tion, Movements, Color, Mechan­ical, Animals, Numbers and System

Tools

print
(value, ..., sep, end, file, flush)
Print values on the terminal or a stream.
wait(time)
Pause the user program for a specified amount of time.
Stop­Watch Class
A stopwatch to measure time intervals. Similar to the stopwatch feature on your phone.
Supported Methods:
time, pause, resume, reset

robotics

DriveBase
(left_motor, right_­motor, wheel_­dia­meter, axle_t­rack)
Class repres­enting a robotic vehicle with two powered wheels and optional wheel caster(s).

robotics Methods

drive
(speed, steering)
Start driving at the specified speed and turnrate, both measured at the center point between the wheels of the robot.
drive_time
(speed, steering, time)
Drive at the specified speed and turnrate for a given amount of time, and then stop.
stop
(stop_type=Stop.COAST)
Stop the robot.

Download the pybricks cheatsheet By FLL TechTacos SugarLand Cheat Sheet

3 Pages
//media.cheatography.com/storage/thumb/flltech2019_pybricks-cheatsheet-by-fll-techtacos-sugarland.750.jpg

PDF (recommended)

Alternative Downloads

Share This Cheat Sheet!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.