๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

์นดํ…Œ๊ณ ๋ฆฌ ์—†์Œ

[Spot Dynamixel - 4] IMU - BNO055

 

๐ŸŒŽ

IMU - BNO055

1. ์„ผ์„œ ์†Œ๊ฐœ

BNO055

IMU ์„ผ์„œ ์ค‘ ํ•˜๋‚˜๋กœ ๊ฐ๊ฐ€์†๋„ 3์ถ•, ๊ฐ์†๋„ 3์ถ•, ์ง€์ž๊ธฐ 3์ถ•์„ ์ธก์ •ํ•ด์ฃผ๋Š” ์„ผ์„œ

์ด 9๊ฐ€์ง€ ์„ผ์„œ๊ฐ’์„ ํ™œ์šฉํ•˜์—ฌ ํ˜„์žฌ ์„ผ์„œ๊ฐ€ ๊ธฐ์šธ์–ด์ง„ ๊ฐ๋„์™€ ์ด๋™ ์†๋„๋ฅผ ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๊ธฐ๋ณธ์ ์œผ๋กœ ์„ผ์„œ๊ฐ’์— ์˜ค์ฐจ๊ฐ€ ๋งŽ์ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ํ•„ํ„ฐ ๋“ฑ์˜ ๊ธฐ๋ฒ•์„ ํ†ตํ•ด ๋ฐ์ดํ„ฐ์˜ ์ •์ œ๊ฐ€ ํ•„์š”ํ•˜์ง€๋งŒ, ์ด ์„ผ์„œ์˜ ๊ฒฝ์šฐ ๊ธฐ๋ณธ์ ์ธ ํ•„ํ„ฐ๊ฐ€ ๋‚ด์žฅ๋˜์–ด ์žˆ์–ด ์•ˆ์ •์ ์ธ ์ธก์ •๊ฐ’์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

 

  • ๊ตฌ๋งค๋งํฌ
Adafruit 9-DOF Absolute Orientation IMU Fusion Breakout - BNO055 [ada-2472]
Adafruit / Adafruit 9-DOF Absolute Orientation IMU Fusion Breakout - BNO055 [ada-2472] / MCU๋ณด๋“œ/์ „์žํ‚คํŠธ > ์„ผ์„œ๋ชจ๋“ˆ > IMU/AHRS(9์ถ• ์ด์ƒ) / Euler Vector, 100Hz / Quaterion, 100Hz / Angular Velocity Vector (20Hz) / Acceleration Vector (100Hz) / Magnetic Field Strength Vector (100Hz) / Linear Acceleration Vector (100Hz) / Gravity Vector (100Hz) / Temperature (1Hz)
https://www.devicemart.co.kr/goods/view?no=1271885

2. ๋ฐฐ์„  ๋ฐฉ๋ฒ•

์„ผ์„œ์™€ Jetson Nano ๊ฐ„์˜ I2C ํ†ต์‹ ์ด ํ•„์š”ํ•˜๋ฉฐ, ์ด๋ฅผ ์œ„ํ•ด Jetson Nano์˜ I2C1_SDA, I2C1_SCL์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

 

๋ฐฐ์„ ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

 

  • ์„ผ์„œ - Jetson NanoVin - 5VSDA - 3
  • SCL - 5
  • GND - GND

3. ์„ค์น˜ ๋ฐฉ๋ฒ• ๋ฐ ์˜ˆ์ œ

 

  • pip์„ ํ†ตํ•ด ๊ด€๋ จ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.
$ sudo pip3 install adafruit-circuitpython-bno055

 

  • ์‹ค์ œ ํŒŒ์ด์ฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์‹œ์—๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด importํ•˜์—ฌ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
import board
import adafruit_bno055

 

๊ธฐ๋ณธ ์˜ˆ์‹œ

BNO055๋ฅผ ํ†ตํ•ด ์–ป์„ ์ˆ˜ ์žˆ๋Š” ๋ชจ๋“  ์„ผ์„œ๊ฐ’๋“ค์„ ์ถ”์ถœํ•˜๊ณ , ์ด๋ฅผ ์ฝ˜์†”์— ์ถœ๋ ฅํ•ด ๋ด…์‹œ๋‹ค.
import time
import board
import busio
import adafruit_bno055

# Use these lines for I2C
i2c_bus0 = busio.I2C(board.SCL_1, board.SDA_1)
sensor = adafruit_bno055.BNO055_I2C(i2c_bus0)

# User these lines for UART
# uart = busio.UART(board.TX, board.RX)
# sensor = adafruit_bno055.BNO055_UART(uart)

while True:
   
    print("Accelerometer (m/s^2): {}".format(sensor.acceleration))
    print("Magnetometer (microteslas): {}".format(sensor.magnetic))
    print("Gyroscope (rad/sec): {}".format(sensor.gyro))
    print("Euler angle: {}".format(sensor.euler))
    print("Quaternion: {}".format(sensor.quaternion))
    print("Linear acceleration (m/s^2): {}".format(sensor.linear_acceleration))
    print("Gravity (m/s^2): {}".format(sensor.gravity))
    print()

    time.sleep(1)

  • sensor.acceleration : 3์ถ• ๊ฐ€์†๋„ ์ธก์ •๊ฐ’
  • sensor.magnetic : 3์ถ• ์ž๊ธฐ์žฅ ์ธก์ •๊ฐ’
  • sensor.gyro : 3์ถ• ๊ฐ์†๋„ ์ธก์ •๊ฐ’
  • sensor.euler : ์˜ค์ผ๋Ÿฌ ์ฒด๊ณ„ ๊ฐ๋„ ๊ณ„์‚ฐ๊ฐ’
  • sensor.quaternion : 4์›์ˆ˜ ์ฒด๊ณ„ ๊ฐ๋„ ๊ณ„์‚ฐ๊ฐ’

 

acceleration, magnetic, gyro ๋Š” ์„ผ์„œ์˜ ์ธก์ •๊ฐ’์ด๋ฉฐ

euler, quaternion๋Š” ์„ผ์„œ์˜ ์ธก์ •๊ฐ’์„ ํ™œ์šฉํ•˜์—ฌ ์ˆ˜ํ•™์ ์ธ ๊ณ„์‚ฐ์„ ํ†ตํ•ด ์–ป์–ด๋‚ธ ๊ฐ๋„๊ฐ’ ์ž…๋‹ˆ๋‹ค.

๊ฐ๋„ ํ‘œ์‹œ ์ฒด๊ณ„์— ๋”ฐ๋ผ์„œ euler ๋ฐฉ์‹๊ณผ quaternion ๋ฐฉ์‹ ๋‘๊ฐ€์ง€๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

 

Quaternion - Wikipedia
In mathematics, the quaternion number system extends the complex numbers. Quaternions were first described by Irish mathematician William Rowan Hamilton in 1843 and applied to mechanics in three-dimensional space. Hamilton defined a quaternion as the quotient of two directed lines in a three-dimensional space, or, equivalently, as the quotient of two vectors.
https://en.wikipedia.org/wiki/Quaternion
Euler angles - Wikipedia
The Euler angles are three angles introduced by Leonhard Euler to describe the orientation of a rigid body with respect to a fixed coordinate system. They can also represent the orientation of a mobile frame of reference in physics or the orientation of a general basis in 3-dimensional linear algebra.
https://en.wikipedia.org/wiki/Euler_angles

 

๊ฐ๋„ ์ฒด๊ณ„์— ๋Œ€ํ•œ ์ถ”๊ฐ€ ์„ค๋ช…


๐Ÿ’ก
3์ฐจ์› ์ƒ์˜ ๊ฐ๋„๋Š” ๊ฐ ์ถ•๋ณ„๋กœ ๊ตํ™˜ ๋ฒ•์น™์ด ์„ฑ๋ฆฝํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ฆ‰ ํšŒ์ „์‹œํ‚ค๋Š” ์ˆœ์„œ๊ฐ€ ๋ฐ”๋€Œ๋ฉด ๊ฒฐ๊ณผ๊ฐ€ ๋‹ฌ๋ผ์ง‘๋‹ˆ๋‹ค!
(x์ถ• 90๋„ ํšŒ์ „ ํ›„ y์ถ• 90๋„ ํšŒ์ „) ≠ (y์ถ• 90๋„ ํšŒ์ „ ํ›„ x์ถ• 90๋„ ํšŒ์ „)

 

๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— 3์ฐจ์› ์ƒ์—์„œ ๊ฐ๋„๋ฅผ ํ‘œํ˜„ํ•  ๋•Œ๋Š” ์ถ•๋ณ„ ๊ฐ๋„ ์ˆœ์„œ์— ๋Œ€ํ•œ ์•ฝ์†์ด ํ•„์š”ํ•˜๋ฉฐ,

๊ทธ ์ค‘์— ํ•œ๊ฐ€์ง€ ์ฒด๊ณ„๊ฐ€ ์˜ค์ผ๋Ÿฌ ๊ฐ๋„์ธ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

  • x์ถ• ํšŒ์ „์„ roll
  • y์ถ• ํšŒ์ „์„ pitch
  • z์ถ• ํšŒ์ „์„ yaw๋ผ๊ณ  ๋ช…๋ช…ํ•˜๊ณ 

rollpitchyaw ์ˆœ์„œ๋Œ€๋กœ ํšŒ์ „์‹œํ‚ค๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

๋”ฐ๋ผ์„œ ์ด๋ฅผ ํšŒ์ „ ํ–‰๋ ฌ๋กœ ํ‘œํ˜„ํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

 

๐Ÿ’ก
ํ–‰๋ ฌ ๊ณ„์‚ฐ์„ ํ• ๋•Œ xyz ํ–‰๋ ฌ๊ณผ ์ œ์ผ ๊ฐ€๊นŒ์ด ์žˆ๋Š” ํ–‰๋ ฌ์ด ๋จผ์ € ๊ณ„์‚ฐ๋˜๊ธฐ ๋•Œ๋ฌธ์— ์ˆ˜์‹์ƒ์—์„œ๋Š” ๋ฐ˜๋Œ€๋กœ Rz Ry Rx ์ˆœ์„œ๋กœ ๊ณฑํ•ด์ง€๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

 

BNO055 ์„ผ์„œ์˜ ๊ฒฝ์šฐ ์ถœ๋ ฅ๊ฐ’์ด ์˜ค์ผ๋Ÿฌ ๊ฐ๋„ ํ˜•์‹์ด๊ธฐ ๋•Œ๋ฌธ์— ์ธก์ •๊ฐ’์„ ํ™œ์šฉํ•  ๋•Œ ์ด์ ์„ ์œ ์˜ํ•˜๋ฉด์„œ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.