Super stupid questions - sorry-- what version do I have ? #935
Replies: 12 comments 10 replies
-
Glad to hear you are enjoying using Pybricks. We have been focused on newer hubs and Pybricks Code for the last few years so we haven't made any official updates for EV3. You can grab the latest build like this (run this on EV3 connected to the internet):
Then you can can |
Beta Was this translation helpful? Give feedback.
-
For the debian package version:
|
Beta Was this translation helpful? Give feedback.
-
David, thanks for your help.
most of the micropython stuff on my EV'3 is
located in
/usr/lib/pybricks-micropython/
Threre are a TON of .mpy files in there. The zip
file that you told me to curl unzips to just one executable.
Will that executable still be using the "old" un-updated
.mpy files -- or are the .mpy files not important?
Thank you,
…---Lou
On 2023-02-03 18:47, David Lechner wrote:
Glad to hear you are enjoying using Pybricks.
We have been focused on newer hubs and Pybricks Code for the last few
years so we haven't made any official updates for EV3.
You can grab the latest build like this (run this on EV3 connected to
the internet):
curl -k -L
https://nightly.link/pybricks/pybricks-micropython/workflows/build/master/pybricks-micropython-build-2436.zip
-O
unzip pybricks-micropython-build-2436.zip
chmod +x pybricks-micropython
Then you can can sudo mv pybricks-micropython /usr/local/bin/ to
override the debian package version of pybricks-micropython or change
the shebang in you Python programs to specify the exactly location
(e.g. #!/home/robot/pybricks-micropython).
--
Reply to this email directly, view it on GitHub [1], or unsubscribe
[2].
You are receiving this because you authored the thread.Message ID:
***@***.***>
Links:
------
[1]
#935 (comment)
[2]
https://github.com/notifications/unsubscribe-auth/AOU7DDENZ27NZY5OBZCOKQDWVWKKNANCNFSM6AAAAAAUQY7OBA
|
Beta Was this translation helpful? Give feedback.
-
after replacing the executable with the new one I get this
error
Starting: brickrun --directory="/home/robot/jerry_test_1"
"/home/robot/jerry_test_1/main.py"
----------
Traceback (most recent call last):
File "/home/robot/jerry_test_1/main.py", line 19, in <module>
ValueError: incompatible .mpy file
----------
Exited with error code 1.
So the .mpy files are not compatible?
…On 2023-02-05 20:49, David Lechner wrote:
The .mpy files are not essential. All of the essential libraries are
"frozen" in the executable file so the one file is all that is needed.
--
Reply to this email directly, view it on GitHub [1], or unsubscribe
[2].
You are receiving this because you authored the thread.Message ID:
***@***.***>
Links:
------
[1]
#935 (reply in thread)
[2]
https://github.com/notifications/unsubscribe-auth/AOU7DDHHKPGPA7OVOC3LYPDWWBKBJANCNFSM6AAAAAAUQY7OBA
|
Beta Was this translation helpful? Give feedback.
-
As a word of caution, I would like to add that motors are currently not fully updated in V3. We updated the motor control algorithms, but we did not yet update the control parameters for NXT/EV3 since we are not using them actively. As a result, they may not work as expected at this time. But if you go ahead with this, we can probably try having a look at this 😄 |
Beta Was this translation helpful? Give feedback.
-
David, here is our robot code. We use many includes,
but we are not really experts.. Can you tell me if there
is a better way?
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
# i2c device for gyro hard reset.
from pybricks.iodevices import I2CDevice
from pybricks.parameters import Port
# uart device for future use
from pybricks.iodevices import UARTDevice
On 2023-02-06 10:47, David Lechner wrote:
Which imports are you using? You can probably get around this by
importing the uspam version of modules instead of spam. If you really
need something from micropython-lib you can copy a .py version to your
local program directory.
--
Reply to this email directly, view it on GitHub [1], or unsubscribe
[2].
You are receiving this because you authored the thread.Message ID:
***@***.***>
Links:
------
[1]
#935 (reply in thread)
[2]
https://github.com/notifications/unsubscribe-auth/AOU7DDBGBLIVBMQLXXI4NN3WWEMI5ANCNFSM6AAAAAAUQY7OBA
#!/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
# i2c device for gyro hard reset.
from pybricks.iodevices import I2CDevice
from pybricks.parameters import Port
# uart device for future use
from pybricks.iodevices import UARTDevice
import random
#from ev3dev2.sensor.lego import GyroSensor
# This program requires LEGO EV3 MicroPython v2.0 or higher.
# Click "Open user guide" on the EV3 extension tab for more information.
# /sys/class/lego-sensor/
# gyro driver : lego-ev3-gyro
this_robot_name="UNKNOWN"
last_direction_rotated_to =0
idle = 55
group = 1
# Create your objects here.
jerry = EV3Brick()
jerry.speaker.beep(300,100)
right_motor = Motor(Port.C)
jerry.speaker.beep(600,100)
left_motor = Motor(Port.A)
jerry.speaker.beep(900,100)
fork_motor = Motor(Port.B)
jerry.speaker.beep(1200,100)
gyro = GyroSensor(Port.S2,Direction.CLOCKWISE)
jerry.speaker.beep(1500,100)
#left_color= ColorSensor(Port.S1)
#right_color= ColorSensor(Port.S3)
jerry_stop_watch = StopWatch()
#device = I2CDevice(Port.S2, 0x22)
# ----------------------------------------------------------------------
# this code turns the robot so many degrees
# this is a re-do of the lego desigher graphic version to python rewrite (2022)
# ----------------------------------------------------------------------
def rotate_robot(angle,turn_speed,reset):
global last_direction_rotated_to # this make it so that other functions can share this varaible
min_velocity = 20
max_turn_error = 1
minimum_degrees_to_motor = 1
if (reset!=0):
gyro.reset_angle(0)
actual_angle = gyro.angle()
error = (actual_angle-angle)
degree_tire_rotation_for_1_complete_robot_turn= 565 # measured emperically
while(abs(error)>max_turn_error):
how_many_tire_degress = error*(degree_tire_rotation_for_1_complete_robot_turn/360)
how_many_tire_degress = how_many_tire_degress *0.99
if (how_many_tire_degress<0):
if (how_many_tire_degress>(-1*minimum_degrees_to_motor)):
how_many_tire_degress = -1*minimum_degrees_to_motor
if (how_many_tire_degress>0):
if (how_many_tire_degress<(minimum_degrees_to_motor)):
how_many_tire_degress = minimum_degrees_to_motor
lmd = int (how_many_tire_degress)
rmd = int(-1*how_many_tire_degress)
#print ("LMD=",lmd," RMD=",rmd," Desired angle =",angle," turn_speed=",turn_speed," error =",error," Angle= " , actual_angle, "how_many_tire_degress =",how_many_tire_degress)
right_motor.reset_angle(0)
left_motor.reset_angle(0)
left_motor.run_target(turn_speed,lmd,wait=False)
right_motor.run_target(turn_speed,rmd,wait=True)
actual_angle = gyro.angle()
error = (actual_angle-angle)
print ("turn complete, final angle =",actual_angle)
right_motor.hold()
last_direction_rotated_to =angle
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
def super_test_rotate_robot():
a=90
s=100
while(True):
rotate_robot(-a,s,0)
wait(300)
rotate_robot(a,s,0)
wait(300)
#a=a-1
if(a==0):
a=180
s=s+50
if(s>700):
s=100
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
def get_2_sec_gyro_drift():
a1 = gyro.angle()
wait(2000)
a2 = gyro.angle()
print ("Drivt =",(a1-a2))
dr=abs(a1-a2)
return (dr)
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
def test_gyro_drift():
d=get_2_sec_gyro_drift()
e=get_2_sec_gyro_drift()
if((d>1) and (e>1)):
while(True):
jerry.speaker.beep(500,100)
jerry.speaker.beep(100,100)
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# this code turns the robot so many degrees
# ----------------------------------------------------------------------
def OLD__rotate_robot(angle,turn_speed,reset):
global last_direction_rotated_to # this make it so that other functions can share this varaible
min_velocity = 20
max_turn_error = 3
if (reset!=0):
gyro.reset_angle(0)
if (angle==0):
angle=0.1
target_speed =turn_speed
accl = 0
actual_angle = gyro.angle()
total_angle_needed = actual_angle - angle
if (total_angle_needed <0):
total_angle_needed = total_angle_needed *-1
outer_loops=0
while (abs(actual_angle-angle)>max_turn_error):
outer_loops=outer_loops+1
while(actual_angle<angle):
if (target_speed<turn_speed):
target_speed = target_speed + accl
#error = (angle - actual_angle)/angle
error = (angle - actual_angle)/total_angle_needed
if (error<0):
error = error *-1
velocity = target_speed * error
if (velocity<min_velocity):
velocity = min_velocity
right_motor.run(velocity*1)
left_motor.run(velocity*-1)
actual_angle = gyro.angle()
jerry.screen.clear()
angle_to_print = "Gyro =%d H=%d" % (actual_angle,angle)
jerry.screen.draw_text(0, 40, angle_to_print)
while(actual_angle>angle):
if (target_speed<turn_speed):
target_speed = target_speed + accl
error = (angle - actual_angle)/total_angle_needed
if (error<0):
error = error *-1
velocity = target_speed * error
if (velocity< min_velocity):
velocity = min_velocity
right_motor.run(velocity*-1)
left_motor.run(velocity* 1)
actual_angle = gyro.angle()
jerry.screen.clear()
#print_stats_to_screen()
angle_to_print = "Gyro =%d H=%d" % (actual_angle,angle )
jerry.screen.draw_text(0, 40, angle_to_print)
#wait(1) #added 2/2/2022
right_motor.hold()
left_motor.hold()
# let the gyro settle
wait(100)
actual_angle = gyro.angle()
#print ("main error loop error = ",abs(angle-actual_angle),"outer loops =",outer_loops )
last_direction_rotated_to =angle
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# make robot gostraight. This tirns on the left and right motor for a certan amount
# ----------------------------------------------------------------------
def make_robot_go_straight (degrees_tire_rotation,speed):
right_motor.reset_angle(0)
left_motor.reset_angle(0)
right_motor.run_target(speed,degrees_tire_rotation,wait=False)
left_motor.run_target(speed,degrees_tire_rotation,wait=False)
while(right_motor.control.done()==False):
actual_angle = gyro.angle()
print ("Actual angle = ",actual_angle,)
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# make robot go in a certan direction. This will adjusts the motors a little
# to accomodate for tire slippage -- but this requires tha the Gyro work.
# ----------------------------------------------------------------------
def make_robot_go_straight_with_gyro (degrees_tire_rotation,degrees_desired_headding,speed):
global last_direction_rotated_to # this make it so that other functions can share this varaible
degrees_tire_rotation=int(degrees_tire_rotation)
degrees_desired_headding=int(degrees_desired_headding)
if (degrees_desired_headding!=-999):
degrees_desired_headding=int(degrees_desired_headding)
last_direction_rotated_to = degrees_desired_headding
else:
degrees_desired_headding = int(last_direction_rotated_to)
print("MRGSWGRO DDH=",degrees_desired_headding)
right_motor.reset_angle(0)
left_motor.reset_angle(0)
right_motor.run_target(speed,degrees_tire_rotation,wait=False)
left_motor.run_target(speed,degrees_tire_rotation,wait=False)
right_adjust =0
left_adjust =0
rms=0
lms=0
while ( (degrees_tire_rotation != right_motor.angle()) and (degrees_tire_rotation != left_motor.angle()) ):
actual_angle = gyro.angle()
jerry.screen.clear()
jerry.screen.draw_text(40, 50, actual_angle)
jerry.screen.draw_text(50, 50, degrees_desired_headding)
#wait(1) #added 2/2/2022
if (degrees_tire_rotation> 0):
gain = 5
if (degrees_tire_rotation<0):
gain = 5
#print ("Actual angle = ",actual_angle," degrees_desired_headding =",degrees_desired_headding, "Rt adjust =",right_adjust," Lt adjust = ",left_adjust," RMA =",right_motor.angle()," LMA =",left_motor.angle()," RMS=",rms," LMS=",lms)
error = degrees_desired_headding -actual_angle
if (error>10):
error = 10
if (error<-10):
error = -10
if (degrees_tire_rotation> 0):
right_adjust = error * gain
left_adjust = error * gain * -1
if (degrees_tire_rotation< 0):
right_adjust = error * gain *-1
left_adjust = error * gain
rms = speed+right_adjust
if (rms>1000):
rms = 1000
if (rms<30):
rms = 30
lms = speed+left_adjust
if (lms>1000):
lms = 1000
if (lms<30):
lms =30
#print ("rms= ",rms," lms =",lms," Err = ",error," Headding =",degrees_desired_headding, "target deg tor",degrees_tire_rotation )
right_motor.run_target(rms,degrees_tire_rotation,wait=False)
left_motor.run_target(lms,degrees_tire_rotation,wait=False)
right_motor.hold()
left_motor.hold()
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# make robot floow black line on map using 2 color sensors
# ----------------------------------------------------------------------
def folow_line (degrees_tire_rotation,speed):
speed = 200
right_motor.reset_angle(0)
left_motor.reset_angle(0)
right_motor.run_target(speed,degrees_tire_rotation,wait=False)
left_motor.run_target(speed,degrees_tire_rotation,wait=False)
right_adjust =0
left_adjust =0
while ( (degrees_tire_rotation != right_motor.angle()) and (degrees_tire_rotation != left_motor.angle()) ):
left_reflectivity = left_color.reflection()
right_reflectivity = right_color.reflection()
jerry.screen.clear()
l = "Left = %s" % left_reflectivity
jerry.screen.draw_text(40, 40, l)
r= "Right = %s" % right_reflectivity
jerry.screen.draw_text(40, 55, r)
gain = 30
limit = 300
print ("left_ref = ",left_reflectivity,"right_ref =",right_reflectivity, "Rt adjust =",right_adjust," Lt adjust = ",left_adjust," RMA =",right_motor.angle()," LMA =",left_motor.angle())
error = abs (left_reflectivity-right_reflectivity)
if (error > 1):
if (left_reflectivity > right_reflectivity ): # and (left_adjust <limit):
right_adjust = -1* gain*error
left_adjust = gain*error
if ( right_reflectivity > left_reflectivity ): #and (right_adjust <limit):
right_adjust = gain*error
left_adjust = -1* gain*error
rms = speed+right_adjust
if (rms>limit):
rms=limit
lms = speed + left_adjust
if (lms>limit):
lms=limit
print ("RMs=",rms," LMs=",lms)
if(1):
if (rms>50):
right_motor.run_target(rms,degrees_tire_rotation,wait=False)
else:
right_motor.stop()
if (lms>50):
left_motor.run_target(lms,degrees_tire_rotation,wait=False)
else:
left_motor.stop()
right_motor.hold()
left_motor.hold()
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# make robot floow black line on map using 2 color sensors
# ----------------------------------------------------------------------
def folow_line_II (degrees_tire_rotation,duity_cycle):
right_motor.reset_angle(0)
left_motor.reset_angle(0)
right_motor.dc(duity_cycle)
left_motor.dc(duity_cycle)
right_adjust =0
left_adjust =0
while ( (degrees_tire_rotation > right_motor.angle()) and (degrees_tire_rotation > left_motor.angle()) ):
left_reflectivity = left_color.reflection()
right_reflectivity = right_color.reflection()
jerry.screen.clear()
l = "Left = %s" % left_reflectivity
jerry.screen.draw_text(40, 40, l)
r= "Right = %s" % right_reflectivity
jerry.screen.draw_text(40, 55, r)
#wait(1) #added 2/2/2022
gain = .5
limit = 100
error = left_reflectivity-right_reflectivity #this will be positive or negative
print ("Error= ",error," left_ref = ",left_reflectivity,"right_ref =",right_reflectivity, "Rt adjust =",right_adjust," Lt adjust = ",left_adjust," RMA =",right_motor.angle()," LMA =",left_motor.angle())
left_adjust = gain * error
right_adjust = -1* gain*error
if (left_adjust<0):
left_adjust = left_adjust *1.5
if (right_adjust<0):
right_adjust = right_adjust *1.5
rms = duity_cycle + right_adjust
if (rms>limit):
rms=limit
if (rms< (-1*limit)):
rms=-1*limit
lms = duity_cycle + left_adjust
if (lms>limit):
lms=limit
if (lms< (-1*limit)):
lms=-1*limit
print ("RMdc=",rms," LMdc=",lms)
right_motor.dc(rms)
left_motor.dc(lms)
right_motor.brake()
left_motor.brake()
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# this code moves the forks all the way down, and then defines that as 140
# degrees.
# ----------------------------------------------------------------------
def setup_forklift():
#fork_motor.dc(25)
#wait(1000)
#fork_motor.dc(-20)
#print ("control limits of fork motor")
#print (fork_motor.control.limits())
# the idea is to push the forks down until they stop
# moving. Once they are stopped, tell the fork motor
# that that position is 140 degrees.
wait(10)
fork_motor.dc(30)
old_read =0
new_read = 1
times_it_is_stopped =0
while (times_it_is_stopped<10):
if (old_read==new_read):
times_it_is_stopped = times_it_is_stopped +1
wait(100)
old_read = new_read
new_read = fork_motor.angle()
#print ("new read=",new_read," old_read=",old_read)
fork_motor.dc(0)
fork_motor.reset_angle(140)
set_fork_angle(5,300) # now bring the forks almost all the way back up
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# positive numbers move it down (upt to 140), 0 degrees is all the way up
# ----------------------------------------------------------------------
def set_fork_angle(angle,speed):
if (angle>140):
angle=140
if (angle <0):
angle = 0
fork_motor.run_target(speed,angle,wait=True)
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# positive numbers move it down (upt to 140), 0 degrees is all the way up
# ----------------------------------------------------------------------
def flip_forks_up_fast():
fork_motor.dc(-100)
wait(200)
set_fork_angle(20,800)
#fork_motor.run_target(speed,angle,wait=True)
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
def smash_forks_down():
#print("about to do it")
#wait(1000)
fork_motor.dc(100)
wait(100)
#print("Did it")
# ----------------------------------------------------------------------
flip_forks_up_fast
smash_forks_down
# ----------------------------------------------------------------------
# displays the gyro angle on the screen
# ----------------------------------------------------------------------
def display_gyro_angle( ):
actual_angle = gyro.angle()
speed = gyro.speed()
jerry.screen.clear()
angle_to_print = "Gyro =%d" % actual_angle
jerry.screen.draw_text(0, 40, angle_to_print)
jerry.screen.draw_text(40, 50, actual_angle)
jerry.screen.draw_text(50, 50, speed)
print("Angle=",actual_angle," speed=",speed)
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# this is used to beep out the group number, its too slow to use that
# say thing
# NMF 2.3.2022
# ----------------------------------------------------------------------
def beep_this_many_times(times_to_beep):
x=0
while(x<times_to_beep):
jerry.speaker.beep(880*2,50)
wait(50)
x = x +1
# ----------------------------------------------------------------------
# this prints the stopwatch ont he screen
# ----------------------------------------------------------------------
def print_stats_to_screen():
voltage = ""
batt_volts = (jerry.battery.voltage()/1000)
voltage = "Volts = %1.1f" % batt_volts
jerry.screen.draw_text(0,20,voltage)
angle_to_print = "Gyro =%d" % gyro.angle()
jerry.screen.draw_text(0, 40, angle_to_print)
g = "Group = %d" % group
jerry.screen.draw_text(0,70,g)
t = jerry_stop_watch.time()
t = t/1000
t = int(t)
r = 150 - t
if (r<0):
r=0
tmesg ="Ela=%d Rem=%d" % (t,r)
jerry.screen.draw_text(0,100,tmesg)
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# this is the menu that picks the groups that are run by the operator
# ----------------------------------------------------------------------
def run_the_menue():
global group
jerry_stop_watch.reset()
jerry_stop_watch.pause()
while(1):
jerry.screen.clear()
print_stats_to_screen()
batt_volts = (jerry.battery.voltage()/1000)
if (batt_volts <7.4):
jerry.speaker.beep(1760,100)
jerry.speaker.beep(880,100)
jerry.speaker.beep(440,100)
wait(10)
b =jerry.buttons.pressed()
if (b==[]):
wait(1)
#print ("no press",b)
else:
jerry.speaker.beep(2000,10)
if (b[0]==Button.UP):
group=group + 1
if (group>20):
group = 20
if (b[0]==Button.DOWN):
group=group +- 1
if (group<1):
group = 1
if (b[0]==Button.CENTER):
jerry_stop_watch.resume()
while( b!=[]):
b =jerry.buttons.pressed()
groupname = "group %d" % group
#jerry.speaker.say(groupname)
beep_this_many_times(group) #say command was replaced by this becsasue it wastes too much time.
run_mission_group(group)
group = group + 1
while( b!=[]):
b =jerry.buttons.pressed()
wait(100)
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
# ----------------------------------------------------------------------
def run_mission_group(mission_group):
global this_robot_name
gyro.reset_angle(0)
wait(10)
gyro.reset_angle(0)
if (mission_group==1) and (this_robot_name== "JERRY"):
# put up tv, collect windmill EU and collect Recahrable battery 12/9/2022
set_fork_angle(65,500)
make_robot_go_straight_with_gyro(340,0,350) # go to the TV fast.
make_robot_go_straight_with_gyro(75,0,250) #hit the tv, but not too hard
make_robot_go_straight_with_gyro(-50,0,400) #unhit the tv
rotate_robot(45,400,0) # turn the robot
make_robot_go_straight_with_gyro(650,-999,400)
rotate_robot(0,400,0)
make_robot_go_straight_with_gyro(90,-999,200)
rotate_robot(-26,200,0)
make_robot_go_straight_with_gyro(-185,-999,200) #capture recharagbel battery
make_robot_go_straight_with_gyro(70,-999,300) #go gorward, with captured battery
face = -50
rotate_robot(face,400,0) # face windmil
windmil_backup_speed = 300
make_robot_go_straight_with_gyro(340-50,-999,200)
make_robot_go_straight_with_gyro(-200,-999,windmil_backup_speed)
make_robot_go_straight_with_gyro(320,-999,200)
make_robot_go_straight_with_gyro(-200,-999,windmil_backup_speed)
make_robot_go_straight_with_gyro(320,-999,200)
make_robot_go_straight_with_gyro(-200,face,windmil_backup_speed)
make_robot_go_straight_with_gyro(320,-999,200)
make_robot_go_straight_with_gyro(-200,-999,windmil_backup_speed) #special last backup
rotate_robot(92,300,0) #rotate tward hybrid car
make_robot_go_straight_with_gyro(310,-999,300) #go tward hybrid
set_fork_angle(110,300) # bring forks down, to get under the hybrid car lever
rotate_to_car =44
rotate_robot(rotate_to_car,300,0) #rotate paralell to hybrid car
make_robot_go_straight_with_gyro(75,-999,300) # go twards the hybrid car getting fork under lifter
rotate_robot(rotate_to_car+4,200,0) #rotate paralell to hybrid car
# fitst try at hybrid
fork_motor.dc(-80) #flip forkk up fast
wait(150)
fork_motor.dc(50) #flip forkk down fast
wait(200)
fork_motor.dc(0)
rotate_robot(rotate_to_car-3,200,0)
fork_motor.dc(-80) #flip forkk up fast
wait(150)
fork_motor.dc(50) #flip forkk down fast
wait(200)
fork_motor.dc(0)
rotate_robot(rotate_to_car-6,200,0)
fork_motor.dc(-80) #flip forkk up fast
wait(150)
fork_motor.dc(0)
rotate_robot(50,200,0) #turn tward home
make_robot_go_straight_with_gyro(-360*3.5,45,500) # go home5
set_fork_angle(10,700)
return
# the car lever gets stuck on the dino carrier
rotate_robot(78,300,0) #turn twrd the nhand
set_fork_angle(95,700) #get for to height to fit under the hand
make_robot_go_straight_with_gyro(170,999,300) # go to the hand
set_fork_angle(130,700) #lift the hand
#-------------------------- end Jerry mission group 1 ----------------------------
return
return
#-------------------------- end JERRY mission group 1 ----------------------------
if (mission_group==1) and (this_robot_name== "Larry"):
# put up tv, collect windmill EU and collect Recahrable battery 12/9/2022
set_fork_angle(65,500)
make_robot_go_straight_with_gyro(340,0,350) # go to the TV fast.
make_robot_go_straight_with_gyro(75,0,250) #hit the tv, but not too hard
make_robot_go_straight_with_gyro(-50,0,400) #unhit the tv
rotate_robot(45,400,0) # turn the robot
make_robot_go_straight_with_gyro(650,-999,400)
rotate_robot(0,400,0)
make_robot_go_straight_with_gyro(90,-999,200)
rotate_robot(-26,200,0)
make_robot_go_straight_with_gyro(-185,-999,200) #capture recharagbel battery
make_robot_go_straight_with_gyro(70,-999,300) #go gorward, with captured battery
face = -50
rotate_robot(face,400,0) # face windmil
windmil_backup_speed = 300
make_robot_go_straight_with_gyro(340-50,-999,200)
make_robot_go_straight_with_gyro(-200,-999,windmil_backup_speed)
make_robot_go_straight_with_gyro(320,-999,200)
make_robot_go_straight_with_gyro(-200,-999,windmil_backup_speed)
make_robot_go_straight_with_gyro(320,-999,200)
make_robot_go_straight_with_gyro(-200,face,windmil_backup_speed)
make_robot_go_straight_with_gyro(320,-999,200)
make_robot_go_straight_with_gyro(-200,-999,windmil_backup_speed) #special last backup
rotate_robot(92,300,0) #rotate tward hybrid car
make_robot_go_straight_with_gyro(310,-999,300) #go tward hybrid
set_fork_angle(110,300) # bring forks down, to get under the hybrid car lever
rotate_to_car =44
rotate_robot(rotate_to_car,300,0) #rotate paralell to hybrid car
make_robot_go_straight_with_gyro(75,-999,300) # go twards the hybrid car getting fork under lifter
rotate_robot(rotate_to_car+4,200,0) #rotate paralell to hybrid car
# fitst try at hybrid
fork_motor.dc(-80) #flip forkk up fast
wait(150)
fork_motor.dc(50) #flip forkk down fast
wait(200)
fork_motor.dc(0)
wait(100)
rotate_robot(rotate_to_car-4,200,0)
fork_motor.dc(-80) #flip forkk up fast
wait(150)
fork_motor.dc(50) #flip forkk down fast
wait(200)
fork_motor.dc(0)
wait(100)
rotate_robot(rotate_to_car-8,200,0)
wait(200)
fork_motor.dc(-80) #flip forkk up fast
wait(200)
fork_motor.dc(0)
rotate_robot(50,200,0) #turn tward home
make_robot_go_straight_with_gyro(-360*3.5,45,500) # go home5
set_fork_angle(10,700)
return
# the car lever gets stuck on the dino carrier
rotate_robot(78,300,0) #turn twrd the nhand
set_fork_angle(95,700) #get for to height to fit under the hand
make_robot_go_straight_with_gyro(170,999,300) # go to the hand
set_fork_angle(130,700) #lift the hand
#-------------------------- end Larry mission group 1 ----------------------------
return
lift_speed=200
if (mission_group==2) and (this_robot_name== "JERRY"):
return
#-------------------------- end JERRY mission group 2 ----------------------------
if (mission_group==2) and (this_robot_name== "Larry"):
# while carrying dinosaur, go flip up power plant then go to the other side
# START ROBOT IN GROUP 2 POSITION
set_fork_angle(110,500)
make_robot_go_straight_with_gyro(360*1.75,-7,300) # go half way to powerr plant
rotate_robot(0,90,0) #face straight
make_robot_go_straight_with_gyro(105,0,300) # go the rest of the way way to powerr plant
down = 140
up =10
set_fork_angle(up,lift_speed) # bring forks up,lifing bar
rotate_robot(-20,200,0) #angle away from platform
make_robot_go_straight_with_gyro(270,-25,300) #go forward twards press plate
rotate_robot(0,200,0) #face straight
make_robot_go_straight_with_gyro(-190,-999,300) #go backwards to align pin with plate
rotate_robot(5,90,0) #face straight
#Try to hit the plate 4 times
move_degrees=40
#set_fork_angle(down,300) # bring forks down, releasing all 3 energy units
fork_motor.dc(80) #flip forkk down fast
wait(150)
set_fork_angle(up,500) # bring forks up,lifing bar in cas we missed
make_robot_go_straight_with_gyro(move_degrees,5,300) # go the rest of the way way to powerr plant
#set_fork_angle(down,300) # bring forks down, releasing all 3 energy units
fork_motor.dc(80) #flip forkk down fast
wait(150)
set_fork_angle(up,500) # bring forks up,lifing bar in cas we missed
make_robot_go_straight_with_gyro(move_degrees,5,300) # go the rest of the way way to powerr plant
#set_fork_angle(down,300) # bring forks down, releasing all 3 energy units
fork_motor.dc(80) #flip forkk udownp fast
wait(150)
set_fork_angle(up,500) # bring forks up,lifing bar in cas we missed
make_robot_go_straight_with_gyro(move_degrees,5,300) # go the rest of the way way to powerr plant
#set_fork_angle(down,300) # bring forks down, releasing all 3 energy units
fork_motor.dc(80) #flip forkk down fast
wait(150)
set_fork_angle(up,500) # bring forks up,lifing bar in cas we missed
rotate_robot(0,300,0) #face straight
make_robot_go_straight_with_gyro(510,-999,400) # go beyond the fixture so we can have room to turn
rotate_robot(45,200,0) # turn as much as we can
make_robot_go_straight_with_gyro(-400,-999,400) # go backwards 45 deg to the
rotate_robot(90,300,0)
make_robot_go_straight_with_gyro(-525,-999,300) # go backwards to the hand was 75
wait(100)
make_robot_go_straight_with_gyro(200,-999,100)
make_robot_go_straight_with_gyro(425,-999,700) # go backwards to the hand was 75
rotate_robot(45,300,0)
make_robot_go_straight_with_gyro(525,45,700)
rotate_robot(0,300,0)
make_robot_go_straight_with_gyro(1000,0,700)
return
rotate_robot(-8,90,0) # face away from the platform so the tire wont hit it
make_robot_go_straight_with_gyro(360*1,-8,500) # go 1/2 way across the rest of table
make_robot_go_straight_with_gyro(360*3.6,20,600) # go full way across the rest of table
#-------------------------- end LARRY mission group 2 ----------------------------
if (mission_group==3) and (this_robot_name== "Larry"):
set_fork_angle(10,500) # bring forks up,SO FLIPPER CLEARS FORK
make_robot_go_straight_with_gyro(260+170,0,300)
rotate_robot(-30,90,0)
make_robot_go_straight_with_gyro(480,-999,300)
rotate_robot(0,90,0)
make_robot_go_straight_with_gyro(360,-999,250) # ram 1 time
make_robot_go_straight_with_gyro(-120,-999,200)
make_robot_go_straight_with_gyro(120,-999,400) # ram 2nd time
make_robot_go_straight_with_gyro(-120,-999,400)
#make_robot_go_straight_with_gyro(120,-999,400) # ram 3rd time
make_robot_go_straight_with_gyro(-360,-999,400)
rotate_robot(-30,90,0)
make_robot_go_straight_with_gyro(-700,-999,400)
if (mission_group==3) and (this_robot_name== "JERRY"):
set_fork_angle(10,500) # bring forks up,SO FLIPPER CLEARS FORK
make_robot_go_straight_with_gyro(260+170,0,300)
rotate_robot(-30,90,0)
make_robot_go_straight_with_gyro(480,-999,300)
rotate_robot(0,90,0)
make_robot_go_straight_with_gyro(360,-999,250) # ram 1 time
make_robot_go_straight_with_gyro(-120,-999,200)
make_robot_go_straight_with_gyro(120,-999,400) # ram 2nd time
make_robot_go_straight_with_gyro(-120,-999,400)
#make_robot_go_straight_with_gyro(120,-999,400) # ram 3rd time
make_robot_go_straight_with_gyro(-360,-999,400)
rotate_robot(-30,90,0)
make_robot_go_straight_with_gyro(-700,-999,400)
if (mission_group==4) and (this_robot_name== "Larry"):
make_robot_go_straight_with_gyro(160,0,300)
rotate_robot(-45,200,0)
make_robot_go_straight_with_gyro(300,-999,300)
set_fork_angle(130,500) # bring forks down5
rotate_robot(0,200,0)
make_robot_go_straight_with_gyro(350,-999,300)
set_fork_angle(80,300) # bring forks down5
set_fork_angle(130,300) # bring forks down5
set_fork_angle(80,300) # bring forks down5
set_fork_angle(130,300) # bring forks down5
set_fork_angle(80,300) # bring forks down5
set_fork_angle(130,300) # bring forks down5
set_fork_angle(80,300) # bring forks down5
set_fork_angle(130,300) # bring forks down5
#make_robot_go_straight_with_gyro(-170,-999,400)
rotate_robot(-125,90,0)
set_fork_angle(70,300) # bring forks down5
make_robot_go_straight_with_gyro(50,-999,400)
set_fork_angle(30,300) # bring forksup
set_fork_angle(70,300) # bring forks down5
make_robot_go_straight_with_gyro(50,-999,400)
set_fork_angle(30,300) # bring forks up
set_fork_angle(70,300) # bring forks down5
make_robot_go_straight_with_gyro(50,-999,400)
set_fork_angle(30,300) # bring forks up
set_fork_angle(70,300) # bring forks down5
set_fork_angle(30,300) # bring forks up
rotate_robot(-199,300,0) #turn around to go move the energy units off the solar plant
make_robot_go_straight_with_gyro(-360*1.28,-999,400) #go right nest to plant
rotate_robot(-190,400,0) # turn to face back wall
make_robot_go_straight_with_gyro(-90,-999,500)
rotate_robot(-245,400,0)
make_robot_go_straight_with_gyro(-300,-999,500)
return
if (mission_group==4) and (this_robot_name== "JERRY"):
make_robot_go_straight_with_gyro(160,0,300)
rotate_robot(-45,200,0)
make_robot_go_straight_with_gyro(300,-999,300)
set_fork_angle(130,500) # bring forks down5
rotate_robot(0,200,0)
make_robot_go_straight_with_gyro(350,-999,300)
set_fork_angle(80,300) # bring forks down5
set_fork_angle(130,300) # bring forks down5
set_fork_angle(80,300) # bring forks down5
set_fork_angle(130,300) # bring forks down5
set_fork_angle(80,300) # bring forks down5
set_fork_angle(130,300) # bring forks down5
set_fork_angle(80,300) # bring forks down5
set_fork_angle(130,300) # bring forks down5
#make_robot_go_straight_with_gyro(-170,-999,400)
rotate_robot(-125,90,0)
set_fork_angle(70,300) # bring forks down5
make_robot_go_straight_with_gyro(50,-999,400)
set_fork_angle(30,300) # bring forksup
set_fork_angle(70,300) # bring forks down5
make_robot_go_straight_with_gyro(50,-999,400)
set_fork_angle(30,300) # bring forks up
set_fork_angle(70,300) # bring forks down5
make_robot_go_straight_with_gyro(50,-999,400)
set_fork_angle(30,300) # bring forks up
set_fork_angle(70,300) # bring forks down5
set_fork_angle(30,300) # bring forks up
rotate_robot(-199,300,0)
make_robot_go_straight_with_gyro(-360*1.28,-999,400)
rotate_robot(-190,400,0)
make_robot_go_straight_with_gyro(-90,-999,500)
rotate_robot(-245,400,0)
make_robot_go_straight_with_gyro(-300,-999,500)
return
if (mission_group==5):
while(True):
#set_fork_angle(down,300) # bring forks down, releasing all 3 energy units
fork_motor.dc(80) #flip forkk down fast
print ("DC=80")
wait(150)
print ("Going up")
set_fork_angle(up,500) # bring forks up,lifing bar in cas we missed
make_robot_go_straight_with_gyro(move_degrees,5,300) # go the rest of the way way to powerr plant
print ("got here")
# ----------------------------------------------------------------------
#test code to see hw may degreees we have to rotate the tires in oppossite
# directions to get the robot to rotate 360 degrees
# ----------------------------------------------------------------------
def test_how_many_tire_degrees_it_takes_for_robot_to_rotate_on_axis():
#right_motor.run_target(rms,degrees_tire_rotation,wait=False)
actual_angle = gyro.angle()
target =0
while ( actual_angle <360):
target=target +1
left_motor.run_target(100,-1*target,wait=False)
right_motor.run_target(100,target,wait=True)
actual_angle = gyro.angle()
print ("Angle= " , actual_angle, "target =",target)
# ----------------------------------------------------------------------
# Write your program here.
#jerry.speaker.say("Transport Colonel Jerry has received orders from his Generals")
gyro.reset_angle(0)
# SET THE MAXIMUM SPEED, ACCELERATION AND TORQUE OF THE MOTORS.
# this is needed becasue the tires tend to slip when robot
# is accelerationg or braking. These errors can add up and make
# the robot unreliable. Also the fork can jerk hard and mess up.
# default values are (800, 1600,100)
# coltrol.limits(max_speeed, accleration, torque)
if(1):
fork_motor.control.limits(1000,1600,200)
left_motor.control.limits(1000,1200,100)
right_motor.control.limits(1000,1200,100)
# get the name of the robot. Each robot is a little differnet and some of the code is tweaked for the exact robot
# this is becasue the tire sizes are not exactly the same and the over all distance that the robot travles
# can be off by a few inces at the end of a long mission.
f=open("/etc/hostname")
this_robot_name = f.read().strip()
setup_forklift()
set_fork_angle(5,500)
gyro.reset_angle(0)
test_gyro_drift()
#test_how_many_tire_degrees_it_takes_for_robot_to_rotate_on_axis()
#super_test_rotate_robot()
#rotate_robot(90,100,0)
#wait(1000)
#rotate_robot(0,100,0)
#wait(1000)
#run_mission_group(2)
run_the_menue()
#run_mission_group(5)
#make_robot_go_straight_with_gyro (360*10,0,300)
#make_robot_go_straight_with_gyro (360*-10,0,300)
#connmanctl
#enable wifi
#scan wifi
#services
#agent on
#connect wifi_74da38f2e886_6c6f755f77696669_managed_psk
#quit
#Enter the word "maker" and press Enter.
#Delete the "ev3dev" text and enter the name you want your robot to have when you connect to it.
#Press CTRL + X when you are ready and nano will ask you if you wish to save your changes.
#Press "Y" to confirm the changes and press Enter.
#Reboot the EV3 Brick
#rename robot
# nano /etc/hostname
# December 29 2021
# re built the forks on the robot to make it more useful for missions
# rewrote the fork zero functions.
# updated code for Group 1 to use new forks
|
Beta Was this translation helpful? Give feedback.
-
You’re speaking over my head… Is there someway I can make this work?
… On Feb 6, 2023, at 1:30 PM, David Lechner ***@***.***> wrote:
I also just pushed out a change that removes /usr/lib/pybricks-micropython from usys.path to avoid this problem altogether.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.
|
Beta Was this translation helpful? Give feedback.
-
Will do -- I am on it!! TY!
…On 2023-02-06 19:26, David Lechner wrote:
Grab the latest build (2441):
curl -k -L
https://nightly.link/pybricks/pybricks-micropython/workflows/build/master/pybricks-micropython-build-2441.zip
-O
unzip pybricks-micropython-build-2441.zip
chmod +x pybricks-micropython
--
Reply to this email directly, view it on GitHub [1], or unsubscribe
[2].
You are receiving this because you authored the thread.Message ID:
***@***.***>
Links:
------
[1]
#935 (reply in thread)
[2]
https://github.com/notifications/unsubscribe-auth/AOU7DDCTNIIXJNWW3L2Q53LWWGJB3ANCNFSM6AAAAAAUQY7OBA
|
Beta Was this translation helpful? Give feedback.
-
the file is not a valid zip file.. only 604 bytes?
…-rw-r--r-- 1 root root 604 Feb 7 01:41
pybricks-micropython-build-2441.zip
On 2023-02-06 19:26, David Lechner wrote:
Grab the latest build (2441):
curl -k -L
https://nightly.link/pybricks/pybricks-micropython/workflows/build/master/pybricks-micropython-build-2441.zip
-O
unzip pybricks-micropython-build-2441.zip
chmod +x pybricks-micropython
--
Reply to this email directly, view it on GitHub [1], or unsubscribe
[2].
You are receiving this because you authored the thread.Message ID:
***@***.***>
Links:
------
[1]
#935 (reply in thread)
[2]
https://github.com/notifications/unsubscribe-auth/AOU7DDCTNIIXJNWW3L2Q53LWWGJB3ANCNFSM6AAAAAAUQY7OBA
|
Beta Was this translation helpful? Give feedback.
-
I am on it...
…On 2023-02-06 20:51, David Lechner wrote:
Try this one:
https://nightly.link/pybricks/pybricks-micropython/workflows/build/master/pybricks-micropython-build-2442.zip
--
Reply to this email directly, view it on GitHub [1], or unsubscribe
[2].
You are receiving this because you authored the thread.Message ID:
***@***.***>
Links:
------
[1]
#935 (reply in thread)
[2]
https://github.com/notifications/unsubscribe-auth/AOU7DDBL2X6OF67G63ZO7H3WWGTANANCNFSM6AAAAAAUQY7OBA
|
Beta Was this translation helpful? Give feedback.
-
it works, sort of ..
The code runs -- bit for some reason the code that looks
at the front buttons of EV3 is bombing..
code:
jerry = EV3Brick()
b =jerry.buttons.pressed()
print ("b=",b)
if (b==[]):
wait(1)
#print ("no press",b)
else:
print ("not sure whats up here..",b)
jerry.speaker.beep(2000,10)
if (b[0]==Button.UP):
output:
b= ()
not sure whats up here.. ()
Traceback (most recent call last):
File "/home/robot/jerry_test_1/main.py", line 1098, in <module>
File "/home/robot/jerry_test_1/main.py", line 616, in run_the_menue
IndexError: tuple index out of range
----------
Exited with error code 1.
Is something different with the way the front panel buttones are
pressed?
Sorry to be such a pain in the butt..
…---Lou
On 2023-02-06 20:51, David Lechner wrote:
Try this one:
https://nightly.link/pybricks/pybricks-micropython/workflows/build/master/pybricks-micropython-build-2442.zip
--
Reply to this email directly, view it on GitHub [1], or unsubscribe
[2].
You are receiving this because you authored the thread.Message ID:
***@***.***>
Links:
------
[1]
#935 (reply in thread)
[2]
https://github.com/notifications/unsubscribe-auth/AOU7DDBL2X6OF67G63ZO7H3WWGTANANCNFSM6AAAAAAUQY7OBA
|
Beta Was this translation helpful? Give feedback.
-
TY
by the way, our team, Nuclear Knights
(Team 43265) is going to FLL STATE!!! Thanks
to YOUR python !!!!!
…----Lou
On 2023-02-06 21:58, David Lechner wrote:
The return type was changed. Instead of if (b==[]):, use if not b. In
Python, empty lists/tuples/strings/etc. are falsey.
--
Reply to this email directly, view it on GitHub [1], or unsubscribe
[2].
You are receiving this because you authored the thread.Message ID:
***@***.***>
Links:
------
[1]
#935 (reply in thread)
[2]
https://github.com/notifications/unsubscribe-auth/AOU7DDACD7GGEAPLZGRPUPLWWG25BANCNFSM6AAAAAAUQY7OBA
|
Beta Was this translation helpful? Give feedback.
-
Hi - My students and I LOVE pybrics! Thank you for creating it!
I have been using a pybrics image SD card fro about 2 years on my EV3. I have seen that a lot of issues may have been identified and fixed since the release I am using. So I have 2 questions:
how do I find out what release version my Pybrics is?
how do I update to the latest fixes?? Can I do some soprt of
apt-get upgrade? Will someone be so kind as to show me an
example of how I would upgrade?
Thanks again for the help.
Beta Was this translation helpful? Give feedback.
All reactions