ROS

Gazebo turtlebot SLAM 코드 분석

ingus kinematics 2022. 10. 4. 17:40
$ roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping

이 코드를 실행하면 turtlebot3로 SLAM을 수행할 수 있습니다.

 

  <!-- Arguments -->

  • arg 태그를 사용하여 model 태그에 현재 turtlebot3 모델이 burger인지 waffle인지 waffle_pi인지를 확인합니다.
  • 그리고 여러 SLAM 방법들 중 어떤 방법을 사용할지 slam_methods를 통해 정의해줍니다.
  • SLAM launch 파일에 들어갈 configuration_basename의 이름을 turtlebot3_lds_2d.lua로 정해줍니다.
  • rviz를 사용할 때 필요한 open_rviz 변수를 지정해줍니다.

 

 

  <!-- TurtleBot3 -->

  <include file="$(find turtlebot3_bringup)/launch/turtlebot3_remote.launch">
    <arg name="model" value="$(arg model)" />
  </include>

터틀봇3의 기능을 활성화하기 위해서 실행시켜줍니다.

 

turtlebot3_remote.launch 파일을 확인해보면 다음과 같습니다.

  • turtlebot3_burger.urdf.xacro 파일을 불러오고
  • robot_state_publisher 패키지의 robot_state_publisher.cpp 파일을 이용하여 노드를 실행시켜줍니다.
  • publish_frequency는 50.0 이고 tf_prefix는 arg로 정의해준 값이 들어갑니다.

 

  <!-- SLAM: Gmapping, Cartographer, Hector, Karto, Frontier_exploration, RTAB-Map -->

  <include file="$(find turtlebot3_slam)/launch/turtlebot3_$(arg slam_methods).launch">
    <arg name="model" value="$(arg model)"/>
    <arg name="configuration_basename" value="$(arg configuration_basename)"/>
  </include>

 

turtlebot3_slam 안에 있는 launch 파일 안에 있는 turtlebot3_gmapping.launch 파일을 실행

turtlebot3_gmapping.launch

이 launch 파일은 gmapping 패키지를 포함합니다.

세 가지 파라메터를 설정해줍니다.

 

1. base_frame

2. odom_frame

3. map_frame

 

이 파라미터는 구독자와 발행자에서 쓰일 파라미터이기 때문에 반드시 작성해주어야 합니다.

추가적으로 config/gmapping_pramas.yaml 파일을 불러와서 gmapping에 관한 파라미터들을 넣어줍니다.

gmapping_params.yaml

 

 

  <!-- rviz -->

visualization 목적으로 쓰입니다.