Connecte Hub mit korrekter Remote nach Farbe

This commit is contained in:
(MakerLab) Laptop 2 2024-06-12 17:48:14 +02:00
parent e4847d6cad
commit 2c3d9eb160

View file

@ -2,15 +2,34 @@ from pybricks.pupdevices import Motor, ColorSensor, UltrasonicSensor, ForceSenso
from pybricks.parameters import Button, Color, Direction, Port, Side, Stop
from pybricks.robotics import DriveBase
from pybricks.tools import wait, StopWatch
from pybricks.hubs import PrimeHub
rc = Remote(timeout=5000)
print("Remote name: ", rc.name)
rc.light.on(Color.RED)
config = {
"PyBrick Hub" : {
"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
try:
shoot = Motor(Port.F)
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:
print("no shoot motor")
@ -52,11 +71,12 @@ while True:
if Button.CENTER in pressed:
if shoot:
# move forward to shoot
angle=45
angle=30
speed=1000
shoot.run_angle(-speed, angle)
# move back
shoot.run_angle(speed, angle)
# move back
shoot.run_angle(-speed, angle)
#shoot.run(speed)
# run fast
db.settings(s_speed*2, s_accel, t_rate, t_accel*2)