Mindsensors Sensors

Work in progress…

class nxt.sensor.mindsensors.SumoEyes(brick, port, long_range=False)

The class to control Mindsensors Sumo sensor. Warning: long range not working for my sensor.

class Reading(raw_reading)

Contains the reading of SumoEyes sensor. left and right can be True or False. If True, then there is something there, if False, then it’s empty there.

set_long_range(val)

Sets if the sensor should operate in long range mode (12 inches) or the short range mode (6 in). val should be True or False.

get_sample()

Returns the processed meaningful values of the sensor

class nxt.sensor.mindsensors.Compassv2(brick, port, check_compatible=True)

Class for the now-discontinued CMPS-Nx sensor. Also works with v1.1 sensors. Note that when using a v1.x sensor, some of the commands are not supported! To determine your sensor’s version, use get_sensor_info().version

I2C_ADDRESS = {'command': (65, '<B'), 'factory_scale_divisor': (19, 'B'), 'factory_scale_factor': (18, 'B'), 'heading': (66, '<H'), 'product_id': (8, '8s'), 'sensor_type': (16, '8s'), 'version': (0, '8s'), 'x_offset': (68, '<h'), 'x_range': (72, '<H'), 'x_raw': (76, '<H'), 'y_offset': (70, '<h'), 'y_range': (74, '<H'), 'y_raw': (78, '<H')}
class Commands
AUTO_TRIG_ON = 'A'
AUTO_TRIG_OFF = 'S'
MAP_HEADING_BYTE = 'B'
MAP_HEADING_INTEGER = 'I'
SAMPLING_50_HZ = 'E'
SAMPLING_60_HZ = 'U'
SET_ADPA_MODE_ON = 'N'
SET_ADPA_MODE_OFF = 'O'
BEGIN_CALIBRATION = 'C'
DONE_CALIBRATION = 'D'
LOAD_USER_CALIBRATION = 'L'
command(command)
get_heading()
get_sample()
compatible_sensors = [<nxt.sensor.digital._SCompatibility object>]
class nxt.sensor.mindsensors.DIST(brick, port, check_compatible=True)

Class for the Distance Infrared Sensor

I2C_ADDRESS = {'command': (65, '<B'), 'distance': (66, '<H'), 'factory_scale_divisor': (19, 'B'), 'factory_scale_factor': (18, 'B'), 'max_distance': (84, '<H'), 'min_distance': (82, '<H'), 'no_of_data_points': (81, '<B'), 'product_id': (8, '8s'), 'sensor_type': (16, '8s'), 'type': (80, '<B'), 'version': (0, '8s'), 'voltage': (68, '<H')}
class Commands
TYPE_GP2D12 = '1'
TYPE_GP2D120 = '2'
TYPE_GP2Y0A21YK = '3'
TYPE_GP2Y0A02YK = '4'
TYPE_CUSTOM = '5'
POWER_ON = 'E'
POWER_OFF = 'D'
ADPA_ON = 'N'
ADPA_OFF = 'O'
command(command)
get_distance()
get_sample()
get_type()
get_voltage()
get_min_distance()
get_max_distance()
compatible_sensors = [<nxt.sensor.digital._SCompatibility object>]
class nxt.sensor.mindsensors.RTC(brick, port)

Class for the RealTime Clock sensor (DS1307)

I2C_ADDRESS = {'date': (4, '<B'), 'day': (3, '<B'), 'factory_scale_divisor': (19, 'B'), 'factory_scale_factor': (18, 'B'), 'hours': (2, '<B'), 'minutes': (1, '<B'), 'month': (5, '<B'), 'product_id': (8, '8s'), 'seconds': (0, '<B'), 'sensor_type': (16, '8s'), 'version': (0, '8s'), 'year': (6, '<B')}
I2C_DEV = 208
get_seconds()
get_minutes()
get_hours()
get_day()
get_month()
get_year()

Last two digits (10 for 2010)

get_date()
hour_mode(mode)

Writes mode bit and re-enters hours, which is required

get_mer()
get_sample()

Returns a struct_time() tuple which can be processed by the time module.

class nxt.sensor.mindsensors.ACCL(brick, port, check_compatible=True)

Class for Accelerometer sensor

I2C_ADDRESS = {'all_accel': (69, '<3h'), 'all_tilt': (66, '3b'), 'command': (65, 'B'), 'factory_scale_divisor': (19, 'B'), 'factory_scale_factor': (18, 'B'), 'product_id': (8, '8s'), 'sensitivity': (25, 'B'), 'sensor_type': (16, '8s'), 'version': (0, '8s'), 'x_accel': (69, '<h'), 'x_offset': (75, '<h'), 'x_range': (77, '<h'), 'x_tilt': (66, 'b'), 'y_accel': (71, '<h'), 'y_offset': (79, '<h'), 'y_range': (81, '<h'), 'y_tilt': (67, 'b'), 'z_accel': (73, '<h'), 'z_offset': (83, '<h'), 'z_range': (85, '<h'), 'z_tilt': (68, 'b')}
class Commands
SENS_15G = '1'
SENS_2G = '2'
SENS_4G = '3'
SENS_6G = '4'
X_CALIBRATION = 'X'
X_CAL_AND_END = 'x'
Y_CALIBRATION = 'Y'
Y_CAL_AND_END = 'y'
Z_CALIBRATION = 'Z'
Z_CAL_AND_END = 'z'
CAL_RESET = 'R'
ADPA_ON = 'N'
ADPA_OFF = 'O'
command(command)
get_sensitivity()
get_tilt(axis)
get_all_tilt()
get_accel(axis)
get_all_accel()
get_sample()
get_offset(axis)
get_range(axis)
set_offset(axis, value)
set_range(axis, value)
compatible_sensors = [<nxt.sensor.digital._SCompatibility object>]
class nxt.sensor.mindsensors.MTRMUX(brick, port, check_compatible=True)

Class for RCX Motor Multiplexer sensor

I2C_ADDRESS = {'command': (65, '<B'), 'direction_m1': (66, '<B'), 'direction_m2': (68, '<B'), 'direction_m3': (70, '<B'), 'direction_m4': (72, '<B'), 'factory_scale_divisor': (19, 'B'), 'factory_scale_factor': (18, 'B'), 'product_id': (8, '8s'), 'sensor_type': (16, '8s'), 'speed_m1': (67, '<B'), 'speed_m2': (69, '<B'), 'speed_m3': (71, '<B'), 'speed_m4': (73, '<B'), 'version': (0, '8s')}
I2C_DEV = 180
class Commands
FLOAT = 0
FORWARD = 1
REVERSE = 2
BRAKE = 3
command(command)
set_direction(number, value)
set_speed(number, value)
get_direction(number)
get_speed(number)
compatible_sensors = [<nxt.sensor.digital._SCompatibility object>]
class nxt.sensor.mindsensors.LineLeader(brick, port, check_compatible=True)

Class for Line Sensor Array

I2C_ADDRESS = {'all_calibrated_readings': (73, '<8B'), 'all_uncal_readings': (116, '<8B'), 'average': (67, '<B'), 'b_cal_data': (108, '<B'), 'b_read_limit': (89, '<B'), 'calibrated_reading_byte1': (73, '<B'), 'calibrated_reading_byte2': (74, '<B'), 'calibrated_reading_byte3': (75, '<B'), 'calibrated_reading_byte4': (76, '<B'), 'calibrated_reading_byte5': (77, '<B'), 'calibrated_reading_byte6': (78, '<B'), 'calibrated_reading_byte7': (79, '<B'), 'calibrated_reading_byte8': (80, '<B'), 'command': (65, '<B'), 'factory_scale_divisor': (19, 'B'), 'factory_scale_factor': (18, 'B'), 'kd': (72, '<B'), 'kd_divisor': (99, '<B'), 'ki': (71, '<B'), 'ki_divisor': (98, '<B'), 'kp': (70, '<B'), 'kp_divisor': (97, '<B'), 'product_id': (8, '8s'), 'result': (68, '<B'), 'sensor_type': (16, '8s'), 'set_point': (69, '<B'), 'steering': (66, '<b'), 'uncal_sensor1_voltage_byte1': (116, '<B'), 'uncal_sensor2_voltage_byte1': (118, '<B'), 'uncal_sensor3_voltage_byte1': (120, '<B'), 'uncal_sensor4_voltage_byte1': (122, '<B'), 'uncal_sensor5_voltage_byte1': (124, '<B'), 'uncal_sensor6_voltage_byte1': (126, '<B'), 'uncal_sensor7_voltage_byte1': (128, '<B'), 'uncal_sensor8_voltage_byte1': (130, '<B'), 'version': (0, '8s'), 'w_cal_data1': (100, '<B'), 'w_read_limit': (81, '<H')}
class Commands
CALIBRATE_WHITE = 'W'
CALIBRATE_BLACK = 'B'
SENSOR_SLEEP = 'D'
US_CONFIG = 'A'
EU_CONFIG = 'E'
UNI_CONFIG = 'U'
SENSOR_WAKE = 'P'
COLOR_INVERT = 'I'
COLOR_INVERT_REVERSE = 'R'
SNAPSHOT = 'S'
command(command)
get_steering()

Value to add to the left and subtract from the right motor’s power.

get_average()

Weighted average; greater as line is closer to right edge. 0 for no line.

get_result()

Bitmap, one bit for each sensor

set_set_point(value)

Average value for steering to gravitate to. 10 (left) to 80 (right).

set_pid(pid, value)
set_pid_divisor(pid, value)
get_reading(number)
get_reading_all()
get_sample()
get_uncal_reading(number)
get_uncal_all()
compatible_sensors = [<nxt.sensor.digital._SCompatibility object>]
class nxt.sensor.mindsensors.Servo(brick, port, check_compatible=True)

Class for Servo sensors

I2C_ADDRESS = {'command': (65, '<B'), 'factory_scale_divisor': (19, 'B'), 'factory_scale_factor': (18, 'B'), 'product_id': (8, '8s'), 'sensor_type': (16, '8s'), 'servo_1_pos': (66, '<H'), 'servo_1_quick': (90, '<B'), 'servo_1_speed': (82, '<B'), 'servo_2_pos': (68, '<H'), 'servo_2_quick': (91, '<B'), 'servo_2_speed': (83, '<B'), 'servo_3_pos': (70, '<H'), 'servo_3_quick': (92, '<B'), 'servo_3_speed': (84, '<B'), 'servo_4_pos': (72, '<H'), 'servo_4_quick': (93, '<B'), 'servo_4_speed': (85, '<B'), 'servo_5_pos': (74, '<H'), 'servo_5_quick': (94, '<B'), 'servo_5_speed': (86, '<B'), 'servo_6_pos': (76, '<H'), 'servo_6_quick': (95, '<B'), 'servo_6_speed': (87, '<B'), 'servo_7_pos': (78, '<H'), 'servo_7_quick': (96, '<B'), 'servo_7_speed': (88, '<B'), 'servo_8_pos': (80, '<H'), 'servo_8_quick': (97, '<B'), 'servo_8_speed': (89, '<B'), 'version': (0, '8s')}
I2C_DEV = 176
COMMANDVALUES = {'EM': 17741, 'Gx': 18296, 'H': 72, 'I1': 18737, 'I2': 18738, 'I3': 18739, 'I4': 18740, 'I5': 18741, 'I6': 18742, 'I7': 18743, 'I8': 18744, 'P': 80, 'R': 82, 'S': 83}
class Commands
RESUME_MACRO = 'R'
RESET_POS_SPEED = 'S'
STORE_MOTOR_POS_1 = 'I1'
STORE_MOTOR_POS_2 = 'I2'
STORE_MOTOR_POS_3 = 'I3'
STORE_MOTOR_POS_4 = 'I4'
STORE_MOTOR_POS_5 = 'I5'
STORE_MOTOR_POS_6 = 'I6'
STORE_MOTOR_POS_7 = 'I7'
STORE_MOTOR_POS_8 = 'I8'
HALT_MACRO = 'H'
X_TO_VAR = 'Gx'
EDIT_MACRO = 'EM'
PAUSE_MACRO = 'P'
command(command)
get_bat_level()
set_position(number, value)
get_position(number)
set_speed(number, value)
get_speed(number)
set_quick(number, value)
compatible_sensors = [<nxt.sensor.digital._SCompatibility object>]
class nxt.sensor.mindsensors.MMX(brick, port, check_compatible=True)

Class for MMX sensors

I2C_ADDRESS = {'command': (65, '<B'), 'command_a_1': (73, '<B'), 'command_a_2': (81, '<B'), 'command_b_1': (72, '<B'), 'command_b_2': (80, '<B'), 'd_encoder': (126, '<H'), 'd_speed': (132, '<H'), 'encoder_1_pos': (98, '<H'), 'encoder_1_target': (66, '<l'), 'encoder_2_pos': (102, '<H'), 'encoder_2_target': (74, '<l'), 'factory_scale_divisor': (19, 'B'), 'factory_scale_factor': (18, 'B'), 'i_encoder': (124, '<H'), 'i_speed': (130, '<H'), 'p_encoder': (122, '<H'), 'p_speed': (128, '<H'), 'pass_count': (134, '<B'), 'product_id': (8, '8s'), 'seconds_to_run_1': (71, '<B'), 'seconds_to_run_2': (79, '<B'), 'sensor_type': (16, '8s'), 'speed_1': (70, '<B'), 'speed_2': (78, '<B'), 'status_m1': (114, '<B'), 'status_m2': (115, '<B'), 'tasks_running_m1': (118, '<H'), 'tasks_running_m2': (119, '<H'), 'tolerance': (135, '<B'), 'version': (0, '8s')}
I2C_DEV = 6
class Commands
RESET_PARAMS_ENCODERS = 'R'
ISSUE_SYNCED_COMMANDS = 'S'
MOTOR_1_FLOAT_STOP = 'a'
MOTOR_2_FLOAT_STOP = 'b'
BOTH_FLOAT_STOP = 'c'
MOTOR_1_BRAKE_STOP = 'A'
MOTOR_2_BRAKE_STOP = 'B'
BOTH_BRAKE_STOP = 'C'
MOTOR_1_ENC_RESET = 'r'
MOTOR_2_ENC_RESET = 's'
command(command)
get_bat_level()
set_encoder_target(motor_number, value)
set_speed(motor_number, value)
set_time_run(motor_number, seconds)
command_b(motor_number, value)
command_a(motor_number, bit_num, bit_val)
get_encoder_pos(motor_number)
get_motor_status(motor_number, bit_num)
get_tasks(motor_number)
set_pid(pid, target, value)
set_pass_count(value)
set_tolerance(value)
compatible_sensors = [<nxt.sensor.digital._SCompatibility object>]
class nxt.sensor.mindsensors.HID(brick, port, check_compatible=True)

Class for Human Interface Device sensors. These are connected to a computer and look like a keyboard to it.

I2C_ADDRESS = {'command': (65, '<B'), 'factory_scale_divisor': (19, 'B'), 'factory_scale_factor': (18, 'B'), 'keyboard_data': (67, '<B'), 'modifier': (66, '<B'), 'product_id': (8, '8s'), 'sensor_type': (16, '8s'), 'version': (0, '8s')}
I2C_DEV = 4
class Commands
TRANSMIT = 'T'
ASCII_MODE = 'A'
DIRECT_MODE = 'D'
command(command)
set_modifier(mod)
write_data(data)
compatible_sensors = [<nxt.sensor.digital._SCompatibility object>]
class nxt.sensor.mindsensors.PS2(brick, port, check_compatible=True)
I2C_ADDRESS = {'button_set_1': (66, '<B'), 'button_set_2': (67, '<B'), 'command': (65, '<B'), 'factory_scale_divisor': (19, 'B'), 'factory_scale_factor': (18, 'B'), 'product_id': (8, '8s'), 'sensor_type': (16, '8s'), 'version': (0, '8s'), 'x_left_joystick': (68, '<b'), 'x_right_joystick': (70, '<b'), 'y_left_joystick': (69, '<b'), 'y_right_joystick': (71, '<b')}
class ControllerState(buttons_1, buttons_2, left_x, left_y, right_x, right_y)
class Buttons
left = 0
down = 0
right = 0
up = 0
square = 0
cross = 0
circle = 0
triangle = 0
r1 = 0
r2 = 0
r3 = 0
l1 = 0
l2 = 0
l3 = 0
class Commands
POWER_ON = 'E'
POWER_OFF = 'D'
DIGITAL_MODE = 'A'
ANALOG_MODE = 's'
ADPA_ON = 'N'
ADPA_OFF = 'O'
command(command)
get_joystick(xy, lr)
get_buttons(setnum)
get_sample()
compatible_sensors = [<nxt.sensor.digital._SCompatibility object>]