def __init__(self): print("Starting motors...") self.m = thrusters.start(N_motors, port) self.stopAll() print("Starting thread...") thread = threading.Thread(target=self.motor_feedback_thread, args=(self.m,)) thread.daemon = True thread.start() return
# Copyright (C) 2017 SeaDroneTM (www.seadronepro.com) # This program is free software; you can redistribute it # and/or modify it under the terms of the GNU General Public # License v3 as published by the Free Software Foundation. ############################################################### import seadrone.smart_thruster as thrusters import threading import time import math N_motors = 15 port = '/dev/ttyUSB0' print("Starting motors...") m = thrusters.start(N_motors, port) def motor_feedback_thread(m): while m.running: print("\n\n\n\n") # empty lines for space for id in m.motors: # show feedback for each motor motor_feedback = 'Motor {:2d}: '.format(id) motor_feedback += "ON " if m.is_on[id] else "OFF " motor_feedback += '{:5d}rpm '.format(m.rpm[id]) motor_feedback += '{:5.2f}A '.format(m.current[id]) motor_feedback += '{:5.2f}V '.format(m.voltage[id]) motor_feedback += '{:5.2f}C '.format(m.driver_temperature[id]) motor_feedback += 'Alarm: ' + m.get_alarm_description(id) print(motor_feedback) if m.has_alarm[id]: