14 KiB
Notation
(value)
(d! dropdown)
<boolean>
(m! display matrix picker)
Hub
- DONE
initialize hub (d! top_side = Axis.Z) (d! front_size = Axis.X)
- transpiled:
hub = PrimeHub(top_side, front_side)
- transpiled:
Hub - Status Light
-
DONE
set button color to (d! color)
- transpiled:
hub.light.on(color)
- transpiled:
-
DONE
turn off button light
- transpiled:
hub.light.off()
- transpiled:
todo: light.blink todo: light.animate
Hub - Display
-
set display orientation to (d! side)
- transpiled:
hub.display.orientation(side)
- transpiled:
-
DONE
turn display off
- transpiled:
hub.display.off()
- transpiled:
-
DONE
set (m! row, col) to (brightness %) brightness
- transpiled:
hub.display.pixel(row, col, brightness)
- transpiled:
-
DONE
show (m! picutre) on display
- transpiled:
hub.display.icon(picture)
- transpiled:
todo: display.animate
-
DONE
show (number) on display
- transpiled:
hub.display.number(number)
- transpiled:
-
show (char) on display
- transpiled:
hub.display.char(char)
- transpiled:
-
DONE
scroll (text) on display
- transpiled:
hub.display.text(text)
- transpiled:
-
scroll (text) on display, on for (on) off for (off)
- transpiled:
hub.display.text(text, on, off)
- transpiled:
Hub - Buttons
!- (buttons pressed)
! - transpiled: hub.buttons.pressed()
- DONE
<is (d! button) button pressed?>
- transpiled:
button in hub.buttons.pressed()
- transpiled:
Hub - IMU
-
DONE
<imu ready?>
- transpiled:
hub.imu.ready()
- transpiled:
-
DONE
<is moving?>
- transpiled:
!hub.imu.stationary()
- transpiled:
-
(side facing up)
- transpiled:
hub.imu.up()
- transpiled:
-
DONE
(pitch)
- transpiled:
hub.imu.tilt()[0]
- transpiled:
-
DONE
(roll)
- transpiled:
hub.imu.roll()[1]
- transpiled:
-
DONE
(acceleration (d! axis))
- transpiled:
hub.imu.acceleration(axis)
- transpiled:
-
DONE
(angular velocity (d! axis))
- transpiled:
hub.imu.angular_velocity(axis)
- transpiled:
-
DONE
(yaw)
- transpiled:
hub.imu.heading()
- warning: must be reset if lifted from table
- reset in prelude?
- transpiled:
-
DONE
reset yaw angle
- transpiled:
hub.imu.reset_heading(0)
- transpiled:
-
DONE
reset yaw angle to (degrees)
- transpiled:
hub.imu.reset_heading(degrees)
- transpiled:
todo: imu.rotation todo: imu.orientation
-
DONE
(angular velocity threshold)
- transpiled:
hub.imu.settings()[0]
- transpiled:
-
DONE
(acceleration threshold)
- transpiled:
hub.imu.settings()[1]
- transpiled:
-
DONE
set angular velocity threshold to (threshold)
- transpiled:
hub.imu.settings(threshold, hub.imu.settings()[1])
- transpiled:
-
DONE
set acceleration threshold to (threshold)
- transpiled:
hub.imu.settings(hub.imu.settings()[0], threshold)
- transpiled:
Hub - Speaker
-
(volume)
- transpiled:
hub.speaker.volume()
- transpiled:
-
set speaker volume to (volume)
- transpiled:
hub.speaker.volume(volume)
- transpiled:
-
play tone (frequency) for (ms) ms
- transpiled:
hub.speaker.beep(frequency, ms)
- transpiled:
-
start playing tone (frequency)
- transpiled:
hub.speaker.beep(frequency, -1)
- transpiled:
todo: speaker.play_notes
TODO: Hub - Bluetooth
Not legal for competition, so I skipped it. Easy to design though, for late.r
Hub - Battery
-
(battery voltage)
- transpiled:
hub.battery.voltage()
- transpiled:
-
(battery current)
- transpiled:
hub.battery.current()
- transpiled:
-
<charger connected?>
- transpiled:
hub.charger.connected()
- transpiled:
-
(charging current)
- transpiled:
hub.charger.current()
- transpiled:
-
<is charging?>
- transpiled:
hub.charger.status() == 1
- transpiled:
-
<is charging complete?>
- transpiled:
hub.charger.status() == 2
- transpiled:
-
<is charging stopped?>
- transpiled:
hub.charger.status() == 3
- transpiled:
Hub - Control
-
set stop button to (button)
- transpiled:
hub.system.set_stop_button(button)
- transpiled:
-
(hub name)
- transpiled:
hub.system.name()
- transpiled:
todo: system.storage
-
DONE
stop and exit program
- program terminator- transpiled: prelude code, go back to selection screen
-
DONE
stop and restart program
- program terminator- transpiled: prelude code, exit, run again
-
DONE
stop and shutdown system
- program terminator- transpiled:
hub.system.shutdown()
- transpiled:
-
<last shut down normally?>
- transpiled:
hub.system.reset_reason() == 0
- transpiled:
-
<last shut down automatically?>
- transpiled:
hub.system.reset_reason() == 1
- transpiled:
-
<last shut down by crash?>
- transpiled:
hub.system.reset_reason() == 2
- transpiled:
Motors
Motors - DC
-
turn on dc motor (port) at (power) power
- transpiled:
motor.dc(power)
- transpiled:
-
stop dc motor (port)
- transpiled:
motor.stop()
- transpiled:
-
set max voltage of dc motor (port) to (voltage)
- transpiled:
motor.settings(voltage)
- transpiled:
-
(max voltage of dc motor (port))
- transpiled:
motor.settings()[0]
- transpiled:
-
set positive direction of dc motor (port) to (d! direction)
- transpiled: RESET motor variable with the direction
Motors
set positive direction of motor (port) to (d! direction)
- traspiled: RESET motor variable with the direction
todo: geartrain todo: reset_angle
-
((port) rotation angle)
- transpiled:
motor.angle()
- transpiled:
-
reset rotation angle of (port)
- transpiled:
motor.reset_angle(0)
- transpiled:
-
reset rotation angle of (port) to (deg)
- transpiled:
motor.reset_angle(deg)
- transpiled:
-
((port) current speed)
- transpiled:
motor.speed()
- transpiled:
-
((port) current load)
- transpiled:
motor.load()
- transpiled:
-
<(port) is stalled?>
- transpiled:
motor.stalled()
- transpiled:
-
(port) stop moving
- transpiled:
motor.stop()
- transpiled:
-
(port) brake
- transpiled:
motor.brake()
- transpiled:
-
(port) stop and hold position
- transpiled:
motor.hold()
- transpiled:
-
(port) start moving at (speed)
- transpiled:
motor.run(speed)
- transpiled:
-
(port) start moving at (power) power
- transpiled:
motor.dc(power)
- transpiled:
-
(port) run for (time) seconds at (speed) speed, then (d! stop action)
- transpiled:
motor.run_time(speed, time, stop action, True)
- transpiled:
-
(port) start running for (time) seconds at (speed) speed, then (d! stop action)
- transpiled:
motor.run_time(speed, time, stop action, False)
- transpiled:
-
(port) run for (deg) degrees at (speed), then (d! stop action)
- transpiled:
motor.run_angle(speed, deg, stop action, True)
- transpiled:
-
(port) start running for (deg) degrees at (speed), then (d! stop action)
- transpiled:
motor.run_angle(speed, deg, stop action, False)
- transpiled:
-
(port) go to relative position (deg) at (speed), then (d! stop action)
- transpiled:
motor.run_target(speed, deg, stop action, True)
- transpiled:
-
(port) start moving to relative position (deg) at (speed), then (d! stop action)
- transpiled:
motor.run_target(speed, deg, stop action, False)
- transpiled:
-
(port) go to relative position (deg) immediately
- transpiled:
motor.track_target(deg)
- transpiled:
-
(port) run at (speed) speed until stalled, then (d! stop action)
- transpiled:
motor.run_until_stalled(speed, stop action)
- transpiled:
-
(port) run at (speed) speed until stalled, then (d! stop action), with maximum power (power)
- transpiled:
motor.run_until_stalled(speed, stop action, power)
- transpiled:
-
<(port) is done moving?>
- transpiled:
motor.done()
- transpiled:
-
((port) max speed)
- transpiled:
motor.limits()[0]
- transpiled:
-
((port) max acceleration)
- transpiled:
motor.limits()[1]
- transpiled:
-
((port) max torque)
- transpiled:
motor.limits()[2]
- transpiled:
-
set (port) max speed to (speed)
- transpiled:
motor.limits(speed, motor.limits()[1], motor.limits()[2])
- transpiled:
-
set (port) max acceleration to (accel)
- transpiled:
motor.limits(motor.limits()[0], accel, motor.limits()[2])
- transpiled:
-
set (port) max torque to (torq)
- transpiled:
motor.limits(motor.limits()[0], motor.limits()[1], torq)
- transpiled:
TODO: pid TODO: tolerances TODO: stall tolerances TODO: scale TODO: state TODO: settings
Tilt Sensor
((port) pitch)
- transpiled:
sensor.tilt()[0]
- transpiled:
((port) roll)
- transpiled:
sensor.tilt()[1]
- transpiled:
Infrared Sensor
((port) infrared distance)
- transpiled:
sensor.distance()
- transpiled:
((port) infrared reflection)
- transpiled:
sensor.reflection()
- transpiled:
((port) object count)
- transpiled:
sensor.count()
- transpiled:
Color and Distance Sensor
<(port) color is (d! color)?>
- transpiled:
sensor.color() == color
- transpiled:
((port) reflection)
- transpiled:
sensor.reflection()
- transpiled:
((port) intensity)
- transpiled:
sensor.ambient()
- transpiled:
((port) infrared distance)
- transpiled:
sensor.distance()
- transpiled:
TODO: detectable_colors
set (port) light to (d! color RGB)
- transpiled:
sensor.light.on(color)
- transpiled:
turn off (port) light
- transpiled:
sensor.light.off()
- transpiled:
TODO - Power Functions Infrared Controls
Color Sensor
<(port) color is (d! color)?>
- transpiled:
sensor.color() == color
- transpiled:
((port) reflection)
- transpiled:
sensor.reflection()
- transpiled:
((port) intensity)
- transpiled:
sensor.ambient()
- transpiled:
((port) hue)
- transpiled:
sensor.hsv().h
- transpiled:
((port) saturation)
- transpiled:
sensor.hsv().s
- transpiled:
((port) brightness)
- transpiled:
sensor.hsv().v
- transpiled:
TODO: detectable_colors
turn on (port) light at (power) brightness
- transpiled:
sensor.lights.on(power)
- transpiled:
turn off (port) light
- transpiled:
sensor.lights.off()
- transpiled:
Ultrasonic Sensor
((port) distance)
- transpiled:
sensor.distance()
- transpiled:
<(port) other ultrasonic sensors nearby?>
- transpiled:
sensor.presence()
- transpiled:
turn on (port) light at (power) brightness
- transpiled:
sensor.lights.on(power)
- transpiled:
turn off (port) light
- transpiled:
sensor.lights.off()
- transpiled:
Force Sensor
((port) force)
- transpiled:
sensor.force()
- transpiled:
((port) distance travelled)
- transpiled:
sensor.distance()
- transpiled:
<(port) pressed?>
- transpiled:
sensor.pressed()
- transpiled:
<(port) touched?>
- transpiled:
sensor.touched()
- transpiled:
TODO - Color Light Matrix
Light
turn on (port) at (power) brightness
- transpiled:
sensor.on(power)
- transpiled:
turn off (port)
- trnaspiled:
sensor.off()
- trnaspiled:
TODO - Remote Control
Constants
Constants - Axis
(x axis)
- transpiled:
Axis.X
- transpiled:
(y axis)
- transpiled:
Axis.Y
- transpiled:
(z axis)
- transpiled:
Axis.Z
- transpiled:
Constants - Button
(left button)
- transpiled:
Button.LEFT
- transpiled:
(center button)
- transpiled:
Button.CENTER
- transpiled:
(right button)
- transpiled:
Button.RIGHT
- transpiled:
(bluetooth button)
- transpiled:
Button.BLUETOOTH
- transpiled:
Constants - Stop Behavior
coast
- transpiled:
Stop.COAST
- transpiled:
preplanned coast
- transpiled:
Stop.COAST_SMART
- transpiled:
brake
- transpiled:
Stop.BRAKE
- transpiled:
hold position
- transpiled:
Stop.HOLD
- transpiled:
do not stop
- transpiled:
Stop.NONE
- transpiled:
Tools
wait (ms) ms
- transpiled:
tools.wait(ms)
- transpiled:
TODO - Tools - Stopwatch
Movement (Robotics)
-
set movement motors to (left port) and (right port)
- transpiled:
left_motor = left port; right_motor = right port; drive = DriveBase(left_motor, right_motor, wd, track)
- transpiled:
-
set wheel diameter to (mm) mm
- transpiled:
wd = mm; drive = DriveBase(left_motor, right_motor, wd, track)
- transpiled:
-
set track width to (mm) mm
- transpiled:
track = mm; drive = DriveBase(left_motor, right_motor, wd, track)
- transpiled:
-
move (mm) mm, then (d! stop)
- transpiled:
drive.straight(mm, stop, True)
- transpiled:
-
start moving (mm) mm, then (d! stop)
- transpiled:
drive.straight(mm, stop, False)
- transpiled:
-
turn in place (deg) degrees, then (d! stop)
- transpiled:
drive.turn(deg, stop, True)
- transpiled:
-
start turning in place (deg) degrees, then (d! stop)
- transpiled:
drive.turn(deg, stop, False)
- transpiled:
-
turn (deg) degrees across a (rad) mm arc, then (d! stop)
- transpiled:
drive.curve(rad, deg, stop, True)
- transpiled:
-
start turning (deg) degrees across a (rad) mm arc, then (d! stop)
- transpiled:
drive.curve(rad, deg, stop, False)
- transpiled:
-
(movement speed)
- transpiled:
drive.settings()[0]
- transpiled:
-
(movement acceleration)
- transpiled:
drive.settings()[1]
- transpiled:
-
(turn speed)
- transpiled:
drive.settings()[2]
- transpiled:
-
(turn acceleration)
- transpiled:
drive.settings()[3]
- transpiled:
-
set movement speed to (speed)
- transpiled:
drive.settings(speed, drive.settings()[1], drive.settings()[2], drive.settings()[3])
- transpiled:
-
set movement acceleration to (speed)
- transpiled:
drive.settings(drive.settings()[0], speed, drive.settings()[2], drive.settings()[3])
- transpiled:
-
set turn speed to (speed)
- transpiled:
drive.settings(drive.settings()[0], drive.settings()[1], speed, drive.settings()[3])
- transpiled:
-
set turn acceleration to (speed)
- transpiled:
drive.settings(drive.settings()[0], drive.settings()[1], drive.settings()[2], speed)
- transpiled:
-
<is done moving?>
- transpiled:
drive.done()
- transpiled:
-
start moving at (spd) speed
- transpiled:
drive.drive(spd, 0)
- transpiled:
-
start moving at (spd) speed with turn rate (tr)
- transpiled:
drive.drive(spd, tr)
- transpiled:
-
stop moving
- transpiled:
drive.stop()
- transpiled:
-
(relative distance)
- transpiled:
drive.distance()
- transpiled:
-
(relative angle)
- transpiled:
drive.angle()
- transpiled:
-
(current drive speed)
- transpiled:
drive.state()[1]
- transpiled:
-
(current turn rate)
- transpiled:
drive.state()[3]
- transpiled:
-
reset angle and distance
- transpiled:
drive.reset()
- transpiled:
-
<is stalled?>
- transpiled:
drive.stalled()
- transpiled:
-
use gyroscope for movement
- transpiled:
drive = GyroDriveBase(left_motor, right_motor, wd, track)
- transpiled:
-
use math for movement
- transpiled:
drive = DriveBase(left_motor, right_motor, wd, track)
- transpiled:
Random
(random number from (a) to (b))
- transpiled:
urandom.randint(a, b)
- transpiled:
(random decimal from 0 to 1)
- transpiled:
urandom.random()
- transpiled:
Control
repeat (n)
- transpiled:
for i in range(n):
- transpiled:
forever
- transpiled:
while True:
- transpiled:
if <cond> then
- transpiled:
if cond:
- transpiled:
if <cond> then else
- transpiled:
if cond: else:
- transpiled:
wait until <cond>
- transpiled:
while !<cond>: pass
- transpiled:
repeat until <cond>
- transpiled:
while !cond:
- transpiled:
stop
- transpiled:
raise SystemExit("Exited by program")
- transpiled:
Operators
((a) + (b))
- transpiled:
a + b
- transpiled:
((a) - (b))
- transpiled:
a - b
- transpiled:
((a) * (b))
- transpiled:
a * b
- transpiled:
((a) / (b))
- transpiled:
a / b
- transpiled:
<(a) > (b)>
- transpiled:
a > b
- transpiled:
<(a) < (b)>
- transpiled:
a < b
- transpiled:
<(a) = (b)>
- transpiled:
a == b
- transpiled:
<<a> and <b>>
- transpiled:
a and b
- transpiled:
<<a> or <b>>
- transpiled:
a or b
- transpiled:
<not <a>>
- transpiled:
not a
- transpiled:
(join (a) (b))
- transpiled:
a + b
- transpiled:
(letter (n) of (a))
- transpiled:
a[n]
- transpiled:
(length of (a))
- transpiled:
len(a)
- transpiled:
<(a) contains (b)?>
- transpiled:
a in b
- transpiled:
((a) mod (b))
- transpiled:
a % b
- transpiled:
(round (a))
- transpiled:
round(a)
- transpiled:
TODO: operators
Variables
Variables are stored as python variables with the prefix UVAR
- for example UVAR_myvar
My blocks
re just functions