Iโm trying to add another motor to the basic drive base and add buttons to the remote. However, Iโm trying to use degrees rather than continuous rotation as the attachment (forklift) can only move 45 degrees or less (to go up ). Also, Iโm adding another button to the remote to make the attachment move down again (-45 degrees). The current software update will not allow these additions and cause the remote to not connect with the robot. If you need anything else besides what I have stated please lmk. Any help is greatly appreciated! Thank you:)
Code:
Define objects for a simple two motor rover using a DriveBase
hub = PrimeHub()
left_motor = Motor(Port.A, positive_direction=Direction.COUNTERCLOCKWISE)
right_motor = Motor(Port.E, positive_direction=Direction.CLOCKWISE)
drive_base = DriveBase(left_motor, right_motor, wheel_diameter=56, axle_track=96)
Speeds and accelerations to use
STRAIGHT_SPEED = 700 # straight driving speed (mm/sec)
TURN_RATE = 150 # turning rate (deg/sec)
Connect to the remote
hub.light.on(Color.YELLOW) # turn hub light yellow while trying to connect
rc = Remote() # will stop the program if it can't connect
Set status light on both hub and remote to green to indicate connection
hub.light.on(Color.GREEN)
rc.light.on(Color.GREEN)
The main loop repeatedly tests the remote buttons and reacts
while True:
# Get the set of buttons that are currently pressed,
pressed = rc.buttons.pressed()
# Determine what straight driving speed to use
if (Button.LEFT_PLUS in pressed):
speed = STRAIGHT_SPEED
elif (Button.LEFT_MINUS in pressed):
speed = -STRAIGHT_SPEED
else:
speed = 0
# Determine what turn rate to use
if (Button.RIGHT_PLUS in pressed):
turn_rate = TURN_RATE
elif (Button.RIGHT_MINUS in pressed):
turn_rate = -TURN_RATE
else:
turn_rate = 0
# Update the driving and turning speeds
drive_base.drive(speed, turn_rate)