디바이스 에이전트 설치 및 연동
필요 소프트웨어 설치
GStreamer
Video 데이터 송신을 위해 1.22
버전 이상의 GStreamer가 필요합니다.
GStreamer Docs - Installing GStreamer의 가이드에 따라 환경에 맞는 GStreamer를 설치합니다.
Boost::Beast
C++로 작성된 Agent를 사용하는 경우, Boost::Beast 라이브러리가 필요합니다.
$ git clone --recursive https://github.com/boostorg/boost.git
$ cd boost
$ ./bootstrap.sh
이후 예제를 빌드하고 테스트 코드를 실행하기 위해 아래. 패키지들을 추가로 설치해줍니다.
$ sudo apt-get install libssl-dev libboost-all-dev
Video Agent
를 사용하는 경우Python 기반 Agent를 사용하는 경우, Boost::Beast 라이브러리가 필요하지 않습니다. 대신 pip를 통해 websockets
라이브러리를 설치해야 합니다.
$ pip install websockets
가상환경을 사용하는 경우, 다음과 같이 설치합니다.
$ python3 -m venv <venv_name>
$ source <venv_name>/bin/activate
$ pip install websockets
Draco
Draco는 LiDAR 데이터를 압축하는 라이브러리로, LiDAR 데이터 송수신시 draco 압축을 사용하는 경우 설치가 필요합니다.
Draco Repository의 BUILDING.md를 참고하여 Draco를 빌드합니다.
Agent 설치 및 실행
Agent 빌드 파일은 압축 파일에 포함되어 있습니다.
Agent 설정
Agent를 컴파일하기 전 src 폴더 내 각각의 .cpp
파일에 있는 Moth 서버의 Host, Port, Path 정보를 수정해야 합니다.
아래 가이드는 boost_draco.cpp
파일을 기준으로 설명이 이루어지며, video.cpp
파일도 아래 가이드를 참고하여 수정할 수 있습니다.
src/boost_draco.cpp
파일의 6~7번째 라인에 있는 host_
와 port_
를 Moth 서버의 Host, Port로 바꿔줍니다.
PointCloudSender::PointCloudSender() : Node("pointcloud_sender")
{
// Moth Server Host, Port
host_ = "localhost"; // Moth 서버의 Host
port_ = "8286"; // Moth 서버의 Port
text = "lidar/draco";
...
16번째 라인의 "/your/pointcloud2/topic"
부분을 실제 로봇의 LiDAR Topic 이름으로 수정합니다.
subscription_ = this->create_subscription<sensor_msgs::msg::PointCloud2>(
"/your/pointcloud2/topic", 10, std::bind(&PointCloudSender::topic_callback, this, _1));
78번째 라인의 "your_path"
부분은 Moth API에 맞게 수정합니다.
ws_ptr->handshake(host, "/your_path");
Agent 빌드
다음 명령어를 통해 빌드가 가능합니다.
$ cd /path/to/your/workspace/agent
$ mkdir build && cd build
$ cmake ..
$ make
Agent 실행
다음 명령어를 통해 Agent를 실행할 수 있습니다.
$ source /opt/ros/<distro>/setup.bash
$ source agent/install/setup.bash
$ ros2 run agent draco
$ ros2 run agent video