Public Member Functions | |
| __init__ (self, bus=0, device=0, monitor=1) | |
| read_debug (self, index) | |
| read_debug_float (self) | |
| set_pid (self, kp, ki, kd) | |
| set_motors (self, start_moving_power, ks, ctrl_pulses) | |
| move (self, left_speed, right_speed) | |
| move_rpm (self, left_rpm, right_rpm) | |
| move_rpm_get_encoders (self, left_rpm, right_rpm) | |
| move_raw (self, left_power, right_power) | |
| move_1m (self, motor, speed) | |
| stop (self) | |
| stop_1m (self, motor) | |
| brake (self, left_torque, right_torque) | |
| brake_1m (self, motor, torque=None) | |
| reset_left_encoder (self) | |
| reset_right_encoder (self) | |
| reset_encoders (self) | |
| led (self, state) | |
| obstacle_emitters (self, state) | |
| servo1 (self, position) | |
| servo2 (self, position) | |
| set_min_battery_V (self, batmin) | |
| read_button (self) | |
| read_battery (self) | |
| read_left_encoder (self) | |
| read_right_encoder (self) | |
| read_left_encoder_increment (self) | |
| read_right_encoder_increment (self) | |
| read_firmware (self) | |
| obstacle_sensors (self) | |
| read_ir_sensors (self) | |
| read_left_range (self) | |
| read_right_range (self) | |
| read_adc (self, channel) | |
| read_adc_0 (self) | |
| read_adc_1 (self) | |
| read_adc_2 (self) | |
| read_adc_3 (self) | |
| read_adc_4 (self) | |
| read_adc_5 (self) | |
| read_adc_6 (self) | |
| read_adc_7 (self) | |
| read_dbg (self, index) | |
| lcd1 (self, data1, data2=None, data3=None, data4=None) | |
| lcd2 (self, data1, data2=None, data3=None, data4=None) | |
| read_line_sensors (self) | |
| read_line (self) | |
Public Attributes | |
| bus = bus | |
| device = device | |
| line_detector = LineDetector() | |
Protected Attributes | |
| _monitor_bnr = Monitor() | |
| _spi = spidev.SpiDev() | |
Static Protected Attributes | |
| int | _KEY1 = 0xAA |
| int | _KEY2 = 0x55 |
| int | _BRAKE_TORQUE = 100 |
| int | _OFF = 0 |
| int | _ON = 1 |
| int | _AN0 = 0 |
| int | _AN1 = 1 |
| int | _AN2 = 2 |
| int | _AN3 = 3 |
| int | _AN4 = 4 |
| int | _AN5 = 5 |
| int | _AN6 = 6 |
| int | _AN7 = 7 |
| int | _COMMAND_FIRMWARE = 0xFE |
| int | _COMMAND_LED = 0xFD |
| int | _COMMAND_SERVO1 = 0xFC |
| int | _COMMAND_SERVO2 = 0xFB |
| int | _COMMAND_LCD_L1 = 0xFA |
| int | _COMMAND_LCD_L2 = 0xF9 |
| int | _COMMAND_IR_EMITTERS = 0xF8 |
| int | _COMMAND_STOP = 0xF7 |
| int | _COMMAND_MOVE = 0xF6 |
| int | _COMMAND_BRAKE = 0xF5 |
| int | _COMMAND_BAT_MIN = 0xF4 |
| int | _COMMAND_SET_PID = 0xF3 |
| int | _COMMAND_MOVE_RAW = 0xF2 |
| int | _COMMAND_SET_MOTORS = 0xF1 |
| int | _COMMAND_ENCL_RESET = 0xF0 |
| int | _COMMAND_ENCR_RESET = 0xEF |
| int | _COMMAND_MOVE_RPM = 0xEE |
| tuple | _COMMAND_MOVE_RPM_R_ENC |
| int | _COMMAND_FUTURE_USE3 = 0xEC |
| int | _COMMAND_FUTURE_USE4 = 0xEB |
| int | _COMMAND_MOVE_1M = 0xEA |
| int | _COMMAND_STOP_1M = 0xE9 |
| int | _COMMAND_BRAKE_1M = 0xE8 |
| int | _COMMAND_FUTURE_USE5 = 0xE7 |
| int | _COMMAND_ADC0 = 0xDF |
| int | _COMMAND_ADC1 = 0xDE |
| int | _COMMAND_ADC2 = 0xDD |
| int | _COMMAND_ADC3 = 0xDC |
| int | _COMMAND_ADC4 = 0xDB |
| int | _COMMAND_ADC5 = 0xDA |
| int | _COMMAND_ADC6 = 0xD9 |
| int | _COMMAND_ADC7 = 0xD8 |
| int | _COMMAND_BAT_READ = 0xD7 |
| int | _COMMAND_BUT_READ = 0xD6 |
| int | _COMMAND_OBSTACLES = 0xD5 |
| int | _COMMAND_IR_SENSORS = 0xD4 |
| int | _COMMAND_ENCL = 0xD3 |
| int | _COMMAND_ENCR = 0xD2 |
| int | _COMMAND_ENCL_INC = 0xD1 |
| int | _COMMAND_ENCR_INC = 0xD0 |
| int | _COMMAND_LINE_READ = 0xCF |
| int | _COMMAND_RANGE_LEFT = 0xCE |
| int | _COMMAND_RANGE_RIGHT = 0xCD |
| int | _COMMAND_ARDUINO_ANA0 = 0xBF |
| int | _COMMAND_ARDUINO_ANA1 = 0xBE |
| int | _COMMAND_ARDUINO_ANA2 = 0xBD |
| int | _COMMAND_ARDUINO_ANA3 = 0xBC |
| int | _COMMAND_ARDUINO_DIG0 = 0xBB |
| int | _COMMAND_ARDUINO_DIG1 = 0xBA |
| int | _COMMAND_ARDUINO_DIG2 = 0xB9 |
| int | _COMMAND_ARDUINO_DIG3 = 0xB8 |
| int | _COMMAND_ARDUINO_DIG4 = 0xB7 |
| int | _COMMAND_ARDUINO_DIG5 = 0xB6 |
| int | _COMMAND_ARDUINO_DIG6 = 0xB5 |
| int | _COMMAND_ARDUINO_DIG7 = 0xB4 |
| int | _COMMAND_ARDUINO_DIG8 = 0xB3 |
| int | _COMMAND_ARDUINO_DIG9 = 0xB2 |
| int | _COMMAND_ARDUINO_DIG10 = 0xB1 |
| int | _COMMAND_ARDUINO_DIG11 = 0xB0 |
| int | _COMMAND_ARDUINO_DIG12 = 0xAF |
| int | _COMMAND_ARDUINO_DIG13 = 0xAE |
| int | _COMMAND_ARDUINO_BUZ = 0xAD |
| int | _COMMAND_ARDUINO_CMP = 0xAC |
| int | _COMMAND_ARDUINO_SNR = 0xAB |
| int | _COMMAND_ARDUINO_GRP1 = 0xAA |
| int | _COMMAND_ARDUINO_GRP2 = 0x9F |
| int | _LCD_CHARS_PER_LINE = 16 |
| int | _delay_TR = 20 |
| int | _delay_SS = 20 |
Class definition to interface with BotnRoll One A By creating an object of this class one can send and receive data to and from a BotnRoll One A robot connected using an spi interface
| onepi.one.BnrOneAPlus.__init__ | ( | self, | |
| bus = 0, | |||
| device = 0, | |||
| monitor = 1 ) |
Constructor for BnrOneAPlus class :param bus: specifies which bus to use, in the case of raspberry pi should be 0 :param device: is the chip select pin. Set to 0 or 1, depending on the connections :param monitor: specifies if this process should be monitored
| onepi.one.BnrOneAPlus.brake | ( | self, | |
| left_torque, | |||
| right_torque ) |
Applies brake torques to motors :param left_torque: torque to apply to the left motor :param right_torque: torque to apply to the right motor
| onepi.one.BnrOneAPlus.brake_1m | ( | self, | |
| motor, | |||
| torque = None ) |
Applies brake torque to a motor :param motor: motor to apply the torque :param torque: torque to apply to the motor
| onepi.one.BnrOneAPlus.lcd1 | ( | self, | |
| data1, | |||
| data2 = None, | |||
| data3 = None, | |||
| data4 = None ) |
Sends data to be displayed on the first line of the lcd :param data1: piece of data to display on the lcd :param data2: optional piece of data to display on the lcd :param data3: optional piece of data to display on the lcd :param data4: optional piece of data to display on the lcd
| onepi.one.BnrOneAPlus.lcd2 | ( | self, | |
| data1, | |||
| data2 = None, | |||
| data3 = None, | |||
| data4 = None ) |
Sends data to be displayed on the second line of the lcd :param data1: piece of data to display on the lcd :param data2: optional piece of data to display on the lcd :param data3: optional piece of data to display on the lcd :param data4: optional piece of data to display on the lcd
| onepi.one.BnrOneAPlus.led | ( | self, | |
| state ) |
Turns on/off the led :param state: turns led ON for odd numbers, OFF otherwise
| onepi.one.BnrOneAPlus.move | ( | self, | |
| left_speed, | |||
| right_speed ) |
Sends left and right wheel speeds to the spi device. :param left_speed: desired left wheel speed :param right_speed: desired right wheel speed
| onepi.one.BnrOneAPlus.move_1m | ( | self, | |
| motor, | |||
| speed ) |
Sets the specified motor to run at the given speed :param motor: number of the motor to set the speed for :param speed: speed to set the motor with
| onepi.one.BnrOneAPlus.move_raw | ( | self, | |
| left_power, | |||
| right_power ) |
Sends calibration power data to the spi device :param left_power: power for left wheel :param right_power: power for right wheel
| onepi.one.BnrOneAPlus.move_rpm | ( | self, | |
| left_rpm, | |||
| right_rpm ) |
Sends left and right wheel speeds to the spi device. :param left_speed: desired left wheel speed :param right_speed: desired right wheel speed
| onepi.one.BnrOneAPlus.move_rpm_get_encoders | ( | self, | |
| left_rpm, | |||
| right_rpm ) |
Sends left and right wheel speeds to the spi device and reads back encoder values. :param left_rpm (int): Desired left wheel speed in RPM :param right_rpm (int): Desired right wheel speed in RPM :return tuple: Left and right encoder values (left_encoder, right_encoder)
| onepi.one.BnrOneAPlus.obstacle_emitters | ( | self, | |
| state ) |
Turns on/off the obstacle emitters :param state: turns emitters ON for odd numbers, OFF otherwise
| onepi.one.BnrOneAPlus.obstacle_sensors | ( | self | ) |
Reads information from obstacle sensors
Returns:
0 if no obstacles detected
1 if obstacle detected on the left side only
2 if obstacle detected on the left side only
3 if obstacle detected on both sides
:return: number representing the obstacle detection
:rtype: int
| onepi.one.BnrOneAPlus.read_adc | ( | self, | |
| channel ) |
Reads adc channel. Expects channel to be in the valid range [0-7] If ouside the range should return 0. :param channel: adc input channel to read from :return: value read from the given adc channel :rtype: int
| onepi.one.BnrOneAPlus.read_adc_0 | ( | self | ) |
Reads adc channel 0 :return: value read from the given adc channel :rtype: int
| onepi.one.BnrOneAPlus.read_adc_1 | ( | self | ) |
Reads adc channel 1 :return: value read from the given adc channel :rtype: int
| onepi.one.BnrOneAPlus.read_adc_2 | ( | self | ) |
Reads adc channel 2 :return: value read from the given adc channel :rtype: int
| onepi.one.BnrOneAPlus.read_adc_3 | ( | self | ) |
Reads adc channel 3 :return: value read from the given adc channel :rtype: int
| onepi.one.BnrOneAPlus.read_adc_4 | ( | self | ) |
Reads adc channel 4 :return: value read from the given adc channel :rtype: int
| onepi.one.BnrOneAPlus.read_adc_5 | ( | self | ) |
Reads adc channel 5 :return: value read from the given adc channel :rtype: int
| onepi.one.BnrOneAPlus.read_adc_6 | ( | self | ) |
Reads adc channel 6 :return: value read from the given adc channel :rtype: int
| onepi.one.BnrOneAPlus.read_adc_7 | ( | self | ) |
Reads adc channel 7 :return: value read from the given adc channel :rtype: int
| onepi.one.BnrOneAPlus.read_battery | ( | self | ) |
Reads the current voltage supplied to BotnRoll One A :return: voltage (V) of input power supply :rtype: float
| onepi.one.BnrOneAPlus.read_button | ( | self | ) |
Gets the button number of the robot that is being pressed Looking at the robot with the buttons on the right side of the LCD, returns: 0 for none 1 for button on top 2 for button in the middle 3 for button at the bottom :return: number of the button being pressed (0, 1, 2, 3)
| onepi.one.BnrOneAPlus.read_dbg | ( | self, | |
| index ) |
Reads debug info from the device :param index: index of debug register :return: contents of the register :rtype: int
| onepi.one.BnrOneAPlus.read_debug | ( | self, | |
| index ) |
reads a debug variable (float) from the spi device
| onepi.one.BnrOneAPlus.read_debug_float | ( | self | ) |
reads a debug variable (float) from the spi device
| onepi.one.BnrOneAPlus.read_firmware | ( | self | ) |
Reads the version of the firmware on the microcontroller :return: firmware version :rtype: list of bytes
| onepi.one.BnrOneAPlus.read_ir_sensors | ( | self | ) |
Reads infrared sensors. Returns 1 if both sensors detect input, 0 otherwise. :return: 1 if both sensors detect input, 0 otherwise
| onepi.one.BnrOneAPlus.read_left_encoder | ( | self | ) |
Reads the value of the left encoder since last request Note: Every time we read the encoder it resets itself :return: counter of the encoder :rtype: int
| onepi.one.BnrOneAPlus.read_left_encoder_increment | ( | self | ) |
Reads the left encoder and keeps incrementing its value It does NOT reset the value after reading it :return: encoder reading :rtype: int
| onepi.one.BnrOneAPlus.read_left_range | ( | self | ) |
Reads the range value detected by the sensor on the left side :return: distance reported by the sensor (mm) :rtype: int
| onepi.one.BnrOneAPlus.read_line | ( | self | ) |
Reads line sensors and returns a value between -100 and 100 depending on the position the line is detected :return: value between -100 and 100 :rtype: float
| onepi.one.BnrOneAPlus.read_line_sensors | ( | self | ) |
reads sensors from adc channels 0 to 7 :return: sensor readings in a list :rtype: list of integers
| onepi.one.BnrOneAPlus.read_right_encoder | ( | self | ) |
Reads the value of the right encoder since last request Note: Every time we read the encoder it resets itself :return: counter of the encoder :rtype: int
| onepi.one.BnrOneAPlus.read_right_encoder_increment | ( | self | ) |
Reads the right encoder and keeps incrementing its value It does NOT reset the value after reading it :return: encoder reading :rtype: int
| onepi.one.BnrOneAPlus.read_right_range | ( | self | ) |
Reads the range value detected by the sensor on the right side :return: distance reported by the sensor (mm) :rtype: int
| onepi.one.BnrOneAPlus.reset_encoders | ( | self | ) |
Resets both left and right encoders
| onepi.one.BnrOneAPlus.reset_left_encoder | ( | self | ) |
Reset counter for the left encoder
| onepi.one.BnrOneAPlus.reset_right_encoder | ( | self | ) |
Reset counter for the right encoder
| onepi.one.BnrOneAPlus.servo1 | ( | self, | |
| position ) |
Sets servo1 position :param position: desired position
| onepi.one.BnrOneAPlus.servo2 | ( | self, | |
| position ) |
Sets servo2 position :param position: desired position
| onepi.one.BnrOneAPlus.set_min_battery_V | ( | self, | |
| batmin ) |
Sets the minimum battery level. If battery drops below this value the BotnRoll One A will issue a warning on the LCD and won't let motors to move :para batmin: minimum voltage level acceptable for the battery (V)
| onepi.one.BnrOneAPlus.set_motors | ( | self, | |
| start_moving_power, | |||
| ks, | |||
| ctrl_pulses ) |
:param start_moving_power pwm applied initially when wheel is stopped :param ks gain multiplier to adjust the inital pwm :param ctrl_pulses pulses read at 25ms when running at full speed
| onepi.one.BnrOneAPlus.set_pid | ( | self, | |
| kp, | |||
| ki, | |||
| kd ) |
Sets the pid params for motor control
| onepi.one.BnrOneAPlus.stop | ( | self | ) |
Sends command to stop both motors
| onepi.one.BnrOneAPlus.stop_1m | ( | self, | |
| motor ) |
Sends command to stop the specified motor :param motor: number of the motor to stop
|
staticprotected |