OpenMarine
IMU wit-motion does not show angles - Printable Version

+- OpenMarine (https://forum.openmarine.net)
+-- Forum: OpenMarine (https://forum.openmarine.net/forumdisplay.php?fid=27)
+--- Forum: General discussion (https://forum.openmarine.net/forumdisplay.php?fid=28)
+--- Thread: IMU wit-motion does not show angles (/showthread.php?tid=5171)



IMU wit-motion does not show angles - Sharafatdin - 2024-02-12

Good day.
I have an IMU of Wit-motion.com production. When I checked on Python software of Ubuntu OS, it could not show the angles in roll, pitch and yaw directions. Instead, it wrote 'None'. Who can help me? The code of python has been attached below:

from witmotion import IMU
import time


def callback(msg):
    print(msg)

# In old MAC
# imu = IMU("/dev/tty.wchusbserial110")


# In the new M2 Mac
imu = IMU("/dev/ttyUSB3")

# In Unix, default port ttyUSB0
# imu = IMU

imu.subscribe(callback)

Orientation = []

StartTime = time.time()
for i in range(100):
    angles = imu.get_angle()
    print(angles)
    if angles[0] is not None:
        roll = float(angles[0])
        pitch = float(angles[1])
        yaw = float(angles[2])
        print("roll = {:03.1f}, pitch = {:03.1f}, yaw = {:03.1f}".format(roll, pitch, yaw))
    Orientation.append(angles)
    time.sleep(0.05)
EndTime = time.time()

print("The Acquisition Lasted=", EndTime-StartTime, " s")
imu.close()