예제 #1
0
def connection_state_changed(c, _):
    global kill_motor
    if c:
        print("Connection established.")
    else:
        print("Disconnected.")

        # Kill drive motors
        kill_motor = True
        drive_motor = DriveMotors()
        drive_motor.left = 0.0
        drive_motor.right = 0.0

        lcm_.publish('/motor', drive_motor.encode())

        # Kill arm motors
        arm_motor = OpenLoopRAMotors()
        arm_motor.joint_a = 0.0
        arm_motor.joint_b = 0.0
        arm_motor.joint_c = 0.0
        arm_motor.joint_d = 0.0
        arm_motor.joint_e = 0.0
        arm_motor.joint_f = 0.0

        lcm_.publish('/arm_motors', arm_motor.encode())

        # Kill SA motors
        sa_motor = SAMotors()
        sa_motor.drill = 0.0
        sa_motor.lead_screw = 0.0
        sa_motor.door_actuator = 0.0
        sa_motor.cache = 0.0

        lcm_.publish('/sa_motors', sa_motor.encode())
예제 #2
0
def autonomous_callback(channel, msg):
    input_data = Joystick.decode(msg)
    new_motor = DriveMotors()

    joystick_math(new_motor, input_data.forward_back, input_data.left_right)

    lcm_.publish('/motor', new_motor.encode())
예제 #3
0
def drive_control_callback(channel, msg):
    global kill_motor

    input_data = Joystick.decode(msg)
    input_data.forward_back = -quadratic(input_data.forward_back)

    if input_data.kill:
        kill_motor = True
    elif input_data.restart:
        kill_motor = False

    new_motor = DriveMotors()

    if kill_motor:
        new_motor.left = 0
        new_motor.right = 0

    else:
        magnitude = deadzone(input_data.forward_back, 0.04)
        theta = deadzone(input_data.left_right, 0.1)

        joystick_math(new_motor, magnitude, theta)

        damp = (input_data.dampen - 1) / (-2)
        new_motor.left *= damp
        new_motor.right *= damp

    lcm_.publish('/motor', new_motor.encode())
예제 #4
0
def motor_callback(channel, msg):
    input_data = DriveMotors.decode(msg)
    # This function is for testing the joystick-motor algorithm
    print("Left: {}  Right: {}\n".format(input_data.left, input_data.right))
예제 #5
0
def send_drive_kill():
    drive_motor = DriveMotors()
    drive_motor.left = 0.0
    drive_motor.right = 0.0

    lcm_.publish('/motor', drive_motor.encode())
예제 #6
0
def drive_motor_callback(channel, msg):
    m = DriveMotors.decode(msg)
    exec_later(rover.percent_vbus_drive(Talons.left_front.value, m.left))
    exec_later(rover.percent_vbus_drive(Talons.right_front.value, m.right))