diff --git a/CMakeLists.txt b/CMakeLists.txt index f71d4ae..52501d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.10) project(oh_my_loam) -set(CMAKE_CXX_FLAGS "-std=c++17 -Wall -lpthread") +set(CMAKE_CXX_FLAGS "-std=c++17 -Wall") set(CMAKE_BUILD_TYPE "Release") set(CMAKE_CXX_FLAGS_RELEASE "-O3") @@ -10,48 +10,15 @@ find_package(PCL QUIET) find_package(g3log REQUIRED) find_package(yaml-cpp REQUIRED) -find_package(catkin REQUIRED COMPONENTS - geometry_msgs - nav_msgs - sensor_msgs - roscpp - rospy - rosbag - std_msgs -) - include_directories(SYSTEM - ${catkin_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS} ${G3LOG_INCLUDE_DIRS} ) -catkin_package( - CATKIN_DEPENDS geometry_msgs nav_msgs roscpp rospy std_msgs - DEPENDS EIGEN3 PCL - INCLUDE_DIRS oh_my_loam common -) - include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ) add_subdirectory(common) add_subdirectory(oh_my_loam) - -add_executable(main main.cc) -target_link_libraries(main - ${catkin_LIBRARIES} - ${PCL_LIBRARIES} - ${G3LOG_LIBRARIES} - ${YAML_CPP_LIBRARIES} - common - oh_my_loam - extractor - odometer - mapper - solver - ${CERES_LIBRARIES} - visualizer - base -) +add_subdirectory(examples) diff --git a/README.md b/README.md index c7d6417..b976b04 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,68 @@ # Oh-My-LOAM -Oh-My-LOAM is a ROS-free implementation of LOAM (J. Zhang and S. Singh. LOAM: Lidar Odometry and Mapping in Real-time). This implementation is modified from [A-LOAM](https://github.com/HKUST-Aerial-Robotics/A-LOAM). +Oh-My-LOAM is a ROS-free implementation of LOAM (J. Zhang and S. Singh. LOAM: Lidar Odometry and Mapping in Real-time). +This implementation is modified from [A-LOAM](https://github.com/HKUST-Aerial-Robotics/A-LOAM). Comparing with A-LOAM, this implementation has following features: - it's ROS-free - it's more readable and easier to understand/modify + + +# How to run +## BUILD + +Install dependences (lsted below).\ +Clone this repository\ +Compile: +```bash +mkdir build && cd build +cmake .. +make -j6 +``` + +## Run with ROS bag as input +Although **Oh-My-LOAM** is ROS-free, running it with ROS bag as input is the simplest way. +We'll take *nsh_indoor_outdoor.bag* as example. +You can download this bag from [google drive](https://drive.google.com/file/d/1s05tBQOLNEDDurlg48KiUWxCp-YqYyGH/view) or [baidupan](https://pan.baidu.com/s/1TbfMQ3Rvmmn1hCjFhXSPcQ) (提取码:9nf7). + +Launch: +``` +./devel/lib/oh_my_loam/main_rosbag ../configs/config_nsh_indoor_outdoor.yaml +``` +Play bag: +``` +ros play nsh_indoor_outdoor.bag +``` + +## Run without ROS support +You can write by yourself. + # Dependences -- Eigen: linear algebra, quaternion -- pcl: point cloud processing -- g3log: logging -- yaml-cpp: yaml parsing -- ceres: non-linear optimization -- c++17 +### 1. C++17 +### 2. Eigen: linear algebra, quaternion +``` +sudo apt install libeigen3-dev +``` +### 3. pcl: point cloud processing +``` +sudo apt install libpcl-dev +``` + +### 4. g3log: logging +Follow [g3log](https://github.com/KjellKod/g3log) to install. + +### 5. yaml-cpp: yaml parsing +``` +sudo apt install libyaml-cpp-dev +``` + +### 6. ceres: non-linear optimization +``` +sudo apt install libceres-dev +``` + +### ROS (optional) diff --git a/common/registerer/registerer.h b/common/registerer/registerer.h index 20919d5..ede355c 100644 --- a/common/registerer/registerer.h +++ b/common/registerer/registerer.h @@ -66,4 +66,4 @@ class Registerer { __attribute__((constructor)) void Register##derived_class() { \ ::common::Registerer::Register(#derived_class); \ } \ - } // namespace \ No newline at end of file + } // namespace diff --git a/oh_my_loam/configs/config.yaml b/configs/config_nsh_indoor_outdoor.yaml similarity index 98% rename from oh_my_loam/configs/config.yaml rename to configs/config_nsh_indoor_outdoor.yaml index 93f46c7..87c7356 100644 --- a/oh_my_loam/configs/config.yaml +++ b/configs/config_nsh_indoor_outdoor.yaml @@ -3,7 +3,6 @@ lidar: VLP16 log_to_file: false log_path: /data/log/oh_my_loam vis: true -save_map: true save_map_path: /data/log/oh_my_loam.pcd # configs for extractor diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..668356d --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,34 @@ +find_package(catkin REQUIRED COMPONENTS + geometry_msgs + nav_msgs + sensor_msgs + roscpp + rospy + rosbag + std_msgs +) + +include_directories(SYSTEM + ${catkin_INCLUDE_DIRS} +) + +catkin_package( + CATKIN_DEPENDS roscpp rospy std_msgs +) + +add_executable(main_rosbag main_rosbag.cc) +target_link_libraries(main_rosbag + ${catkin_LIBRARIES} + ${PCL_LIBRARIES} + ${G3LOG_LIBRARIES} + ${YAML_CPP_LIBRARIES} + common + oh_my_loam + extractor + odometer + mapper + solver + ${CERES_LIBRARIES} + visualizer + base +) diff --git a/main.cc b/examples/main_rosbag.cc similarity index 100% rename from main.cc rename to examples/main_rosbag.cc diff --git a/package.xml b/examples/package.xml similarity index 90% rename from package.xml rename to examples/package.xml index 79bf967..5cde9d8 100644 --- a/package.xml +++ b/examples/package.xml @@ -4,10 +4,10 @@ 0.0.0 - Reimplementation of LOAM. + A ROS-free implementation of LOAM. - qintong + feixyz BSD diff --git a/images/nsh_indoor_outdoor.png b/images/nsh_indoor_outdoor.png new file mode 100644 index 0000000..aa3cb47 Binary files /dev/null and b/images/nsh_indoor_outdoor.png differ diff --git a/oh_my_loam/visualizer/ohmyloam_visualizer.cc b/oh_my_loam/visualizer/ohmyloam_visualizer.cc index 2da52f0..4df6b60 100644 --- a/oh_my_loam/visualizer/ohmyloam_visualizer.cc +++ b/oh_my_loam/visualizer/ohmyloam_visualizer.cc @@ -44,6 +44,7 @@ void OhmyloamVisualizer::KeyboardEventCallback( } is_updated_ = true; } else if (event.getKeySym() == "s" && event.keyDown()) { + if (save_path_.empty()) return; auto frame = GetCurrentFrame(); PointCloud cloud; cloud.reserve(frame.cloud_map_surf->size() + frame.cloud_map_surf->size());