Ejemplo n.º 1
0
def main():
    mac_address = "aa:bb:cc:dd:ee:ff"
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()
        sleep(20)

        volume = sphero.user_io.get_audio_volume()
        print(volume)
        sphero.animatronics.play_animation(50)
        sleep(5)

        sphero.user_io.set_audio_volume(0)
        volume = sphero.user_io.get_audio_volume()
        print(volume)
        sphero.animatronics.play_animation(50)
        sleep(5)

        sphero.user_io.set_audio_volume(255)
        volume = sphero.user_io.get_audio_volume()
        print(volume)
        sphero.animatronics.play_animation(50)
        sleep(5)

        sphero.user_io.set_audio_volume(20)
        volume = sphero.user_io.get_audio_volume()
        print(volume)
        sphero.animatronics.play_animation(50)
        sleep(5)

        for data in LMQAnimation:
            sphero.animatronics.play_animation_and_wait(data.value,
                                                        target_id=None,
                                                        timeout=10)

        sphero.power.enter_soft_sleep()
Ejemplo n.º 2
0
def energetic_bump_spin():
    speed = 125
    heading = 0
    with Sphero(mac_address=mac_address) as sphero:
        sleep(2)
        print(f"Bump with speed {speed} and heading {heading}")

        for i in range(2):
            sphero.driving.drive_with_heading(speed, heading,
                                              Direction.forward)
            sleep(0.20)
            sphero.driving.drive_with_heading(0, heading, Direction.forward)
            sleep(0.65)
            sphero.driving.drive_with_heading(speed, heading,
                                              Direction.reverse)
            sleep(0.10)
            sphero.driving.drive_with_heading(0, heading, Direction.forward)
            sleep(0.65)

        sphero.driving.tank_drive(100, 90, Direction.forward)
        sleep(4)
        sphero.driving.drive_with_heading(0, heading, Direction.forward)
        sleep(1)

    return "energetic bump and spin performed"
Ejemplo n.º 3
0
def toy_scanner(*,
                toy_type: Toy = None,
                name: str = None,
                timeout: float = 5.0) -> Sphero:
    delegate = _ScanDelegate()
    running_event = Event()
    running_event.set()

    with ThreadPoolExecutor(max_workers=1) as executor:
        executor.submit(_scanner, delegate, timeout, running_event)
        for scan_item in _queue_iter(delegate.queue, timeout):

            # none when time is out
            if not scan_item:
                break

            if ((not name and not toy_type)
                    or (name and name == scan_item.name)
                    or (toy_type and scan_item.toy_type == toy_type)):
                running_event.clear()
                return Sphero(
                    mac_address=scan_item.mac_address,
                    toy_type=scan_item.toy_type,
                )

    raise PySpheroNotFoundError("Toy not found")
Ejemplo n.º 4
0
def main():
    global x, flag
    mac_address = "d6:bc:6a:05:79:b6"
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()
        sphero.sensor.set_notify(notify_callback, CoreTime, Quaternion)

    print('start')
    # for i in range(10):
    while True:
        if (flag):
            print("x: {0}".format(x))
            sleep(1)
        # sleep(5)
    with Sphero(mac_address=mac_address) as sphero:
        sphero.sensor.cancel_notify_sensors()
        sphero.power.enter_soft_sleep()
Ejemplo n.º 5
0
def main():
    mac_address = "aa:bb:cc:dd:ee:ff"
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()
        sphero.sensor.set_notify(notify_callback, CoreTime, Quaternion)
        sleep(2)
        sphero.sensor.cancel_notify_sensors()
        sphero.power.enter_soft_sleep()
Ejemplo n.º 6
0
def control_robot(mac_address):

    p_start = (0, 0)
    p_end = (0, 50)

    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()
        drive_line.drive_cubic_bezier(sphero, p_start, p_end, Type.DERIVATIVE)
        sphero.power.enter_soft_sleep()
Ejemplo n.º 7
0
def main():
    mac_address = "aa:bb:cc:dd:ee:ff"
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()
        sleep(20)

        sphero.power.enter_soft_sleep()

        #deep sleep
        sphero.power.enter_deep_sleep()
Ejemplo n.º 8
0
def send():
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()

        sleep(2)
        print(f"Send drive with speed {speed} and heading {heading}")

        sphero.driving.drive_with_heading(speed, heading, Direction.forward)

        sphero.power.enter_soft_sleep()
Ejemplo n.º 9
0
def main():
    mac_address = "aa:bb:cc:dd:ee:ff"
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()
        for i in range(20):
            sphero.user_io.set_all_leds_8_bit_mask(back_color=Color(blue=0xff))
            sleep(0.25)
            sphero.user_io.set_all_leds_8_bit_mask(front_color=Color(red=0xff))
            sleep(0.25)

        sphero.power.enter_soft_sleep()
Ejemplo n.º 10
0
def main():
    #mac_address = "aa:bb:cc:dd:ee:ff"
    mac_address = "f7:e2:c2:7d:4c:bb"
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()
        sleep(2)
        sphero.user_io.set_all_leds_8_bit_mask()
        #testing = True
        #while(testing):
        #sphero.user_io.set_all_leds_8_bit_mask(front_color=Color(blue=255,green=255,red=255),back_color=Color(blue=255,green=255,red=255))
        sphero.user_io.set_led_matrix_one_color(color=Color(blue=255))
        #sphero.sensor.set_notify(notify_callback, CoreTime, Accelerometer)

        #sphero.sensor.cancel_notify_sensors()
        #sphero.sensor.cancel_notify_sensors()
        # while(sphero.sensor.get_ambient_light_sensor_value() <= 75):
        #     print("Light Sensor: {}",sphero.sensor.get_ambient_light_sensor_value(), end="\r")
        #     sphero.user_io.set_all_leds_8_bit_mask()
        # sleep(1)
        # sphero.user_io.set_all_leds_8_bit_mask(front_color=Color(blue=55))
        # sphero.user_io.set_led_matrix_text_scrolling(string=":)",color=Color(blue=255,red=0,green=0))
        # sleep(2)
        # sphero.driving.drive_with_heading(1, 270, Direction.forward)
        # sleep(.1)
        # sphero.driving.drive_with_heading(1, 90, Direction.forward)
        # sleep(.1)
        # sphero.driving.drive_with_heading(1, 0, Direction.forward)
        # sleep(1)
        # sphero.user_io.set_led_matrix_one_color(color=Color(green=255))
        # sphero.driving.drive_with_heading(252, 5, Direction.forward)
        # sleep(3.2)
        # sphero.user_io.set_led_matrix_one_color(color=Color(red=255))
        # sphero.driving.drive_with_heading(1, 0, Direction.forward)
        # sleep(2)
        # sphero.driving.drive_with_heading(200, 180, Direction.forward)
        # sleep(2)
        # sphero.driving.drive_with_heading(200, 200, Direction.forward)
        # sleep(.5)
        # sphero.driving.drive_with_heading(200, 180, Direction.forward)
        # sleep(1.5)
        # sphero.driving.drive_with_heading(1, 180, Direction.forward)
        # sphero.driving.reset_yaw()
        # sphero.driving.drive_with_heading(75, 90, Direction.forward)
        #sphero.driving.tank_drive(right_speed=255,left_speed=255)
        #sphero.user_io.set_led_matrix_one_color(color=Color(blue=255))
        #sphero.user_io.set_led_matrix_single_character(symbol="*",color=Color(blue=255,red=255,green=255))
        #sphero.user_io.set_led_matrix_text_scrolling(string="Get pi",color=Color(blue=255,red=255,green=255))
        #sleep(5)
        #sphero.driving.raw_motor(left_speed=200,left_direction=DirectionRawMotor.reverse,right_speed=200,right_direction=DirectionRawMotor.forward)
        #sphero.driving.raw_motor(left_direction=Direction.reverse,left_speed=100,right_direction=Direction.forward,right_speed=200)
        #sphero.driving.drive_with_heading(255, 0, Direction.forward)
        sleep(40)
        sphero.power.enter_soft_sleep()
Ejemplo n.º 11
0
def main():
    mac_address = "d6:bc:6a:05:79:b6"
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()

        for _ in range(5):
            sleep(2)
            speed = random.randint(50, 100)
            heading = random.randint(0, 360)
            print(f"Send drive with speed {speed} and heading {heading}")

            sphero.driving.drive_with_heading(speed, heading, Direction.forward)

        sphero.power.enter_soft_sleep()
Ejemplo n.º 12
0
def main():
    def callback(value):
        print(value.name)

    mac_address = "aa:bb:cc:dd:ee:ff"
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()
        sleep(10)

        #enable capa touch
        sphero.user_io.enable_cap_touch(True, callback)
        sleep(30)

        sphero.power.enter_soft_sleep()
Ejemplo n.º 13
0
def main():
    mac_address = "d6:bc:6a:05:79:b6"
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()
        for i in range(20):
            print('blink')
            sphero.user_io.set_all_leds_8_bit_mask(back_color=Color(blue=0xff))
            sleep(0.25)
            sphero.user_io.set_all_leds_8_bit_mask(front_color=Color(red=0xff))
            sleep(0.25)

        sphero.power.enter_soft_sleep()

    print('Exit with')
Ejemplo n.º 14
0
def normal_eyes():
    with Sphero(mac_address=mac_address) as sphero:
        sleep(2)
        print("Show eyes in matrix")
        pixels = [
            # Left Eye
            Pixel(x=0, y=1),
            Pixel(x=0, y=2),
            Pixel(x=0, y=3),
            Pixel(x=1, y=1),
            Pixel(x=1, y=2),
            Pixel(x=1, y=3),
            Pixel(x=2, y=1),
            Pixel(x=2, y=2),
            Pixel(x=2, y=3),
            # Right Eye
            Pixel(x=5, y=1),
            Pixel(x=5, y=2),
            Pixel(x=5, y=3),
            Pixel(x=6, y=1),
            Pixel(x=6, y=2),
            Pixel(x=6, y=3),
            Pixel(x=7, y=1),
            Pixel(x=7, y=2),
            Pixel(x=7, y=3)
        ]
        colors = [
            # Left Eye
            Color(red=0xff, green=0xff, blue=0xff),
            Color(red=0xff, green=0xff, blue=0xff),
            Color(red=0xff, green=0xff, blue=0xff),
            Color(red=0xff, green=0xff, blue=0xff),
            Color(blue=0xff),
            Color(red=0xff, green=0xff, blue=0xff),
            Color(red=0xff, green=0xff, blue=0xff),
            Color(red=0xff, green=0xff, blue=0xff),
            Color(red=0xff, green=0xff, blue=0xff),
            # Right Eye
            Color(red=0xff, green=0xff, blue=0xff),
            Color(red=0xff, green=0xff, blue=0xff),
            Color(red=0xff, green=0xff, blue=0xff),
            Color(red=0xff, green=0xff, blue=0xff),
            Color(blue=0xff),
            Color(red=0xff, green=0xff, blue=0xff),
            Color(red=0xff, green=0xff, blue=0xff),
            Color(red=0xff, green=0xff, blue=0xff),
            Color(red=0xff, green=0xff, blue=0xff)
        ]
        for (pixel, color) in zip(pixels, colors):
            sphero.user_io.set_led_matrix_pixel(pixel, color)
Ejemplo n.º 15
0
def main():
    mac_address = "F1:B6:E8:5A:7B:D7"  #Sphero 1
    #mac_address = "F1:8D:AE:17:9D:75" #Sphero 2
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()
        sphero.sensor.set_notify(notify_callback, CoreTime, Accelerometer)
        print(f"Sensors On!")
        speed = 255
        heading = 0
        #sphero.driving.reset_yaw()
        sleep(1)
        sphero.driving.drive_with_heading(speed, heading, Direction.forward)
        print(f"Motors Engaged!")
        sleep(1)
        sphero.sensor.cancel_notify_sensors()
        print(f"Sensors Disengaged!")
Ejemplo n.º 16
0
def main():

    mac_address = "aa:bb:cc:dd:ee:ff"
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()
        sleep(10)

        #get battery info
        battery_state = sphero.power.get_battery_state_LMQ()
        print("Battery is: ", battery_state.name)

        #get battery percentage
        battery_percentage = sphero.power.get_battery_percentage()
        print("Battery level: ", battery_percentage, " %")

        sphero.power.enter_soft_sleep()
Ejemplo n.º 17
0
def main(args=None):
    rclpy.init(args=args)
    quaternion_publisher = QuaternionPublisher()

    mac_address = "d6:bc:6a:05:79:b6"
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()
        sphero.sensor.set_notify(notify_callback, Quaternion)

        rclpy.spin(quaternion_publisher)

        quaternion_publisher.destroy_node()
        rclpy.shutdown()

        sphero.sensor.cancel_notify_sensors()
        sphero.power.enter_soft_sleep()
Ejemplo n.º 18
0
def main():

    mac_address = "aa:bb:cc:dd:ee:ff"
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()
        sleep(10)

        #Force front headlight on
        sphero.user_io.set_headlights(255)
        #Headlight in automatic
        sphero.user_io.set_headlights(0)

        for x in range(0x0, 0x39, 0x2):
            sphero.user_io.set_taillights(x)
            sleep(0.1)

        sphero.power.enter_soft_sleep()
Ejemplo n.º 19
0
def mild_bump():
    speed = 75
    heading = 0
    with Sphero(mac_address=mac_address) as sphero:
        sleep(2)
        print(f"Bump with speed {speed} and heading {heading}")

        for i in range(2):
            sphero.driving.drive_with_heading(speed, heading,
                                              Direction.forward)
            sleep(0.4)
            sphero.driving.drive_with_heading(0, heading, Direction.forward)
            sleep(1)
            sphero.driving.drive_with_heading(speed, heading,
                                              Direction.reverse)
            sleep(0.3)
            sphero.driving.drive_with_heading(0, heading, Direction.forward)
            sleep(1)
    return "mild bump performed"
Ejemplo n.º 20
0
def calm_bump():
    speed = 50
    heading = 0
    with Sphero(mac_address=mac_address) as sphero:
        sleep(2)
        print(f"Bump with speed {speed} and heading {heading}")

        for i in range(2):
            sphero.driving.drive_with_heading(speed, heading,
                                              Direction.forward)
            sleep(0.75)
            sphero.driving.drive_with_heading(0, heading, Direction.forward)
            sleep(1.25)
            sphero.driving.drive_with_heading(speed, heading,
                                              Direction.reverse)
            sleep(0.65)
            sphero.driving.drive_with_heading(0, heading, Direction.forward)
            sleep(1.25)
    return "calm bump performed"
Ejemplo n.º 21
0
def main():
    mac_address = "aa:bb:cc:dd:ee:ff"
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()
        sleep(8)
        sphero.driving.ackermann_reset(0x0,0x0)
        sphero.driving.ackermann_drive(0x0, 0x0)

        #right
        for x in range(0x3e800000,0x3f800000, 0x50000):
            sphero.driving.ackermann_drive(x, 0x0)
            sleep(0.1)
        sleep(2)
        for x in range(0x3f800000,0x3e800000, -0x50000):
            sphero.driving.ackermann_drive(x, 0x0)
            sleep(0.1)

        #left
        for x in range(0xbe800000,0xbf800000, 0x50000):
            sphero.driving.ackermann_drive(x, 0x0)
            sleep(0.1)
        sleep(2)
        for x in range(0xbf800000,0xbe800000, -0x50000):
            sphero.driving.ackermann_drive(x, 0x0)
            sleep(0.1)

        #forward
        for x in range(0x3e000000,0x3f800000, 0x50000):
            sphero.driving.ackermann_drive(0x0, x)
            sleep(0.1)
        for x in range(0x3f800000,0x3e000000, -0x50000):
            sphero.driving.ackermann_drive(0x0, x)
            sleep(0.1)

        #reverse
        for x in range(0xBe000000,0xBf800000, 0x50000):
            sphero.driving.ackermann_drive(0x0, x)
            sleep(0.1)
        for x in range(0xBf800000,0xBe000000, -0x50000):
            sphero.driving.ackermann_drive(0x0, x)
            sleep(0.1)

        sphero.power.enter_soft_sleep()
Ejemplo n.º 22
0
def main(args=None):

    mac_address = "d6:bc:6a:05:79:b6"
    with Sphero(mac_address=mac_address) as sphero:
        try:
            sphero.power.wake()
            rclpy.init(args=args)
            simple_sphero_driver = SimpleSpheroDriver(sphero)
            rclpy.spin(simple_sphero_driver)
            print("Spin end")
            sphero.power.enter_soft_sleep()

        except KeyboardInterrupt:
            print("Keyboarrd Interrupt!")
            pass

        finally:
            print("Finally")
            sphero.power.enter_soft_sleep()
            simple_sphero_driver.destroy_node()
            rclpy.shutdown()
Ejemplo n.º 23
0
def dizzy_look_left():
    with Sphero(mac_address=mac_address) as sphero:
        sleep(2)
        print("Look left")
        pixels = [
            # Left Eye
            Pixel(x=1, y=3),
            Pixel(x=2, y=3),
            # Right Eye
            Pixel(x=6, y=1),
            Pixel(x=7, y=1)
        ]
        colors = [
            # Left Eye
            Color(red=0xff, green=0xff, blue=0xff),
            Color(blue=0xff),
            # Right Eye
            Color(red=0xff, green=0xff, blue=0xff),
            Color(blue=0xff)
        ]
        for (pixel, color) in zip(pixels, colors):
            sphero.user_io.set_led_matrix_pixel(pixel, color)
Ejemplo n.º 24
0
def happy_look_right():
    with Sphero(mac_address=mac_address) as sphero:
        sleep(2)
        print("Look right")
        pixels = [
            # Left Eye
            Pixel(x=1, y=2),
            Pixel(x=0, y=2),
            # Right Eye
            Pixel(x=6, y=2),
            Pixel(x=5, y=2)
        ]
        colors = [
            # Left Eye
            Color(red=0xff, green=0xff, blue=0xff),
            Color(blue=0xff),
            # Right Eye
            Color(red=0xff, green=0xff, blue=0xff),
            Color(blue=0xff)
        ]
        for (pixel, color) in zip(pixels, colors):
            sphero.user_io.set_led_matrix_pixel(pixel, color)
Ejemplo n.º 25
0
        logger.debug(f"Send {packet}")
        self.ch_api_v2.write(packet.build(), withResponse=False) #changed to false
        #return self.packet_collector.get_response(packet, raise_api_error, timeout=timeout)

#I love python
BluepyAdapter.write = my_write

#total time for the robot running
RUNNING_TIME=10
#the lab's robots' adresses
addresses=["E4:C9:D4:82:B8:4A", "CF:A1:99:E6:60:CA", "EA:16:30:8A:40:0A"]
#change the adress here depanding which robot you want to use
robot_adress=addresses[1]

def drive(addresses, starting_time
    with Sphero(mac_address=robot_address) as sphero:
        print('robot connected')
        try:
            sphero.power.wake()
            print('robot awake')
        except:
            sphero.power.enter_soft_sleep()
            print('go back to sleep')
            sphero.power.wake()
            print("now you're awake ?")
        current_time=time.time()
        #constantly print the bot's gyroscope info
        try:
            sphero.sensor.set_notify(notify_callback, CoreTime, Quaternion)
            print('sensor on')
        except:
Ejemplo n.º 26
0
def main():
    mac_address = "C2:03:29:02:E7:17"
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()
        sleep(2)
        sphero.power.enter_soft_sleep()
Ejemplo n.º 27
0
def main():
    print("Connecting to Sphero...", end=" ")
    ### Connect to Sphero Bolt ###
    mac_address = "f7:e2:c2:7d:4c:bb"
    with Sphero(mac_address=mac_address) as sphero:
        print("DONE!")
        sphero.power.wake()
        sleep(2)
        sphero.user_io.set_all_leds_8_bit_mask()
        sleep(1)
        print("Gathering Pin Points...")
        getPinLocation(25)
        print("")
        print("DONE!")
        print("Gathering Sphero Points...")
        sphero.user_io.set_led_matrix_one_color(color=Color(blue=255))
        getSpheroLocation(25)
        print("")
        print("DONE!")
        print("pinCoords:", pinCoords)
        print("roboCoords:", roboCoords)

        ### Calibration Run ###
        angle = 0
        start = [roboCoords[0][0], roboCoords[0][1]]
        sleep(1)
        sphero.driving.drive_with_heading(0, 0, Direction.forward)
        sleep(.75)
        sphero.driving.drive_with_heading(100, 0, Direction.forward)
        sleep(1)
        sphero.driving.drive_with_heading(0, 0, Direction.forward)
        sleep(1.25)
        oldCoords = roboCoords
        print("Gathering Sphero Points...")
        getSpheroLocation(25)
        print("")
        print("DONE!")
        print("roboCoords:", roboCoords)
        target = [roboCoords[0][0], roboCoords[0][1]]
        print("Calculating Angle...", end=" ")
        offset_angle = findangle(start, target)

        print("offset_angle:", offset_angle, "degrees")

        ### First Pin ###
        start = [roboCoords[0][0], roboCoords[0][1]]
        target = [pinCoords[0][0], pinCoords[0][1]]
        print("Calculating Angle...", end=" ")
        angle = findangle(start, target)
        angle = angle - offset_angle
        if angle < 0:
            print("its neg")
            angle = angle + 360
        sleep(1)
        print("angle:", angle, "degrees")

        print("sending command to robot...")
        sleep(.25)
        sphero.driving.drive_with_heading(0, angle, Direction.forward)
        sleep(.75)
        sphero.driving.drive_with_heading(100, angle, Direction.forward)
        sleep(2.5)
        sphero.driving.drive_with_heading(0, angle, Direction.forward)
        sleep(.25)

        ### Back up
        angle = 180
        angle = angle - offset_angle
        if angle < 0:
            print("its neg")
            angle = angle + 360
        print("sending command to robot...")
        sleep(.25)
        sphero.driving.drive_with_heading(0, angle, Direction.forward)
        sleep(.75)
        sphero.driving.drive_with_heading(100, angle, Direction.forward)
        sleep(1)
        sphero.driving.drive_with_heading(0, angle, Direction.forward)
        sleep(.75)

        ### Second Pin ###
        print("Gathering Sphero Points...")
        getSpheroLocation(25)
        print("")
        print("DONE!")
        print("roboCoords:", roboCoords)
        print("Calculating Angle...", end=" ")
        start = [roboCoords[0][0], roboCoords[0][1]]
        target = [pinCoords[1][0], pinCoords[1][1]]
        angle = findangle(start, target)
        angle = angle - offset_angle
        if angle < 0:
            print("its neg")
            angle = angle + 360
        print("angle:", angle, "degrees")

        print("sending command to robot...")
        sleep(.25)
        sphero.driving.drive_with_heading(0, angle, Direction.forward)
        sleep(.75)
        sphero.driving.drive_with_heading(100, angle, Direction.forward)
        sleep(1.25)
        sphero.driving.drive_with_heading(0, angle, Direction.forward)
        sleep(.25)

        ### Back up
        angle = 180
        angle = angle - offset_angle
        if angle < 0:
            print("its neg")
            angle = angle + 360
        print("sending command to robot...")
        sleep(.25)
        sphero.driving.drive_with_heading(0, angle, Direction.forward)
        sleep(.75)
        sphero.driving.drive_with_heading(100, angle, Direction.forward)
        sleep(1)
        sphero.driving.drive_with_heading(0, angle, Direction.forward)
        sleep(.75)

        ### Third Pin ###
        print("Gathering Sphero Points...")
        getSpheroLocation(25)
        print("")
        print("DONE!")
        print("roboCoords:", roboCoords)
        print("Calculating Angle...", end=" ")
        start = [roboCoords[0][0], roboCoords[0][1]]
        target = [pinCoords[2][0], pinCoords[2][1]]
        angle = findangle(start, target)
        angle = angle - offset_angle
        if angle < 0:
            print("its neg")
            angle = angle + 360
        print("angle:", angle, "degrees")

        print("sending command to robot...")
        sleep(.25)
        sphero.driving.drive_with_heading(0, angle, Direction.forward)
        sleep(.75)
        sphero.driving.drive_with_heading(100, angle, Direction.forward)
        sleep(1.5)
        sphero.driving.drive_with_heading(0, angle, Direction.forward)

        sphero.power.enter_soft_sleep()
Ejemplo n.º 28
0
def sphero_sleep():
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.enter_soft_sleep()
Ejemplo n.º 29
0
def sphero_wake():
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()
Ejemplo n.º 30
0
def main():
    mac_address = "d6:bc:6a:05:79:b6"
    with Sphero(mac_address=mac_address) as sphero:
        sphero.power.wake()
        sleep(2)
        sphero.power.enter_soft_sleep()