Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ROS optional, provide Docker, Dependencies as submodules #8

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[submodule "ext/ceres-solver"]
path = ext/ceres-solver
url = https://github.com/ceres-solver/ceres-solver.git
[submodule "ext/g2o"]
path = ext/g2o
url = https://github.com/RainerKuemmerle/g2o.git
[submodule "ext/Sophus"]
path = ext/Sophus
url = https://github.com/strasdat/Sophus.git
59 changes: 31 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
cmake_minimum_required(VERSION 3.0.2)
project(lidar_camera_calibrator)
set(CMAKE_BUILD_TYPE "release")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -O3")
set(CMAKE_CXX_STANDARD 14)

find_package(catkin REQUIRED COMPONENTS
roscpp sensor_msgs cv_bridge pcl_ros pcl_conversions std_msgs
)
find_package(OpenCV REQUIRED)
find_package(PCL REQUIRED)
find_package(catkin)
add_definitions(${PCL_DEFINITIONS})

catkin_package(
INCLUDE_DIRS include
DEPENDS PCL
)

include_directories(
include
${catkin_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
)

link_directories(
include
${PCL_LIBRARY_DIRS}
)
add_library(get_sync_data include/get_sync_data/get_sync_data.cpp)
add_executable(get_sync_data_node ./src/get_sync_data_node.cpp )
target_link_libraries(get_sync_data_node
get_sync_data
${OpenCV_LIBS}
${PCL_LIBRARIES}
${catkin_LIBRARIES}
)

# lidar camera calibrator
add_subdirectory(src/calibrator)
if (catkin_FOUND)
catkin_package(
INCLUDE_DIRS include
DEPENDS PCL
)

include_directories(
include
${catkin_INCLUDE_DIRS}
${PCL_INCLUDE_DIRS}
)

link_directories(
include
${PCL_LIBRARY_DIRS}
)
add_library(get_sync_data include/get_sync_data/get_sync_data.cpp)
add_executable(get_sync_data_node ./src/get_sync_data_node.cpp )
target_link_libraries(get_sync_data_node
get_sync_data
${OpenCV_LIBS}
${PCL_LIBRARIES}
${catkin_LIBRARIES}
)

add_subdirectory(src/calibrator)
else()
add_subdirectory(src/calibrator)
endif()
81 changes: 68 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,91 @@ Hope it helps you.

## Dependencies

- ROS
- ROS Kinetic/Melodic (optional)

- OpenCV

```bash
$ sudo apt install libopencv-dev python3-opencv
```

- Qt 5 (system)

```bash
$ sudo apt install qt5-qmake qt5-default qtbase5-dev qtbase5-private-dev libqglviewer-dev-qt5
```

- Eigen 3 (3.3+)

- [ceres](https://github.com/ceres-solver/ceres-solver.git)(commit: e51e9b4)
```bash
$ sudo apt install libeigen3-dev
```

> ```bash
> # ceres dependencies
> $ sudo apt-get install liblapack-dev libsuitesparse-dev libcxsparse3 libgflags-dev libgoogle-glog-dev libgtest-dev
> ```
- Dependencies in `ext/` (clone with --recursive)

- [g2o](https://github.com/RainerKuemmerle/g2o.git)(tag: 20200410_git)
- [ceres](https://github.com/ceres-solver/ceres-solver.git)(commit: e51e9b4)

```bash
$ sudo apt-get install liblapack-dev libsuitesparse-dev libcxsparse3 libgflags-dev libgoogle-glog-dev libgtest-dev
```

- [g2o](https://github.com/RainerKuemmerle/g2o.git)(tag: 20200410_git)dependencies

```bash
$ sudo apt-get install libqglviewer-dev-qt5 libsuitesparse-dev libcxsparse3 libcholmod3
```

- [sophus](https://github.com/strasdat/Sophus.git)(commit: 13fb328)

> ```bash
> # g2o dependencies
> $ sudo apt-get install qt5-qmake qt5-default libqglviewer-dev-qt5 libsuitesparse-dev libcxsparse3 libcholmod3
> ```
- Misc

- [sophus](https://github.com/strasdat/Sophus.git)(commit: 13fb328)
```bash
$ sudo apt install libcairo2-dev libcgal-dev
```

## Build

#### ROS

```bash
$ mkdir -p ws_calibrator/src && cd ws_calibrator
$ git clone REPOSITORY_GIT_LINK src/lidar_camera_calibrator
$ git clone --recursive REPOSITORY_GIT_LINK src/lidar_camera_calibrator
$ # Install dependencies in ext/, cmake . && make -j3 && sudo make install, each
$ catkin_make
```

#### Non-ROS


```bash
$ git clone --recursive REPOSITORY_GIT_LINK lidar_camera_calibrator && cd lidar_camera_calibrator
$ # Install dependencies in ext/, cmake . && make -j3 && sudo make install, each
$ cd src/calibrator/ && mkdir build && cd build
$ cmake .. && make -j3
```

#### Docker

Build:

```bash
docker build -f docker/Dockerfile -t calibrator .
```

Permissions:

```bash
chmod +x docker/entrypoint.sh
```

Start:

```bash
docker run -it --entrypoint /bin/bash --privileged --name calibrator --rm -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY -h $HOSTNAME -v $HOME/.Xauthority:/home/calibrator/.Xauthority -v /dev:/dev -- calibrator
```

Follow [Usage instructions](#usage)

## Test

We have tested this tool on real and simulated Velodyne-16 and normal cameras, and test data is provided under the `data` folder.
Expand Down
45 changes: 45 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM ros:melodic-perception
RUN apt-get update && apt-get install -y x11-apps git vim libcairo2-dev libcgal-dev libopencv-dev python3-opencv\
libeigen3-dev liblapack-dev libsuitesparse-dev libcxsparse3 libgflags-dev libgoogle-glog-dev libgtest-dev \
qt5-qmake qt5-default qtbase5-dev qtbase5-private-dev libqglviewer-dev-qt5 libsuitesparse-dev libcxsparse3 libcholmod3

ARG user=calibrator
ARG home=/home/$user
RUN groupadd -g 1000 $user
RUN useradd -d $home -s /bin/bash -m $user -u 1000 -g 1000 \
&& adduser $user sudo
WORKDIR $home

COPY ext .
RUN cd ceres-solver && cmake . && make -j3 && make install
RUN cd g2o && cmake . && make -j3 && make install
# see issue https://github.com/strasdat/Sophus/issues/214 for ubuntu 20.04
RUN cd Sophus && cmake . && make -j3 && make install

ENV ROS_WS $home/ros_ws
RUN mkdir -p $ROS_WS/src
WORKDIR $ROS_WS
COPY . $ROS_WS/src/lidar_camera_calibrator
RUN . /opt/ros/melodic/setup.sh \
&& catkin_make


# fix vtk pcl interaction https://stackoverflow.com/a/75687353
RUN ln -s /usr/bin/vtk7 /usr/bin/vtk

RUN chown -R $user:$user $home
USER $user
ENV HOME $home

# necessary for libg2o_core.so to be found after linking
RUN echo "export LD_LIBRARY_PATH=/usr/local/lib:/opt/ros/melodic/lib" >> ~/.bashrc
RUN echo "export XDG_RUNTIME_DIR=$home/xdg_runtime_dir" >> ~/.bashrc

# xdg
RUN mkdir $home/xdg_runtime_dir

# ROS entrypoint
COPY ./docker/entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
CMD ["bash"]

10 changes: 10 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

if [ ${ROS_DISTRO} == "foxy" ] ; then
source "$ROS_WS/install/local_setup.bash"
else
source "/opt/ros/$ROS_DISTRO/setup.bash"
source "$ROS_WS/devel/setup.bash"
fi
exec "$@"
1 change: 1 addition & 0 deletions ext/Sophus
Submodule Sophus added at 13fb32
1 change: 1 addition & 0 deletions ext/ceres-solver
Submodule ceres-solver added at e51e9b
1 change: 1 addition & 0 deletions ext/g2o
Submodule g2o added at 675946
Loading