직관적인느낌

Mapviz - GPS 본문

공학/시스템 설치 및 설정

Mapviz - GPS

범슐랭 2023. 3. 20. 12:49
728x90

해당 프로그램은, Jetson에서는 작동하지 않는다. 일반 PC의 Ubuntu (18.04)에서 동작


1. Ubuntu 18.04에 Docker 설치

2. Docker mapproxy 설정

3. ROS Melodic에 Mapviz 설치

4. Mapviz 사용법

5. Mapviz에서 구글 위성 지도 사용

 

1. Ubuntu 18.04에 Docker 설치

sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL <https://download.docker.com/linux/ubuntu/gpg> | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] <https://download.docker.com/linux/ubuntu> bionic stable"
sudo apt update
apt-cache policy docker-ce

sudo apt install docker-ce
sudo systemctl status

 

2. Docker mapproxy 설정

mkdir ~/mapproxy
sudo docker run -p 8080:8080 -d -t -v ~/mapproxy:/mapproxy danielsnider/mapproxy

 

3. ROS Melodic에 Mapviz 설치

  • Install by apt
sudo apt-get install ros-$ROS_DISTRO-mapviz ros-$ROS_DISTRO-mapviz-plugins ros-$ROS_DISTRO-tile-map ros-$ROS_DISTRO-multires-image
  • Install by git clone
cd catkin_ws/
cd src/
git clone <https://github.com/swri-robotics/mapviz>
  • make
cd ..
catkin_make

 

4. Mapviz 사용법

  • Set Launch file

💡 mapviz/mapviz/launch/mapviz.launch

Mapviz에 GPS 값을 수신해주기 위해 Launch 파일을 수정해줘야 한다.

mapviz/mapviz/launch/mapviz.launch

initialize_origin.py는 GPS 좌표를 받아 WGS84 좌표계를 ROS TF트리에 연결하므로
<param name="local_xy_origin" value="auto"/>로 변환해주면 첫 수신한 GPS 값을 원점으로 사용한다.

<remap from="fix" to="your/gps/topic"/>을 추가하면
내가 사용하는 GPS 보드가 수신한 GPS값을 토대로 Mapviz를 사용할 수 있다.


- 수정 전

<launch>

  <node pkg="mapviz" type="mapviz" name="mapviz"></node>

  <node pkg="swri_transform_util" type="initialize_origin.py" name="initialize_origin" >
    <param name="local_xy_frame" value="/map"/>
    <param name="local_xy_origin" value="swri"/>
    <rosparam param="local_xy_origins">
      [{ name: swri,
         latitude: 29.45196669,
         longitude: -98.61370577,
         altitude: 233.719,
         heading: 0.0},
         
       { name: back_40,
         latitude: 29.447507,
         longitude: -98.629367,
         altitude: 200.0,
         heading: 0.0}]
    </rosparam>
  </node>

  <node pkg="tf" type="static_transform_publisher" name="swri_transform" args="0 0 0 0 0 0 /map /origin 100"  />

</launch>

- 수정 후

<launch>
  <node pkg="mapviz" type="mapviz" name="mapviz"></node>
  <node pkg="swri_transform_util" type="initialize_origin.py" name="initialize_origin" >
<param name="local_xy_frame" value="/map"/>
<param name="local_xy_origin" value="auto"/>
<rosparam param="local_xy_origins">
[{ name: swri,
latitude: 29.45196669,
longitude: -98.61370577,
altitude: 233.719,
heading: 0.0},
{ name: back_40,
latitude: 29.447507,
longitude: -98.629367,
altitude: 200.0,
heading: 0.0}]
    </rosparam>
	<remap from="fix" to="/ublox_gps/fix"/>
  </node>
  <node pkg="tf" type="static_transform_publisher" name="swri_transform" args="0 0 0 0 0 0 /map /origin 100"  />
</launch>

필자는 ublox_gps/fix를 사용하여 RTK msg를 전달하기 때문에 ublox_gps/fix를 넣어주었다.


 

 

  • 실행
roslaunch mapviz mapviz.launch

 


💡 ※당연히 사용하는 GPS 보드도 실행해 줘야한다.※


 

  • Mapviz 설정
    • Config (왼쪽 상단)
      • fixed Frame : map 으로 설정하고
      • **Target Frame : <none>**으로 설정한 후
      • use latest transforms를 체크한다.
    • tile_map (왼쪽 하단에 Add를 눌러서)
      • **Source : Stamen(terrian)**으로 설정
    • navsat (왼쪽 하단에 Add를 눌러서)
      • Topic : remap에서 설정한 토픽 (Select)
      • Color : 개인 취향
      • Draw style : point
      맵이 보이지 않을 시 오른쪽 하단에 초록색 화살표를 누르면 된다. 그럼 본인의 위치에 점이 찍힌 것을 볼 수 있다.

 

💡

※Mapviz는 하나씩 쌓아 올려가므로 Add의 순서가 중요하다.

Add의 순서가 맞지 않으면 지도가 나타나지 않을 수 있다※


5. Mapviz에서 구글 위성 지도 사용

  • Mapviz 설정
    • tile_map (왼쪽 하단에 Add를 눌러서)
      • Source : Custom Source 로 설정
      • Base URL
      <http://localhost:8080/wmts/gm_layer/gm_grid/{level}/{x}/{y}.png>
      
      • Max Zoom : 19 [설정 후, Save]

 

https://youtu.be/rtCnrmN_y2k

728x90
반응형