<jupyter_start><jupyter_text>IMU sensor  Library **inertial_measurement_unit** This library does not accept I2C port<jupyter_code>from di_sensors.inertial_measurement_unit import InertialMeasurementUnit
imu = InertialMeasurementUnit(bus = "GPG3_AD1")  # or GPG3_AD2 (whatever it is connected)
imu.read_euler()
imu.read_magnetometer()
imu.read_gyroscope()
imu.read_accelerometer()
imu.read_linear_acceleration()
imu.read_gravity()
imu.read_quaternion()
imu.read_temperature()<jupyter_output><empty_output><jupyter_text>Library **easy_inertial_measurement_unit**<jupyter_code>from di_sensors.easy_inertial_measurement_unit import EasyIMUSensor<jupyter_output><empty_output><jupyter_text>Run only one of the two lines below<jupyter_code>imu = EasyIMUSensor(port = "AD1") # or AD2 (whatever it is connected)
imu = EasyIMUSensor(port = "I2C") # If connected to a I2C port<jupyter_output><empty_output><jupyter_text>And check it works<jupyter_code>imu.read_temperature()<jupyter_output><empty_output><jupyter_text>You can check all other methods (they are the same as above)<jupyter_code>imu.read_euler()
imu.read_magnetometer()
imu.read_gyroscope()
imu.read_accelerometer()
imu.read_linear_acceleration()
imu.read_gravity()
imu.read_quaternion()<jupyter_output><empty_output><jupyter_text>Easy methods (specifically added by this class)<jupyter_code>imu.safe_calibration_status() # 0-3 (-1 means it cannot access the sensor)
imu.safe_calibrate() # The IMU calibrates automatically,
# the purpose is to block a given script untl the sensor reports it has fully calibrated
# IT REQUIRES TO RESTART THE KERNEL (does not finish)
imu.reconfig_bus() # If becomes unresponsive but it's still plugged into the board<jupyter_output><empty_output><jupyter_text>`convert_heading(...)` **takes in a heading in degrees and return the name of the corresponding heading**<jupyter_code>import time
while True:
    time.sleep(1)
    print ("{:.1f} {:s}".format(imu.safe_north_point() , imu.convert_heading(imu.read_euler()[0])))<jupyter_output><empty_output><jupyter_text>`safe_read_magnetometer()` **reads the magnetometer values X, Y, Z in *micro-Teslas* **<jupyter_code>imu.read_magnetometer()
imu.safe_read_magnetometer()<jupyter_output><empty_output><jupyter_text>`safe_read_euler()` reads the absolute orientation of euler angles in degrees of *heading*, *roll* and *pitch*.<jupyter_code>imu.read_euler()
imu.safe_read_euler()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1069672131147541, 'fraction_numerical': 0.006147540983606557, 'mean_word_length': 8.963265306122448, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '365274', 'license': 'MIT', 'n_tokens_mistral': 912, 'n_tokens_neox': 873, 'n_words': 183, 'path': 'Chapter2_Unit_Tests/DI-IMU/IMU_libraries.ipynb', 'repo_name': 'manelpuig/Hands-On-ROS-for-Robotics-Programming', 'size': '2440'}