gmapping slam으로 지도 만들기

여기 있는 gmapping, slam 튜토리얼을 했다. 튜토리얼은 상당히 쉽게 구성되어 있으나, 내가 실재로 해보면 잘 안된다. 왜 그런지 확인하기 위해 삽질을 했다. 해당 사이트에서 다운로드 받을 수 있는 rosbag 파일에 어떤 토픽이 저장되어 있는지 궁금했다. rqt가 제공하는 rosbag 플러그인으로 어떤 데이터가 있는지 확인했다.

rosbag play로 실행하면 뭐가 잘못 되었는지 다음 메세지를 보았다. debug 레벨을 켜라는 소리인 듯 한데…

[ WARN] [1664664315.511464153]: MessageFilter [target=odom ]: Dropped 100.00% of messages so far. Please turn the [ros.gmapping.message_filter] rosconsole logger to DEBUG for more information.

rosconsole로 message filter 현재 상태를 확인하고 변경할 수 있다.

root:workspace$rosconsole get /slam_gmapping ros.gmapping.message_filter
info
root:workspace$rosconsole set slam_gmapping ros.gmapping.message_filter debug

rosbag에 -a 옵션을 주고 모든 데이터를 저장하면 지도를 만들 수 있다. 아래와 같이 tf와 scan 데이터만 저장한 다음 rosbag play를 실행하면 tf tree가 끊어져 있다. 정확하게는 basefoot_print와 base_link가 끊겨져 있고, scanner_link가 없다.

ros@workspace$rosbag record /tf /laser/scan
[ INFO] [1664767902.638118674]: Subscribing to /laser/scan
[ INFO] [1664767902.642276643]: Subscribing to /tf
[ INFO] [1664767902.645339564]: Recording to '2022-10-03-03-31-42.bag'.
ros@workspace$ros@bag$rosbag play --clock 2022-10-03-03-31-42.bag

하나씩 해 보다가 /tf_static까지 record 해 보았다. 아, 힘들었다^^!

ros@bag$rosbag record -o mydata /tf /tf_static /laser/scan
[ INFO] [1664769638.007469286]: Subscribing to /laser/scan
[ INFO] [1664769638.011680347]: Subscribing to /tf
[ INFO] [1664769638.014193685]: Subscribing to /tf_static
[ INFO] [1664769638.298793651, 1626.350000000]: Recording to 'mydata_2022-10-03-04-00-38.bag'.

record한 결과를 보면 지도가 잘 생성됨을 확인했다. tf_tree를 보면

위 빠진 tf_tree와 다르게 base_footprint와 base_link가, base_link와 scanner_link가 연결되었다. 왜 이렇게 결정되었는지 확인해 보면, urdf에 fixed라고 joint를 정의해서 그렇다. 아래 urdf를 정의한 부분을 확인해 보면 fixed로 joint를 정의했기 때문에 tf_static을 필요로 한다.

 42 
 43         <joint name = "base_footprint_fixed" type = "fixed">
 44                 <origin xyz = "0 0 0.03" rpy = "0 0 0"/>
 45                 <parent link = "base_footprint"/>
 46                 <child link = "base_link"/>
 47         </joint>
 48 

146         <joint name = "left_wheel_joint" type = "continuous">
147                 <origin xyz = "0.1 0.15 0" rpy = "0 0 0"/>
148                 <parent link = "base_link"/>
149                 <child link = "left_wheel"/>
150                 <axis xyz = "0 1 0"/>
151 
152         </joint>
153 
154         <joint name = "left_wheel_joint_back" type = "continuous">
155                 <origin xyz = "-0.1 0.15 0" rpy = "0 0 0"/>
156                 <parent link = "base_link"/>
157                 <child link = "left_wheel_back"/>
158                 <axis xyz = "0 1 0"/>
159 
160         </joint>
161 
162 


205         <joint name = "head_scanner" type = "fixed">
206                 <!-- rpy를 수정하면 카메라 각도가 바뀜-->
207                 <origin xyz = "0.15 0 0" rpy = "0 0 0"/>
208                 <parent link = "base_link"/>
209                 <child link = "scanner_link"/>
210         </joint>
211 

기록한 rosbag 파이을 보면, scan, tf, tf_static 3개가 들어가 있다.

코멘트

댓글 남기기

이 사이트는 Akismet을 사용하여 스팸을 줄입니다. 댓글 데이터가 어떻게 처리되는지 알아보세요.