【记录】新Ubuntu20配置voxelmap的环境安装
因为系统总出问题,仅用于个人纪录。
1. 升级CMake到3.28及以上版本(Sophus依赖)
wget https://github.com/Kitware/CMake/releases/download/v3.28.3/cmake-3.28.3-linux-x86_64.sh
chmod +x cmake-3.28.3-linux-x86_64.sh
sudo ./cmake-3.28.3-linux-x86_64.sh --skip-license --prefix=/usr/local
2. Install Eigen3.4.0
Required by Sophus, and Ceres.
wget https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz
tar -xzf eigen-3.4.0.tar.gz
cd eigen-3.4.0
然后编译安装。
3. Install Ceres
版本采用Version: -solver-2.2.0.tar.gz
#CMake (already installed)
sudo apt-get install cmake
# google-glog + gflags
sudo apt-get install libgoogle-glog-dev libgflags-dev
# Use ATLAS for BLAS & LAPACK
sudo apt-get install libatlas-base-dev
# Eigen3 (already installed)
sudo apt-get install libeigen3-dev
# SuiteSparse (optional)
sudo apt-get install libsuitesparse-devwget ceres-solver.org/ceres-solver-2.2.0.tar.gz
tar zxf ceres-solver-2.2.0.tar.gz
mkdir ceres-bin
cd ceres-bin
cmake ../ceres-solver-2.2.0
make -j12
make test
make install
4. Install Sophus
git clone https://github.com/strasdat/Sophus.git
cd Sophus
mkdir build && cd build
cmake ..
make
sudo make install
5. 安装其他代码
Livox-SDK(安装到任意路径即可)
livox_ros_driver2 (安装到workspace下方)
./build.sh ROS1
6. Install libtorch
libtorch需要确定python、cuda、cudann的版本。
测试代码:
import torch
print(f"PyTorch version: {torch.__version__}") # 输出 PyTorch 版本(如 2.1.0)
print(f"Cuda available: {torch.cuda.is_available()}") # 应返回 True
print(f"Cuda version: {torch.version.cuda}") # 应返回 12.1(兼容 12.2)
print(f"Cudann version: {torch.backends.cudnn.version()}") # 输出 cuDNN 版本
输入如下:
PyTorch version: 2.5.1
Cuda available: True
Cuda version: 12.4
Cudann version: 90101
选择:libtorch version: 12.1
libtorch是二进制文件,下载后不需要编译,只需要在cmakelist中加进去。
wget https://download.pytorch.org/libtorch/cu121/libtorch-cxx11-abi-shared-with-deps-2.1.0%2Bcu121.zip
unzip libtorch-cxx11-abi-shared-with-deps-2.1.0+cu121.zip
export LIBTORCH_HOME=/PATH/TO/libtorch # 但是这个好像没有用
遇到的bug
将电脑主机名设定为了1660,但在启动roscore时遇到问题,没有正常启动,一段时间后报失链接。
查看日志,发现roscore并没有像往常一样链接localhost:11311,而是找的1660。
deepseek给出:如果主机名设定为了1660这种纯数字,roscore在连接时会当作ip而不是本地。
ROS 的依赖问题
ROS 的核心组件(如 roscore)依赖主机名进行网络通信,而:
许多网络工具(如 ping、hostname -I)会将纯数字名称误认为是端口号或IP片段,导致解析失败。
ROS 的默认环境变量(如 ROS_MASTER_URI)可能生成错误的URL(例如 http://1660:11311,被误解析为端口1660)。
日志中的直接证据
您之前看到的错误提示 ping 1660 就是因为ROS误将主机名当作IP或端口,导致无法连接自身。
查看:Check: vim /etc/hosts,显示的配置如下。
127.0.0.1 localhost
127.0.1.1 1660
修改 1660 为其他名字,例如 GTX1660,然后就可以了。