I need to read the values of 2 inertial sensors permanently and in order to read it while executing my main program whose code apart from defining these threads and executing them must request inputs by keyboard and then make comparisons with the data obtained from the sensors I tried with this definition of the thread but when executing the main remains in infinite loop without being able to pass to the rest of the program
What should I add so that the threads are executed and the program continues with the rest of the code? will the variable az_actual, tilt_actual be global in order to be used in other parts of the code?
class BNO055(object):
def __init__(self, interval=1):
""" Constructor
:type interval: int
:param interval: Check interval, in seconds
"""
self.interval = interval
thread = threading.Thread(target=self.run, args=())
thread.daemon = True # Daemonize thread
thread.start() # Start the execution
def run(self):""" Method that runs forever """
while True:
sys, gyro, accel, mag = bno.get_calibration_status() # Read the calibration status, 0=uncalibrated and 3=fully calibrated.
if sys == 3 :
az_actual, roll, tilt_actual = bno.read_euler()
print('Azimut={0:0.2F} Tilt={2:0.2F}\tSys_cal={3} Gyro_cal={4} Accel_cal={5} Mag_cal={6}\n'.format( az_actual, roll, tilt_actual, sys, gyro, accel, mag))
time.sleep(0.01) # Velocidad ideal de lectura del sensor
else:
print ("El sensor no esta calibrado")
time.sleep(self.interval)
example = BNO055()
time.sleep(3)
print('Checkpoint')
time.sleep(2)
print('Finalizado')