Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gaoxiang12/slam_in_autonomous_dri…
Browse files Browse the repository at this point in the history
…ving
  • Loading branch information
gaoxiang committed Feb 14, 2023
2 parents 6508e22 + d8a581c commit 43cd53d
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)

option(BUILD_WITH_UBUNTU1804 OFF)

include(cmake/packages.cmake)
include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${PROJECT_SOURCE_DIR})
Expand Down
71 changes: 60 additions & 11 deletions cmake/packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,63 @@ include_directories(${yaml-cpp_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/thirdparty/)
include_directories(${PROJECT_SOURCE_DIR}/thirdparty/velodyne/include)

set(third_party_libs
${catkin_LIBRARIES}
${g2o_libs}
${OpenCV_LIBS}
${PCL_LIBRARIES}
${Pangolin_LIBRARIES}
glog gflags
${yaml-cpp_LIBRARIES}
yaml-cpp
tbb
)
if(BUILD_WITH_UBUNTU1804)
function(extract_file filename extract_dir)
message(STATUS "Extract ${filename} to ${extract_dir} ...")
set(temp_dir ${extract_dir})
if(EXISTS ${temp_dir})
file(REMOVE_RECURSE ${temp_dir})
endif()
file(MAKE_DIRECTORY ${temp_dir})
execute_process(COMMAND ${CMAKE_COMMAND} -E tar -xvzf ${filename}
WORKING_DIRECTORY ${temp_dir})
endfunction()

set(TBB_ROOT_DIR ${PROJECT_SOURCE_DIR}/thirdparty/tbb/oneTBB-2019_U8/oneTBB-2019_U8)
set(TBB_BUILD_DIR "tbb_build_dir=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
set(TBB_BUILD_PREFIX "tbb_build_prefix=tbb")

extract_file(${PROJECT_SOURCE_DIR}/thirdparty/tbb/2019_U8.tar.gz ${PROJECT_SOURCE_DIR}/thirdparty/tbb/oneTBB-2019_U8)

include(${TBB_ROOT_DIR}/cmake/TBBBuild.cmake)

#message(STATUS "======TBB_BUILD_DIR = ${TBB_BUILD_DIR}")
#message(STATUS "======TBB_BUILD_PREFIX = ${TBB_BUILD_PREFIX}")

tbb_build(TBB_ROOT ${TBB_ROOT_DIR}
compiler=gcc-9
stdver=c++17
${TBB_BUILD_DIR}
${TBB_BUILD_PREFIX}
CONFIG_DIR
TBB_DIR)

find_package(TBB REQUIRED)

include_directories(${PROJECT_SOURCE_DIR}/thirdparty/tbb/oneTBB-2019_U8/oneTBB-2019_U8/include)
link_directories(${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/tbb_release)

set(third_party_libs
${catkin_LIBRARIES}
${g2o_libs}
${OpenCV_LIBS}
${PCL_LIBRARIES}
${Pangolin_LIBRARIES}
glog gflags
${yaml-cpp_LIBRARIES}
yaml-cpp
TBB::tbb
)
else()
set(third_party_libs
${catkin_LIBRARIES}
${g2o_libs}
${OpenCV_LIBS}
${PCL_LIBRARIES}
${Pangolin_LIBRARIES}
glog gflags
${yaml-cpp_LIBRARIES}
yaml-cpp
tbb
)
endif ()
46 changes: 45 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,53 @@
## 编译

- 本书推荐的编译环境是Ubuntu 20.04。更老的Ubuntu版本需要适配gcc编译器,主要是C++17标准。更新的Ubuntu则需要您自己安装对应的ROS版本。
- 在编译本书代码之前,请编译安装本书thirdparty/下的三方库(如果您机器上没有安装的话)。
- 在编译本书代码之前,请编译安装本书thirdparty/下的```g2o```以及以下三方库(如果您机器上没有安装的话)
- ROS Noetic (http://wiki.ros.org/noetic/Installation/Ubuntu)
- pcl-ros (如果没有选择安装 ```ros-noetic-desktop-full```): ```sudo apt install ros-noetic-pcl-ros```
- velodyne-msgs (如果没有选择安装```ros-noetic-desktop-full```): ```sudo apt install ros-noetic-velodyne-msgs```
- opencv: ```sudo apt install libopencv-dev```
- glog: ```sudo apt install libgoogle-glog-dev```
- eigen3: ```sudo apt install libeigen3-dev```
- suitesparse: ```sudo apt install libsuitesparse-dev```
- pcl: ```sudo apt install libpcl-dev```
- yaml-cpp: ```sudo apt install libyaml-cpp-dev```
- tbb: ```sudo apt install libbtbb-dev```
- gmock: ```sudo apt install libgmock-dev```
- 以下命令可以一次安装上面几个库: ```sudo apt install -y libopencv-dev libgoogle-glog-dev libeigen3-dev libsuitesparse-dev libpcl-dev libyaml-cpp-dev libbtbb-dev libgmock-dev```
- Pangolin: https://github.com/stevenlovegrove/Pangolin
- 之后,使用通常的cmake, make 方式就可以编译本书所有内容了。

### 适配Ubuntu18.04

为了在Ubuntu18.04上编译运行,需要安装gcc-9,并且使用对应版本的TBB

**安装gcc-9**
```bash
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++

#命令最后的1和10是优先级,如果使用auto选择模式,系统将默认使用优先级高的
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 1
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 10

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 1
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 10
```

**检查版本**
```bash
g++ -v
```

**编译程序**
```bash
mkdir build
cd build
cmake .. -DBUILD_WITH_UBUNTU1804=ON
make -j8
```

## TODO项

- 一部分插图需要授权
Expand Down
2 changes: 1 addition & 1 deletion src/ch7/loam-like/feature_extraction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void FeatureExtraction::Extract(FullCloudPtr pc_in, CloudPtr pc_out_edge, CloudP
p.z = pt.z;
p.intensity = pt.intensity;

scans_in_each_line[pt.ring]->emplace_back(p);
scans_in_each_line[pt.ring]->points.emplace_back(p);
}

// 处理曲率
Expand Down
Binary file added thirdparty/tbb/2019_U8.tar.gz
Binary file not shown.

0 comments on commit 43cd53d

Please sign in to comment.