Connecte Hub mit korrekter Remote nach Farbe
This commit is contained in:
parent
e4847d6cad
commit
2c3d9eb160
1 changed files with 26 additions and 6 deletions
|
@ -2,15 +2,34 @@ from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSenso
|
||||||
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
|
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
|
||||||
from pybricks.robotics import DriveBase
|
from pybricks.robotics import DriveBase
|
||||||
from pybricks.tools import wait, StopWatch
|
from pybricks.tools import wait, StopWatch
|
||||||
|
from pybricks.hubs import PrimeHub
|
||||||
|
|
||||||
rc = Remote(timeout=5000)
|
config = {
|
||||||
print("Remote name: ", rc.name)
|
"PyBrick Hub" : {
|
||||||
rc.light.on(Color.RED)
|
"remote" : "blue",
|
||||||
|
"color" : Color.BLUE
|
||||||
|
},
|
||||||
|
"Hub Rot" : {
|
||||||
|
"remote" : "red",
|
||||||
|
"color" : Color.RED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hub = PrimeHub()
|
||||||
|
hub_name = hub.system.name()
|
||||||
|
hub_config = config[hub_name]
|
||||||
|
print("Hub config: ", hub_config)
|
||||||
|
rc = Remote(timeout=5000, name=hub_config["remote"])
|
||||||
|
rc.light.on(hub_config["color"])
|
||||||
|
|
||||||
shoot = None
|
shoot = None
|
||||||
try:
|
try:
|
||||||
shoot = Motor(Port.F)
|
shoot = Motor(Port.F)
|
||||||
print("found shoot motor")
|
print("found shoot motor")
|
||||||
|
# erhöhe Beschleunigung des Shoot Motors von 2000 auf 8000
|
||||||
|
shoot.control.limits(1000, 8000, 199)
|
||||||
|
print("Shoot limits (speed, accel, torque): " + str(shoot.control.limits()))
|
||||||
|
shoot.control.limits
|
||||||
except:
|
except:
|
||||||
print("no shoot motor")
|
print("no shoot motor")
|
||||||
|
|
||||||
|
@ -52,11 +71,12 @@ while True:
|
||||||
if Button.CENTER in pressed:
|
if Button.CENTER in pressed:
|
||||||
if shoot:
|
if shoot:
|
||||||
# move forward to shoot
|
# move forward to shoot
|
||||||
angle=45
|
angle=30
|
||||||
speed=1000
|
speed=1000
|
||||||
shoot.run_angle(-speed, angle)
|
|
||||||
# move back
|
|
||||||
shoot.run_angle(speed, angle)
|
shoot.run_angle(speed, angle)
|
||||||
|
# move back
|
||||||
|
shoot.run_angle(-speed, angle)
|
||||||
|
#shoot.run(speed)
|
||||||
|
|
||||||
# run fast
|
# run fast
|
||||||
db.settings(s_speed*2, s_accel, t_rate, t_accel*2)
|
db.settings(s_speed*2, s_accel, t_rate, t_accel*2)
|
||||||
|
|
Loading…
Reference in a new issue