Exemplo n.º 1
0
def create_rrb3(mockmode):
    # type: (bool) -> rrb3.RRB3
    if not mockmode:
        logging.info("Initializing RRB3")
        import rrb3
        return rrb3.RRB3()
    else:
        logging.info("Using mock RRB3")
        import mock_rrb3
        return mock_rrb3.MockRRB3()
Exemplo n.º 2
0
    def __init__(self, config):
        threading.Thread.__init__(self)

        self.config = config
        self.rate = float(self.config.get('rover', 'rate'))
        battery_voltage = self.config.get('hw', 'battery_voltage')
        motor_voltage = self.config.get('hw', 'motor_voltage')
        logging.info('Initializing rrb3...')
        self.rr = rrb3.RRB3(battery_voltage, motor_voltage)
        self.rr.set_led1(0)
        self.rr.set_led1(1)
        logger.info('Initialized rrb3')
        self.is_running = True
Exemplo n.º 3
0
import rrb3 as rrb
import time, random

# Change these for your setup.
BATTERY_VOLTS = 9
MOTOR_VOLTS = 6

# Configure the RRB
rr = rrb.RRB3(9, 6)

tooClose = 20

while True:
    rr.set_motors(.7, 1, .7, 1)
    distance = rr.get_distance()
    print(distance)
    if distance < tooClose:
        rr.set_motors(0, 1, 0, 1)
        rr.forward(.5, .4)
        rr.right(2.3, .5)
        if rr.get_distance() < tooClose:
            rr.left(2.3, .5)
            if rr.get_distance() < tooClose:
                rr.forward(1, .3)
                rr.right(2.3, .5)
                rr.forward(4, .75)
Exemplo n.º 4
0
import sys

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

try:
    import thread
except ImportError:
    import _thread as thread

# raspberry pi IP Address
# IP_ADDRESS = sys.argv[1]
BATTERY_VOLTS = 9
MOTOR_VOLTS = 6

# Configure the RRB
rr = rrb.RRB3(BATTERY_VOLTS, MOTOR_VOLTS)
rr.set_led1(1)
rr.set_led2(1)

# speed
half_speed = 0.2
back_speed = 0.1

start_flag = False


def command(ws, message):
    global start_flag
    if ',' in message:
        message = message.split(',')[1].replace('"', '').replace(']', '')
Exemplo n.º 5
0
#Python 2

import rrb3 as rrb
import time
#import ex_8x8_pixels

rr = rrb.RRB3(6, 3)


def confirm(question):
    answer = input(question)


def test_leds():
    rr.set_led1(0)
    rr.set_led2(0)
    confirm("Are LED1 and LED2 both OFF?")

    rr.set_led1(1)
    rr.set_led2(0)
    confirm("Is LED1 ON and LED2 OFF?")

    rr.set_led1(1)
    rr.set_led2(1)
    confirm("Are LED1 and LED2 both ON?")

    rr.set_led1(0)
    rr.set_led2(0)
    confirm("Are LED1 and LED2 both OFF?")

Exemplo n.º 6
0
# pixyViewH = 75
# pixyImgV = 400
# pixyImgH = 640
# pixel to visual angle conversion factor (only rough approximation) (pixyViewV/pixyImgV + pixyViewH/pixyImgH) / 2
pix2ang_factor = 0.117
# reference object one is the pink earplug (~12mm wide)
refSize1 = 12
# reference object two is side post (~50mm tall)
refSize2 = 50
# this is the distance estimation of an object
objectDist = 0
# this is some desired distance to keep (mm)
targetDist = 100
# reference distance; some fix distance to compare the object distance with
refDist = 400
rr = rrb3.RRB3(9, 6)

blocks = None


def handle_SIGINT(sig, frame):
    """
    Handle CTRL-C quit by setting run flag to false
    This will break out of main loop and let you close
    pixy gracefully
    """
    global run_flag
    run_flag = False


class Blocks(ctypes.Structure):
Exemplo n.º 7
0
import rrb3 as rrb
#from rrb3 import rrb
from random import randint

rr = rrb.RRB3(12, 12)  # Battery voltage 12V, motor 12V

T = 20  # 20 seconds to extend


def test_motors():
    rr.set_motors(0, 0, 0, 0)
    print("Are Both motors stopped?")

    rr.set_motors(1, 0, 1, 0)
    print("Are Both motors going forwards?")

    rr.set_motors(0.5, 0, 0.5, 0)
    print("Are both motors going forwards at half speed?")

    rr.set_motors(1, 1, 1, 1)
    print("Are both motors going backwards?")

    rr.set_motors(0, 0, 0, 0)
    print("Are the motors off now?")


test_motors()

extended = False

try: