Example #1
0
def picture_callback(channel, msg):
    global taking_picture
    data = PiPicture.decode(msg)
    if index != data.index or taking_picture:
        return
    stop_pipeline()
    taking_picture = True
    exec_later(take_picture())
Example #2
0
def sa_motor_callback(channel, msg):
    m = SAMotors.decode(msg)
    exec_later(rover.percent_vbus_drive(Talons.drill.value, m.drill))
    exec_later(rover.percent_vbus_drive(Talons.lead_screw.value, m.lead_screw))
    exec_later(
        rover.percent_vbus_drive(Talons.door_actuator.value, m.door_actuator))
    exec_later(rover.percent_vbus_drive(Talons.cache.value, m.cache))
Example #3
0
def process_param_set_msg(bus, msg, device_id):
    param = talon_srx.Param(msg.data[0])
    raw_bits = struct.unpack('<I', msg.data[1:5])[0]
    val = raw_bits
    if param in (talon_srx.Param.ProfileParamSlot0_P,
                 talon_srx.Param.ProfileParamSlot0_I,
                 talon_srx.Param.ProfileParamSlot0_D,
                 talon_srx.Param.ProfileParamSlot1_P,
                 talon_srx.Param.ProfileParamSlot1_I,
                 talon_srx.Param.ProfileParamSlot1_D):
        val = talon_srx.fxp_10_22_to_float(raw_bits)
    print('setting parameter {} to {}'.format(param.name, val))

    msg = aiocan.Message(arb_id=(talon_srx.PARAM_RESPONSE | device_id),
                         extended_id=True,
                         data=msg.data)
    exec_later(bus.send(msg))
Example #4
0
def open_loop_arm_callback(channel, msg):
    m = OpenLoopRAMotors.decode(msg)
    exec_later(rover.percent_vbus_drive(Talons.arm_joint_a.value, m.joint_a))
    exec_later(rover.percent_vbus_drive(Talons.arm_joint_b.value, m.joint_b))
    exec_later(rover.percent_vbus_drive(Talons.arm_joint_c.value, m.joint_c))
    exec_later(rover.percent_vbus_drive(Talons.arm_joint_d.value, m.joint_d))
    exec_later(rover.percent_vbus_drive(Talons.arm_joint_e.value, m.joint_e))
    exec_later(rover.percent_vbus_drive(Talons.arm_joint_f.value, m.joint_f))
Example #5
0
def arm_demand_callback(channel, msg):
    m = Encoder.decode(msg)
    exec_later(rover.position_pid_drive(Talons.arm_joint_a.value, m.joint_a))
    exec_later(rover.position_pid_drive(Talons.arm_joint_b.value, m.joint_b))
    exec_later(rover.position_pid_drive(Talons.arm_joint_c.value, m.joint_c))
    exec_later(rover.position_pid_drive(Talons.arm_joint_d.value, m.joint_d))
    exec_later(rover.position_pid_drive(Talons.arm_joint_e.value, m.joint_e))
    exec_later(rover.position_pid_drive(Talons.arm_joint_f.value, m.joint_f))
Example #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))
Example #7
0
def set_demand_callback(channel, msg):
    m = SetDemand.decode(msg)
    exec_later(rover.talons[m.deviceID].set_demand(m.value, m.control_mode))
Example #8
0
def set_param_callback(channel, msg):
    m = SetParam.decode(msg)
    exec_later(rover.talons[m.deviceID].set_param(m.paramID, m.value))