Пример #1
0
def cmd_tacho(port, var):
    return b''.join([
        ev3.opInput_Device, ev3.GET_RAW,
        ev3.LCX(0),
        ev3.port_motor_input(port),
        ev3.GVX(var)
    ])
Пример #2
0
 def _ops_pos(self):
     """
     read positions of the wheels (returns operations)
     """
     return b''.join([
         ev3.opInput_Device,
         ev3.READY_RAW,
         ev3.LCX(0),  # LAYER
         ev3.port_motor_input(self._port_left),  # NO
         ev3.LCX(7),  # TYPE - EV3-Large-Motor
         ev3.LCX(1),  # MODE - Degree
         ev3.LCX(1),  # VALUES
         ev3.GVX(0),  # VALUE1
         ev3.opInput_Device,
         ev3.READY_RAW,
         ev3.LCX(0),  # LAYER
         ev3.port_motor_input(self._port_right),  # NO
         ev3.LCX(7),  # TYPE - EV3-Large-Motor
         ev3.LCX(0),  # MODE - Degree
         ev3.LCX(1),  # VALUES
         ev3.GVX(4)  # VALUE1
     ])
Пример #3
0
 def _ops_pos(self):
     """
     read positions of the wheels (returns operations)
     """
     return b''.join([
         ev3.opInput_Device,
         ev3.READY_RAW,
         ev3.LCX(0),                             # LAYER
         ev3.port_motor_input(self._port_left),  # NO
         ev3.LCX(7),                             # TYPE - EV3-Large-Motor
         ev3.LCX(1),                             # MODE - Degree
         ev3.LCX(1),                             # VALUES
         ev3.GVX(0),                             # VALUE1
         ev3.opInput_Device,
         ev3.READY_RAW,
         ev3.LCX(0),                             # LAYER
         ev3.port_motor_input(self._port_right), # NO
         ev3.LCX(7),                             # TYPE - EV3-Large-Motor
         ev3.LCX(0),                             # MODE - Degree
         ev3.LCX(1),                             # VALUES
         ev3.GVX(4)                              # VALUE1
     ])
 def get_degrees_two_motors(self, motors):
     ops = b''.join([
         ev3.opInput_Device,
         ev3.READY_SI,
         ev3.LCX(0),  # LAYER
         ev3.port_motor_input(motors[0]['port']),  # NO
         ev3.LCX(7),  # TYPE
         ev3.LCX(0),  # MODE
         ev3.LCX(1),  # VALUES
         ev3.GVX(0),  # VALUE1
         ev3.opInput_Device,
         ev3.READY_RAW,
         ev3.LCX(0),  # LAYER
         ev3.port_motor_input(motors[1]['port']),  # NO
         ev3.LCX(7),  # TYPE
         ev3.LCX(0),  # MODE
         ev3.LCX(1),  # VALUES
         ev3.GVX(4)  # VALUE1
     ])
     reply = self.ev3.send_direct_cmd(ops, global_mem=8)
     (pos_0, pos_1) = struct.unpack('<fi', reply[5:])
     #pos_0 -= self.base_pos[0]
     #pos_1 -= self.base_pos[1]
     return pos_0, pos_1
 def get_degree_single_motor(self, motors, motor_num):
     ops = b''.join([
         ev3.opInput_Device,
         ev3.READY_SI,
         ev3.LCX(0),  # LAYER
         ev3.port_motor_input(motors[motor_num]['port']),  # NO
         ev3.LCX(7),  # TYPE
         ev3.LCX(0),  # MODE
         ev3.LCX(1),  # VALUES
         ev3.GVX(0),  # VALUE1
     ])
     reply = self.ev3.send_direct_cmd(ops, global_mem=8)
     pos = struct.unpack('<fi', reply[5:])
     print(pos)
     pos -= self.base_pos[motor_num]
     return pos
Пример #6
0
def remote_motor_status(port: int) -> None:

    ops = b''.join([
        ev3.opInput_Device,
        ev3.READY_SI,
        ev3.LCX(0),                   # LAYER
        ev3.port_motor_input(port), # NO
        ev3.LCX(7),                   # TYPE
        ev3.LCX(0),                   # MODE
        ev3.LCX(1),                   # VALUES
        ev3.GVX(0),                   # VALUE1
    ])
    reply = my_ev3.send_direct_cmd(ops, global_mem=4)
    (pos_a,) = struct.unpack('<f', reply[5:])
#    pos_a = struct.unpack('<f', reply[5:])
    print("Get Remote MOTOR in PORT with position {}".format(pos_a))
Пример #7
0
import ev3, struct

my_ev3 = ev3.EV3(protocol=ev3.BLUETOOTH, host='00:16:53:43:1b:92')
my_ev3.verbosity = 1

ops = b''.join([
    ev3.opInput_Device,
    ev3.READY_SI,
    ev3.LCX(0),  # LAYER
    ev3.port_motor_input(ev3.PORT_B),  # NO
    ev3.LCX(7),  # TYPE
    ev3.LCX(0),  # MODE
    ev3.LCX(1),  # VALUES
    ev3.GVX(0),  # VALUE1
    ev3.opInput_Device,
    ev3.READY_RAW,
    ev3.LCX(0),  # LAYER
    ev3.port_motor_input(ev3.PORT_C),  # NO
    ev3.LCX(7),  # TYPE
    ev3.LCX(0),  # MODE
    ev3.LCX(1),  # VALUES
    ev3.GVX(4)  # VALUE1
])
reply = my_ev3.send_direct_cmd(ops, global_mem=8)
(pos_a, pos_d) = struct.unpack('<fi', reply[5:])
print("positions in degrees (ports B and C): {} and {}".format(pos_a, pos_d))