Example #1
0
 def json2Packets1(self, json_str):
     print(json_str)
     commands = json.loads(json_str)
     converse = {
         WWMedia.WWSound.WWSoundDot.HOWDY: "hi",
         WWMedia.WWSound.WWSoundDot.HOLD_ME: "ayayay",
         WWMedia.WWSound.WWSoundDot.READYSET: "brrp",
         WWMedia.WWSound.WWSoundDash.HOWSGOING: "elephant",
         WWMedia.WWSound.WWSoundDash.LETS_GO: "confused2"
     }
     packets = two_packet_wrappers()
     print("two")
     if '300' in commands:
         robot = MorseRobot()
         packets.packet2_bytes_num = 0
         packets.packet1_bytes_num = 20
         myfile = converse[commands['300']['file']]
         byte_array = robot.say(myfile)
         packets.packet1_bytes = byte_array
         print("say", myfile, byte_array)
     if '205' in commands:
         robot = MorseRobot()
         packets.packet2_bytes_num = 0
         packets.packet1_bytes_num = 20
         degree = commands['205']['degree']
         byte_array = robot.turn(degree)
         packets.packet1_bytes = byte_array
         print("turn", degree, byte_array)
     return packets
Example #2
0
def run(bot_address):
    with MorseRobot(bot_address) as robot:
        robot.connect()
        robot.reset()
        # robot.debug()
        # It would be nice to get bump sensing to work for additional obsticle avoidance.
        robot.whenever("prox_left", above=OBSTACLE_DISTANCE,
                       max_firing_freq=5).do(avoid_left)
        robot.whenever("prox_right",
                       above=OBSTACLE_DISTANCE,
                       max_firing_freq=5).do(avoid_right)
        robot.whenever("picked_up", value=True, max_firing_freq=1).do(stop)
        robot.whenever("nominal", value=True, max_firing_freq=1).do(start)
        robot.whenever("dot_left_of_dash", value=True,
                       max_firing_freq=.5).do(left_indicator_on)
        robot.whenever("dot_left_of_dash", value=False,
                       max_firing_freq=.5).do(left_indicator_off)
        robot.whenever("dot_right_of_dash", value=True,
                       max_firing_freq=.5).do(right_indicator_on)
        robot.whenever("dot_right_of_dash", value=False,
                       max_firing_freq=.5).do(right_indicator_off)
        try:
            robot.drive(NOMINAL_SPEED)
            while True:
                robot.sleep(0.5)
        except KeyboardInterrupt:
            robot.stop()
            pass
Example #3
0
def run(bot_address):
    print("Connecting to {0}.".format(bot_address))
    bot = MorseRobot(bot_address)
    bot.reset()
    bot.connect()
    print("Connected")
    # bot.sense.unsubscribe()
    while True:
        draw_now(bot)
Example #4
0
def run(bot_address):
    with MorseRobot(bot_address) as robot:
        robot.connect()
        robot.reset()
        try:
            while True:
                robot.sleep(.5)
                os.system('clear')
                os.system('setterm -cursor off')
                for key, value in robot.sensor_state.iteritems():
                    print("{:<20}:{:6}".format(key, value))
                os.system('setterm -cursor on')
        except KeyboardInterrupt:
            robot.stop()
            pass
Example #5
0
 def setUp(self):
     self.bot = MorseRobot()
     self.bot.command = MagicMock()