def main(): whill = ComWHILL(port='COM4') while True: time.sleep(3) whill.send_power_off() time.sleep(3) whill.send_power_on()
def main(): whill = ComWHILL(port='COM6') count = 0 side = -50 whill.hold_joy(front=int(0), side=side, timeout=30000) while True: count += 1 print(count) if count >= 10: count = 0 side *= -1 print('Reverse turning direction') whill.hold_joy(front=int(0), side=side, timeout=30000) time.sleep(1)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # コース1のスクリプト import time from whill import ComWHILL from command_forward import CommandForward from command_turn_left import CommandTurnLeft from command_turn_right import CommandTurnRight from command_stop import CommandStop from command_http import CommandHttp from measure import Measure whill = ComWHILL(port='/dev/tty.usbserial-FT2K21HW') request_speed_mode = 0 measure = Measure() commands = [ CommandForward(whill, measure, 1.2), CommandTurnRight(whill, measure, 45.0), CommandHttp("http://192.168.21.214:3000/change1"), CommandStop(whill, measure, 5000), CommandTurnLeft(whill, measure, 90.0), CommandForward(whill, measure, 1.0), CommandTurnRight(whill, measure, 45.0), CommandHttp("http://192.168.21.214:3000/change2"), CommandStop(whill, measure, 5000), CommandTurnLeft(whill, measure, 135.0), CommandForward(whill, measure, 1.0), CommandTurnRight(whill, measure, 45.0),
def main(): whill = ComWHILL(port='/dev/ttyUSB0') whill.register_callback('power_on', power_on_callback) while True: whill.sleep(3) whill.send_power_off() whill.sleep(3) whill.send_power_on()
#!/usr/bin/env python3 # whill module example package # Copyright (c) 2018 WHILL, Inc. # This software is released under the MIT License. import time from whill import ComWHILL whill = ComWHILL(port='COM4') request_speed_mode = 0 whill.start_data_stream(1000, 0, request_speed_mode) while True: time.sleep(1) is_refreshed = whill.refresh() if whill.latest_received_data_set == 0: print(whill.speed_profile[request_speed_mode]) whill.start_data_stream(1000, 1, request_speed_mode) else: level, current = whill.battery.values() print(whill.joy) print( 'Battery Status: remaining capacity {level}%, current draiwng {current}mA' .format(level=level, current=current)) print('Motor Status') request_speed_mode = (request_speed_mode + 1) % 6 whill.start_data_stream(1000, 0, request_speed_mode)
#!/usr/bin/env python3 # whill module example package # Copyright (c) 2018 WHILL, Inc. # This software is released under the MIT License. import time from whill import ComWHILL whill = ComWHILL(port='COM6') request_speed_mode = 0 while True: for request_speed_mode in range(6): whill.start_data_stream(750, 0, request_speed_mode) time.sleep(1) is_refreshed = whill.refresh() print('{request_speed_mode}: {profile}'.format(request_speed_mode=request_speed_mode+1, profile=whill.speed_profile[request_speed_mode])) print('All 6 speed profiles have been read. Enter [1-4] which you want to apply to 5 (CR).') print('Enter "0" to exit') key_input = -1 acceptable_index = [1, 2, 3, 4] while key_input not in acceptable_index: key_input = int(input('>>> ')) if key_input == 0: exit() whill.set_speed_profile_via_dict(4, whill.speed_profile[key_input - 1])
#!/usr/bin/env python3 # whill module example package # Copyright (c) 2018 WHILL, Inc. # This software is released under the MIT License. import time from whill import ComWHILL whill = ComWHILL(port='COM4') while True: whill.send_joystick(int(10), int(0)) time.sleep(1)
#!/usr/bin/env python3 # whill module example package # Copyright (c) 2018 WHILL, Inc. # This software is released under the MIT License. import time from whill import ComWHILL whill = ComWHILL(port='/dev/tty.usbserial-FT1HNPEN') while True: whill.send_joystick(int(10), int(0)) time.sleep(0.05)
#!/usr/bin/env python3 # whill module example package # Copyright (c) 2018 WHILL, Inc. # This software is released under the MIT License. import time from datetime import datetime from whill import ComWHILL whill = ComWHILL(port='COM5') request_speed_mode = 0 interval_msec = 50 whill.start_data_stream(interval_msec, 0, request_speed_mode) filename = datetime.now().strftime('%Y-%m-%d-%H-%M-%S') pathname = f'data/{filename}.csv' f = open(pathname, 'w') f.close() while True: print() time.sleep(interval_msec / 1000) is_refreshed = whill.refresh() if whill.latest_received_data_set == 0: # print('speed_profile:', whill.speed_profile[request_speed_mode]) whill.start_data_stream(interval_msec, 1, request_speed_mode) else: level, current = whill.battery.values() # print('accelerometer:', whill.accelerometer) # print('gyro:', whill.gyro)
#!/usr/bin/env python3 # whill module example package # Copyright (c) 2018 WHILL, Inc. # This software is released under the MIT License. import time from whill import ComWHILL request_speed_mode = 0 whill = ComWHILL(port='COM4') def callback0(): global request_speed_mode, whill print('callback 0') print(whill.speed_profile[request_speed_mode]) whill.start_data_stream(1000, 1, request_speed_mode) def callback1(): global request_speed_mode, whill print('callback 1') level, current = whill.battery.values() print(whill.accelerometer) print(whill.gyro) print(whill.joy) print( 'Battery Status: remaining capacity {level}%, current draiwng {current}mA' .format(level=level, current=current)) print('Motor Status')
#!/usr/bin/env python3 # whill module example package # Copyright (c) 2018 WHILL, Inc. # This software is released under the MIT License. import time from whill import ComWHILL whill = ComWHILL(port='COM5') interval_msec = 1000 interval_sec = interval_msec / 1000 joys = [] with open('data/2019-08-15-04-31-45.csv', 'r') as f: line = f.readline() while line: joy = line.strip().split(',') joys.insert(0, joy) line = f.readline() for joy in joys: print(joy) front = -1 * int(joy[0]) side = -1 * int(joy[1]) whill.hold_joy(front, side, interval_msec) time.sleep(interval_sec)
#!/usr/bin/env python3 # whill module example package # Copyright (c) 2018 WHILL, Inc. # This software is released under the MIT License. import time from whill import ComWHILL whill = ComWHILL(port='COM5') interval_msec = 1000 interval_sec = interval_msec / 1000 with open('data/2019-08-15-05-41-37.csv', 'r') as f: line = f.readline() while line: joy = list(map(int, line.strip().split(','))) print(joy) whill.hold_joy(int(joy[0]), int(joy[1]), interval_msec) time.sleep(interval_sec) line = f.readline()
#!/usr/bin/env python3 # whill module example package # Copyright (c) 2018 WHILL, Inc. # This software is released under the MIT License. import time from whill import ComWHILL whill = ComWHILL(port='COM5') whill.hold_joy(int(10), int(0)) # whill.unhold_joy() # result = whill.send_power_on() # result = whill.receive_data() # print(result) # while True: # whill.send_joystick(int(100), int(0)) # time.sleep(1) # whill.send_joystick(int(100), int(0))