한이음/GPS 좌표 트래킹을 통한 자율주행 로봇

IMU (Myahrs+) 사용하기

MZ 아이종 2022. 2. 3. 03:47

모터를 동작시키면 직선으로 주행을 하도록 명령을 내려도 실제로는 직선으로 주행하지 않을 수도 있다.

이를 IMU 센서를 이용해서 보정함으로서 정확한 주행을 할 수 있도록 한다.  

그래서 IMU 센서를 이용하는 방법을 알아보겠다.

 

사용버전. 노트북

˙ Samsung Ultrabook i7

˙ Ubuntu 18.04.6 LTS

˙ Ros Melodic

˙ Myahrs+

 

단계

1. 패키지 확인

2. 설치

3. Rviz를 통해 확인

4. raw data 받기

 

 

1. 패키지 확인

아래의 주소로 이동하여 melodic-devel baranch를 선택해 준다. 

https://github.com/robotpilot/myahrs_driver

 

GitHub - robotpilot/myahrs_driver: myahrs_driver is a package that provides a ROS driver for the WITHROBOT myAHRS+.

myahrs_driver is a package that provides a ROS driver for the WITHROBOT myAHRS+. - GitHub - robotpilot/myahrs_driver: myahrs_driver is a package that provides a ROS driver for the WITHROBOT myAHRS+.

github.com

 

 

 

2. 설치

아래의 명령어를 순서대로 입력하면 설치가 진행된다.

$ cd ~/catkin_ws/src #또는 cs
$ git clone https://github.com/robotpilot/myahrs_driver.git #melodic-devel의 주소이다.
$ cd .. 
$ catkin_make #또는 cm

 

 

3. Rviz를 통해 확인

PC와 IMU를 연결하고 권한을 부여하고 실행한다.

$ sudo chmod 777 /dev/ttyACM0
$ roslaunch myahrs_driver myahrs_driver.launch

 

명령어를 실행하면 아래와 같이 Rviz를 통해 출력된다.

 

왼쪽 Displays에서 Imu를 체크하면 아래와 같이 화살표가 보여지고, imu를 움직이는대로 움직인다.

 

 

4. raw data 받기

roslaunch를 실행하는 중에 rostopic을 확인하여 raw data를 받아온다.

$ rostopic list #현재 구동중인 ros topic, msg 확인가능
$ rostopic echo /imu/data_raw #raw data 값 받아올 수 있음

 

아래처럼 현재 실행중인 rostopic과 msg들을 확인할 수 있다.

이중 /imu/data_raw가 imu의 순수한 값을 가지고 있다.

 

명령어를 작성하면 아래와 같이 raw data를 얻을 수 있다.