基于ubuntu22.04安装矩阵、优化、图像、李群李代数
gcc
c++编译器
sudo apt-get install gcc
cmake
下载源码编译安装 https://cmake.org/download/
tar -zxvf cmake-3.25.1
cd cmake-3.25.1
./bootstrap
make
sudo make install
cmake --version #查看cmake版本
which cmake #查看cmake路径
Eigen3
矩阵计算
sudo apt-get install libeigen3-dev
sudo ln -s /usr/include/eigen3/Eigen /usr/include/Eigen #修改映射
pinocchio
#依赖
sudo apt install valgrind liburdfdom-dev
sudo apt install python3-numpy libpython3-dev # 安装python3即可
#eigenpy
sudo sh -c "echo 'deb [arch=amd64] http://robotpkg.openrobots.org/packages/debian/pub $(lsb_release -cs) robotpkg' >> /etc/apt/sources.list.d/robotpkg.list"
curl http://robotpkg.openrobots.org/packages/debian/robotpkg.key | sudo apt-key add -
sudo apt-get update
sudo apt install robotpkg-py310-eigenpy # 安装在/opt/openrobots/目录 Py310,改为需要的版本
sudo apt update
sudo apt install -qqy robotpkg-py3*-pinocchio
sudo vim ~/.bashrc
export PATH=/opt/openrobots/bin:$PATH
export PKG_CONFIG_PATH=/opt/openrobots/lib/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=/opt/openrobots/lib:$LD_LIBRARY_PATH
export PYTHONPATH=/opt/openrobots/lib/python3.10/site-packages:$PYTHONPATH # Adapt your desired python version here
export CMAKE_PREFIX_PATH=/opt/openrobots:$CMAKE_PREFIX_PATH
#添加软连接,解决工程依赖
sudo find / -name libpinocchio.so
sudo ln -s /opt/openrobots/lib/libpinocchio.so /usr/lib
sudo ln -s /opt/openrobots/lib/libhpp-fcl.so /usr/lib
#如roscore运行报错,~/.bashrc再添加
LD_LIBRARY_PATH=/opt/ros/noetic/lib
#ImportError: /home/jeff/anaconda3/envs/isaac/lib/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/_rclpy_pybind11.cpython-310-x86_64-linux-gnu.so)
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX
ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /home/xxx/anaconda3/envs/xxx/bin/../lib/libstdc++.so.6
mujoco
wget https://mujoco.org/download/mujoco-3.0.0-linux-x86_64.tar.gz
tar -xvzf mujoco-3.0.0-linux-x86_64.tar.gz -C ~/.mujoco
sudo vim ~/.bashrc
export LD_LIBRARY_PATH=/home/jeff/.mujoco/mujoco-3.0.0/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/nvidia
export PATH="$LD_LIBRARY_PATH:$PATH"
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so
export MUJOCO_KEY_PATH=/home/jeff/.mujoco${MUJOCO_KEY_PATH}
#mujocopy
pip3 install mujoco
#把include文件放在系统目录
sudo cp -rf /usr/local/lib/python3.8/dist-packages/mujoco/include/mujoco/ /usr/local/include/
sudo find / -name libmujoco*
sudo ln -s /home/jeff/.mujoco/mujoco-3.0.0/lib/libmujoco.so /usr/lib
sudo ln -s /home/jeff/.mujoco/mujoco-3.0.0/lib/libmujoco.so.3.0.0 /usr/lib
libjson-rpc-cpp
#1、依赖安装
sudo apt-get install libjsoncpp-dev
sudo apt-get install libhiredis-dev
sudo apt-get install libargtable2-dev
sudo apt-get install libmicrohttpd-dev
#2、下载源码
git clone https://github.com/cinemast/libjson-rpc-cpp.git
cd libjson-rpc-cpp
#3、打开编译选项,需要的设置为YES,这一步可选
vim CMakeLists.txt
set(TCP_SOCKET_SERVER YES CACHE BOOL "Include Tcp Socket server")
set(TCP_SOCKET_CLIENT YES CACHE BOOL "Include Tcp Socket client")
#3、编译安装
mkdir build
cd build
cmake ..
make
sudo make install
sudo ldconfig
#工程引用后,报HMD找不到
#新建一个 FindMHD.cmake 文件并在工程中include进入cmakelists中
# Find the libmicrohttpd library
find_path(MHD_INCLUDE_DIR microhttpd.h)
find_library(MHD_LIBRARY NAMES microhttpd libmicrohttpd)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MHD DEFAULT_MSG MHD_INCLUDE_DIR MHD_LIBRARY)
if (MHD_FOUND)
if (NOT TARGET MHD::MHD)
add_library(MHD::MHD UNKNOWN IMPORTED)
set_target_properties(MHD::MHD PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${MHD_INCLUDE_DIR}"
IMPORTED_LOCATION "${MHD_LIBRARY}"
)
endif()
endif()
# 例如:
# 指定CMake模块路径
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# 找到 libmicrohttpd 库
find_package(MHD REQUIRED)
Sophus
李群计算
#下载
git clone https://github.com/strasdat/Sophus.git
#编译安装
cd Sophus
mkdir build
cd build
cmake ..
make
sudo make install
- fmt依赖
git clone https://github.com/fmtlib/fmt.git
cd fmt && mkdir build
cmake ..
make && make install
- 使用sophus
find_package( Sophus REQUIRED )
include_directories( ${Sophus_INCLUDE_DIRS} )
add_executable(xxx xxx.cpp)
target_link_libraries( xxx Sophus::Sophus )
g2o
非线性优化
git clone https://github.com/RainerKuemmerle/g2o.git
cd g2o
mkdir build
cd build
cmake ..
make
sudo make install
ceres
非线性优化
https://github.com/ceres-solver/ceres-solver/archive/refs/tags/2.0.0.tar.gz
#安装相关依赖
sudo apt-get install liblapack-dev libsuitesparse-dev libcxsparse3 libgflags-dev libgoogle-glog-dev libgtest-dev
#安装ceres(使用2.0版本没有eigen路径找不到问题)
tar -zxvf ceres-solver-2.0.0.tar.gz
cd ceres-solver-2.0.0/
mkdir build
cd build
cmake ..
make
sudo make install
# 安装成功查看
/usr/local/include/ceres下找到Ceres的头文件
/usr/local/lib/下找到名为libceres.a的库文件
- 使用cmakelists.txt
find_package(Ceres REQUIRED)
include_directories(${CERES_INCLUDE_DIRS})
add_executable(xxx xx.cpp)
target_link_libraries(xxx ${CERES_LIBRARIES})
opencv+opencv_contrib
图像处理
https://github.com/opencv/opencv/archive/4.7.0.zip
https://github.com/opencv/opencv_contrib/archive/refs/tags/4.7.0.tar.gz
#依赖安装
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg-dev libswscale-dev libtiff5-dev
sudo apt-get install libcanberra-gtk-module
sudo apt-get install pkg-config
#解压
unzip opencv-4.7.0
tar -zxvf opencv_contrib-4.7.0.tar.gz
#拷贝
cp -r opencv_contrib-4.7.0 opencv-4.7.0
# 编译
mkdir -p build && cd build
cmake ..
cmake --build .
#安装
sudo make install # 默认安装路径为/user/local/lib
#修改两个配置文件,尾行新增
sudo gedit /etc/ld.so.conf
include /user/local/lib
sudo gedit /etc/bash.bashrc
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
source /etc/bash.bashrc
# 查看版本
pkg-config opencv –modversion
# 添加映射方便使用
sudo ln -s /usr/local/include/opencv4/opencv2 /usr/local/include/opencv2
#测试
cd samples
cd cpp
cd example_cmake
cmake .
make
./opencv_example
- ffmpeg
sudo apt install ffmpeg
- VTK
https://www.vtk.org/files/release/9.2/VTK-9.2.2.tar.gz
tar -zxvf VTK-9.2.2.tar.gz
cd VTK-9.2.2/
mkdir build
cmake ../ -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release -DVTK_WRAP_PYTHON=O
make
sudo make install
- 使用cmakeLists.txt
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(xxx xxx.cpp)
target_link_libraries(xxx ${OpenCV_LIBS})
Pangolin
三维可视化工具
git clone https://github.com/stevenlovegrove/Pangolin.git
# 依赖
sudo apt install libglew-dev cmake libboost-dev libboost-thread-dev libboost-filesystem-dev libeigen3-dev
# 安装
cd Pangolin/
mkdir build
cd build
cmake ..
make
sudo make install
- error1 项目中使用pangolin,build时候报引用错误
需要在CMakeLists.txt添加
find_package(Pangolin REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS})
add_executable(helloPangolin helloPangolin.cpp)
target_link_libraries(helloPangolin ${Pangolin_LIBRARIES})
- error while loading shared libraries: libpango_windowing.so: cannot open shared object file: No such file or directory
sudo ldconfig
pcl
点云处理
sudo apt install libpcl-dev