Пример #1
0
def triple_input_filter_all_input_scaled():
    printer.name = "triple_input_filter_all_input_scaled"

    printer.source = join_values(
        scaled_pair(joystick_left.values, -10, 10, -100, 100),
        scaled_pair(filter_messages(messages.values, type='JOYSTICK', id=0), -50, 50, -100, 100),
        scaled_pair(filter_messages(messages.values, type='JOYSTICK', id=1), -10, 10, -100, 100),
    )
Пример #2
0
def print_pantilt_three_combined_streams():
    # Map input values from local and remote joysticks (scaled)
    # Accepts remote 'PANTILT' messages that  (scaling not required)
    printer.name = "print_pantilt_three_combined_streams"
    printer.source = join_values(
        scaled_pair(joystick_left.values, 0, 180, -100, 100),
        scaled_pair(filter_messages(messages.values, type='JOYSTICK', id=1), 0, 180, -100, 100),
        filter_messages(messages.values, type='PANTILT', id=0)
    )
Пример #3
0
def triple_input_pantilt_scaling_no_conversion():

    pan_tilt.source = join_values(
        filter_messages(messages.values, type='JOYSTICK', id=1),
        filter_messages(messages.values, type='PANTILT', id=0),
        scaled_pair(joystick_left.values, 0, 180, -100, 100),
    )
Пример #4
0
    def setUpClass():

        VirtualJoystickTest.joystick0 = Joystick(MOTOR_JOYSTICK_ID)
        VirtualJoystickTest.motors = Wheelbase(left=LEFT_MOTOR_ID,
                                               right=RIGHT_MOTOR_ID)
        VirtualJoystickTest.motors.source = steering_mixer(
            VirtualJoystickTest.joystick0.values)
        #VirtualJoystickTest.motors.source_delay = 0.1

        VirtualJoystickTest.joystick1 = Joystick(PANTILT_JOYSTICK_ID)
        VirtualJoystickTest.pan_tilt = PanTilt(pan=PAN_SERVO_ID,
                                               tilt=TILT_SERVO_ID)
        VirtualJoystickTest.pan_tilt.source = scaled_pair(
            VirtualJoystickTest.joystick1.values, MAX_ANGLE, MIN_ANGLE,
            JOY_AXIS_MIN, JOY_AXIS_MAX)
        #VirtualJoystickTest.pan_tilt.source_delay = 0.1

        # Setup Selenium

        capabilities = DesiredCapabilities.CHROME
        capabilities['loggingPrefs'] = {'browser': 'ALL'}

        if VirtualJoystickTest.IS_CI_BUILD:
            username = environ["SAUCE_USERNAME"]
            access_key = environ["SAUCE_ACCESS_KEY"]
            capabilities["tunnel-identifier"] = environ["TRAVIS_JOB_NUMBER"]
            capabilities["build"] = environ["TRAVIS_BUILD_NUMBER"]
            capabilities["tags"] = [environ["TRAVIS_PYTHON_VERSION"], "CI"]
            hub_url = "%s:%s@localhost:4445" % (username, access_key)
            VirtualJoystickTest.driver = webdriver.Remote(
                desired_capabilities=capabilities,
                command_executor="http://%s/wd/hub" % hub_url)
        else:
            #DRIVER = webdriver.Safari()  # see: http://elementalselenium.com/tips/69-safari
            #DRIVER = webdriver.Chrome()   # see: https://sites.google.com/a/chromium.org/chromedriver/downloads
            VirtualJoystickTest.driver = webdriver.Chrome(
                desired_capabilities=capabilities)

        VirtualJoystickTest.driver.implicitly_wait(BROWSER_WAIT_SECONDS)
        VirtualJoystickTest.driver.maximize_window()
        VirtualJoystickTest.driver.get("http://localhost:8000/")
        VirtualJoystickTest.canvas = VirtualJoystickTest.driver.find_element_by_id(
            "camera_view")

        VirtualJoystickTest.fake_set_speed_called_values = [
            OccuranceRecorder(allow_repeating_items=False),
            OccuranceRecorder(allow_repeating_items=False)
        ]

        VirtualJoystickTest.fake_set_angle_called_values = [
            OccuranceRecorder(allow_repeating_items=False),
            OccuranceRecorder(allow_repeating_items=False)
        ]
Пример #5
0
def robot():
    wheelbase.source = steering_mixer(
        join_values(
            filter_messages(messages.values, type='JOYSTICK', id=0),
            joystick_right.values
        )
    )

    pan_tilt.source = join_values(
        filter_messages(messages.values, type='PANTILT', id=0),
        scaled_pair(
            join_values(joystick_left.values, filter_messages(messages.values, type='JOYSTICK', id=1)), 180, 0, -100, 100),
        # filter_messages(messages.values, type='PANTILT', id=0),
        # scaled_pair(joystick_left.values, 0, 180, -100, 100),
        # scaled_pair(filter_messages(messages.values, type='JOYSTICK', id=1), 0, 180, -100, 100),
    )
Пример #6
0
def mock_robot():
    printer.name = "mock_robot___WHEELS"

    printer.source = steering_mixer(
        join_values(
            filter_messages(messages.values, type='JOYSTICK', id=0),
            joystick_right.values
        )
    )

    printer2.name = "mock_robot__PANTILT"

    printer2.source = join_values(
        filter_messages(messages.values, type='PANTILT', id=0),
        scaled_pair(
            join_values(joystick_left.values, filter_messages(messages.values, type='JOYSTICK', id=1)), 180, 0, -100, 100),
        )
Пример #7
0
def mock_robot_builtin_pantilt_conversion():
    printer.name = "mock_robot_builtin_pantilt_conversion___WHEELS"

    printer.source = steering_mixer(
        join_values(
            filter_messages(messages.values, type='JOYSTICK', id=0),
            joystick_right.values
        )
    )

    printer2.name = "mock_robot_builtin_pantilt_conversion__PANTILT"

    printer2.source = join_values(
        filter_messages(messages.values, type='PANTILT', id=0),
        pantilt_converter(
            join_values(
                scaled_pair(joystick_left.values, -10, 10, -100, 100),
                filter_messages(messages.values, type='JOYSTICK', id=1),
            )
        )
    )
Пример #8
0
def dual_triple_input_filter_all_input_scaled_pantilt_conversion():
    printer.name = "dual_triple_input_filter_all_input_scaled_pantilt_conversion__ONE"

    printer.source = pantilt_converter(
        join_values(
            scaled_pair(joystick_left.values, -10, 10, -100, 100),
            scaled_pair(filter_messages(messages.values, type='JOYSTICK', id=0), -50, 50, -100, 100),
            scaled_pair(filter_messages(messages.values, type='JOYSTICK', id=1), -10, 10, -100, 100),
        )
    )

    printer2.name = "dual_triple_input_filter_all_input_scaled_pantilt_conversion__TWO"
    printer2.source = pantilt_converter(
        join_values(
            scaled_pair(joystick_left.values, -10, 10, -100, 100),
            scaled_pair(filter_messages(messages.values, type='JOYSTICK', id=0), -50, 50, -100, 100),
            scaled_pair(filter_messages(messages.values, type='JOYSTICK', id=1), -10, 10, -100, 100),
        )
    )
Пример #9
0
#!/usr/bin/python3

# see: https://github.com/CamJam-EduKit/EduKit3

from gpiozero import CamJamKitRobot
from picraftzero import Joystick, steering_mixer, scaled_pair, start

robot = CamJamKitRobot()
joystick = Joystick()

robot.source = scaled_pair(steering_mixer(joystick.values),
                           -1.0,
                           1.0,
                           input_min=-100,
                           input_max=100)

start()
Пример #10
0
from picraftzero.config import get_config

config = get_config()
script_file = config.get('service', 'script', fallback=None)

if script_file:
    logger.info("Running user script: {}".format(script_file))
    with open(script_file) as f:
        code = compile(f.read(), script_file, 'exec')
        exec(code)
        # user script is expected to exit with an error code or 0, so shouldnt reach here
        exit(1)

# see the `pantilt.py` example for more info.

from picraftzero import Wheelbase, PanTilt, Joystick, steering_mixer, scaled_pair, start, filter_messages, MessageReceiver, join_values
joystick_right = Joystick(0)
joystick_left = Joystick(1)
messages = MessageReceiver(port=8001)

wheelbase = Wheelbase(left=1, right=0)
pan_tilt = PanTilt(pan=0, tilt=1)

wheelbase.source = steering_mixer(joystick_right.values)
pan_tilt.source = join_values(
    filter_messages(messages.values, type='PANTILT', id=0),
    scaled_pair(joystick_left.values, 180, 0, -100, 100))

if __name__ == '__main__':
    start()
Пример #11
0
def print_local_joystick_scaled():
    printer.name = "print_local_joystick_scaled"
    printer.source = scaled_pair(joystick_right.values, 180, 0, -100, 100)