# Dobot hex mapping

本仓库为基于 Dobot Hexplorer 的建图示例程序

<div align="center">
<table>
  <tr>
    <td align="center">
      <img src="assets/pcl_result.png" alt="result" height="360" ><br>
      <b>结果</b>
    </td>
    <td align="center">
      <img src="assets/pathing.gif" alt="pathing" height="360"><br>
      <b>建图</b>
    </td>
  </tr>
</table>
</div>

## 环境依赖

1. Ubuntu 22.04
2. ROS2 Humble

## 编译依赖

### 基础依赖

```bash
sudo apt-get install -y \
  protobuf-compiler libprotobuf-dev \
  libgoogle-glog-dev \
  libpcl-dev \
  libeigen3-dev \
  libyaml-cpp-dev \
  libboost-all-dev \
  build-essential cmake pkg-config
```

### 第三方包依赖

**LIVOX-SDK2**

```bash
git clone https://github.com/Livox-SDK/Livox-SDK2.git
cd ./Livox-SDK2/
mkdir build
cd build
cmake .. && make -j
sudo make install
```

**livox_ros_driver2**

```bash
mkdir -p ws_livox/src
git clone https://github.com/Livox-SDK/livox_ros_driver2.git ws_livox/src/livox_ros_driver2
cd ws_livox/src/livox_ros_driver2
source /opt/ros/humble/setup.sh
./build.sh humble
```

**GTSAM**:

```bash
git clone https://github.com/borglab/gtsam
mkdir build && cd build
cmake ..
make -j  # optional, runs all unit tests
sudo make install
```

## 编译

编译前运行

```bash
source /opt/ros/humble/setup.bash
source ws_livox/install/setup.bash
```

编译

```bash
cd dobot_hex_mapping
mkdir build && cd build
cmake ..
make -j
echo "/usr/local/lib" | sudo tee /etc/ld.so.conf.d/usr-local-lib.conf >/dev/null
sudo ldconfig
```

## 数据采集

启动机器人后，运行数据采集脚本

```bash
cd ~/Documents
./record.sh
```

回到原点后

## 建图

运行建图

```bash
./fastlio2/lio_mapping <bag_path> <config_file_path>
```

例如

```bash
./fastlio2/lio_mapping ../record/ /home/ayxuan/ws/dobot_hex_mapping/fastlio2/config/lio_YJ.yaml
```
