├── .dockerignore
├── .gitignore
├── docker
├── build_docker.sh
├── run_docker.sh
├── Dockerfile
└── 1.Dockerfile
├── scripts
├── debug_plot.sh
└── transform_monitor.py
├── launch
├── test_outdoor.launch
├── test_indoor.launch
├── test_outdoor_64.launch
├── 16_scans_test.launch
├── test_indoor_rs32.launch
├── rs32_scans_test.launch
├── 64_scans_test.launch
├── map_4D.launch
└── map_4D_indoor.launch
├── include
├── 3rdparty
│ └── sophus
│ │ ├── example_ensure_handler.cpp
│ │ ├── LICENSE.txt
│ │ ├── interpolate.hpp
│ │ ├── velocities.hpp
│ │ ├── rotation_matrix.hpp
│ │ ├── interpolate_details.hpp
│ │ ├── num_diff.hpp
│ │ ├── sim_details.hpp
│ │ ├── geometry.hpp
│ │ ├── common.hpp
│ │ ├── types.hpp
│ │ └── test_macros.hpp
├── factor
│ ├── GravityLocalParameterization.h
│ ├── PoseLocalParameterization.h
│ ├── PriorFactor.h
│ ├── PlaneProjectionFactor.h
│ ├── PivotPointPlaneFactor.h
│ ├── PointDistanceFactor.h
│ ├── PlaneToPlaneFactor.h
│ ├── MarginalizationFactor.h
│ └── ImuFactor.h
├── utils
│ ├── TicToc.h
│ ├── common_ros.h
│ ├── Twist.h
│ ├── LoadVirtual.h
│ ├── CircularBuffer.h
│ └── math_utils.h
├── point_processor
│ └── point_types.h
├── map_builder
│ └── MapBuilder.h
├── imu_processor
│ ├── ImuInitializer.h
│ ├── ImuInitializer_viorb.h
│ └── MeasurementManager.h
└── feature_manager
│ └── FeatureManager.h
├── config
├── outdoor_test_config.yaml
├── indoor_test_config.yaml
└── outdoor_test_config_64.yaml
├── test
├── test_visualizaer.cc
├── test_point_processor
│ ├── test_point_odometry.cc
│ ├── test_point_mapping.cc
│ └── test_point_processor.cc
└── test_imu_processor
│ ├── test_circular_buffer.cc
│ └── test_measurement_manager.cc
├── src
├── factor
│ ├── GravityLocalParameterization.cc
│ ├── PoseLocalParameterization.cc
│ ├── PriorFactor.cc
│ └── PointDistanceFactor.cc
├── mapping_node.cc
├── odometry_node.cc
├── map_builder_node.cc
├── processor_node.cc
├── input_filters_node.cc
├── imu_processor
│ └── MeasurementManager.cc
├── save_bag_to_pcd.cc
└── estimator_node.cc
├── README.md
└── package.xml
/.dockerignore:
--------------------------------------------------------------------------------
1 | docker
2 | .git
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | .vscode
3 | build
4 | cmake-build-*
5 |
--------------------------------------------------------------------------------
/docker/build_docker.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
3 | docker build --build-arg your_name=${USER} -t hyye/lio -f ${DIR}/Dockerfile ${DIR}/..
--------------------------------------------------------------------------------
/scripts/debug_plot.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | python transform_monitor.py &
3 | rqt_plot /predict_odom/pose/pose/position:x:y:z &
4 | rqt_plot /extrinsic_lb/pose/position:x:y:z &
5 | rqt_plot /debug/imu_rot/vector/y /debug/laser_rot/vector/y
6 |
--------------------------------------------------------------------------------
/launch/test_outdoor.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/include/3rdparty/sophus/example_ensure_handler.cpp:
--------------------------------------------------------------------------------
1 | #include "common.hpp"
2 |
3 | #include
4 | #include
5 |
6 | namespace Sophus {
7 | void ensureFailed(char const* function, char const* file, int line,
8 | char const* description) {
9 | std::printf("Sophus ensure failed in function '%s', file '%s', line %d.\n",
10 | file, function, line);
11 | std::printf("Description: %s\n", description);
12 | std::abort();
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/launch/test_indoor.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/launch/test_outdoor_64.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/launch/16_scans_test.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/launch/test_indoor_rs32.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/launch/rs32_scans_test.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/launch/64_scans_test.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/launch/map_4D.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/launch/map_4D_indoor.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/include/3rdparty/sophus/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright 2011-2017 Hauke Strasdat
2 | 2012-2017 Steven Lovegrove
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to
6 | deal in the Software without restriction, including without limitation the
7 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 | sell copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 | IN THE SOFTWARE.
--------------------------------------------------------------------------------
/include/3rdparty/sophus/interpolate.hpp:
--------------------------------------------------------------------------------
1 | #ifndef SOPHUS_INTERPOLATE_HPP
2 | #define SOPHUS_INTERPOLATE_HPP
3 |
4 | #include
5 |
6 | #include "interpolate_details.hpp"
7 |
8 | namespace Sophus {
9 |
10 | // This function interpolates between two Lie group elements ``foo_T_bar``
11 | // and ``foo_T_baz`` with an interpolation factor of ``alpha`` in [0, 1].
12 | //
13 | // It returns a pose ``foo_T_quiz`` with ``quiz`` being a frame between ``bar``
14 | // and ``baz``. If ``alpha=0`` it returns ``foo_T_bar``. If it is 1, it returns
15 | // ``foo_T_bar``.
16 | //
17 | // (Since interpolation on Lie groups is inverse-invariant, we can equivalently
18 | // think of the input arguments as being ``bar_T_foo``, ``baz_T_foo`` and the
19 | // return value being ``quiz_T_foo``.)
20 | //
21 | // Precondition: ``p`` must be in [0, 1].
22 | //
23 | template
24 | enable_if_t::supported, G> interpolate(
25 | G const& foo_T_bar, G const& foo_T_baz, Scalar2 p = Scalar2(0.5f)) {
26 | using Scalar = typename G::Scalar;
27 | Scalar inter_p(p);
28 | SOPHUS_ENSURE(inter_p >= Scalar(0) && inter_p <= Scalar(1),
29 | "p (%) must in [0, 1].");
30 | return foo_T_bar * G::exp(inter_p * (foo_T_bar.inverse() * foo_T_baz).log());
31 | }
32 |
33 | } // namespace Sophus
34 |
35 | #endif // SOPHUS_INTERPOLATE_HPP
36 |
--------------------------------------------------------------------------------
/docker/run_docker.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | until nvidia-docker ps
4 | do
5 | echo "Waiting for docker server"
6 | sleep 1
7 | done
8 |
9 |
10 | # Make sure processes in the container can connect to the x server
11 | # Necessary so rviz can create a context for OpenGL rendering
12 | XAUTH=/tmp/.docker.xauth
13 | if [ ! -f $XAUTH ]
14 | then
15 | xauth_list=$(xauth nlist :0 | sed -e 's/^..../ffff/')
16 | if [ ! -z "$xauth_list" ]
17 | then
18 | echo $xauth_list | xauth -f $XAUTH nmerge -
19 | else
20 | touch $XAUTH
21 | fi
22 | chmod a+r $XAUTH
23 | fi
24 |
25 | # nvidia-docker run -it \
26 | # -e DISPLAY=$DISPLAY \
27 | # -e QT_X11_NO_MITSHM=1 \
28 | # -e XAUTHORITY=$XAUTH \
29 | # -v "$XAUTH:$XAUTH" \
30 | # -v "/tmp/.X11-unix:/tmp/.X11-unix" \
31 | # -v "/etc/localtime:/etc/localtime:ro" \
32 | # -v "/dev/input:/dev/input" \
33 | # --privileged \
34 | # --rm=true \
35 | # --net=host \
36 | # hyye/lio
37 |
38 | nvidia-docker run -it \
39 | -e DISPLAY=$DISPLAY \
40 | -e QT_X11_NO_MITSHM=1 \
41 | -e XAUTHORITY=$XAUTH \
42 | -v "$XAUTH:$XAUTH" \
43 | --user=$USER \
44 | --volume="/etc/group:/etc/group:ro" \
45 | --volume="/etc/passwd:/etc/passwd:ro" \
46 | --volume="/etc/shadow:/etc/shadow:ro" \
47 | --volume="/etc/sudoers.d:/etc/sudoers.d:ro" \
48 | --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
49 | --privileged \
50 | --rm=true \
51 | --net=host \
52 | hyye/lio \
53 | /bin/bash -c "source /workspace/devel/setup.bash; sleep 1; roslaunch lio test_indoor.launch & sleep 1; roslaunch lio map_4D_indoor.launch"
54 |
--------------------------------------------------------------------------------
/config/outdoor_test_config.yaml:
--------------------------------------------------------------------------------
1 | %YAML:1.0
2 | # lidar features
3 | min_plane_dis: 0.2
4 |
5 | min_match_sq_dis: 1.0
6 |
7 | corner_filter_size: 0.2
8 | surf_filter_size: 0.4
9 | map_filter_size: 0.6
10 |
11 | # window sizes
12 | window_size: 7
13 | opt_window_size: 5
14 |
15 | init_window_factor: 1
16 |
17 | # Extrinsic parameter between IMU and Camera (adapted from VINS-mono)
18 | estimate_extrinsic: 1 # 0 Have an accurate extrinsic parameters. We will trust the following imu^R_cam, imu^T_cam, don't change it.
19 | # 1 Have an initial guess about extrinsic parameters. We will optimize around your initial guess.
20 | # 2 Don't know anything about extrinsic parameters. You don't need to give R,T. We will try to calibrate it. Do some rotation movement at beginning.
21 | opt_extrinsic: 1
22 |
23 | extrinsic_rotation: !!opencv-matrix
24 | rows: 3
25 | cols: 3
26 | dt: d
27 | data: [1, 0, 0,
28 | 0, 1, 0,
29 | 0, 0, 1]
30 |
31 | #Translation from imu frame to laser frame, laser^T_imu
32 | extrinsic_translation: !!opencv-matrix
33 | rows: 3
34 | cols: 1
35 | dt: d
36 | data: [-2.4, 0, 0.7]
37 |
38 | # optimization options
39 | run_optimization: 1
40 |
41 | update_laser_imu: 1
42 | gravity_fix: 1
43 |
44 | plane_projection_factor: 0
45 |
46 | imu_factor: 1
47 | point_distance_factor: 1
48 |
49 | prior_factor: 0
50 |
51 | marginalization_factor: 1
52 |
53 | odom_io: 3
54 |
55 | pcl_viewer: 0
56 |
57 | # IMU noises
58 | acc_n: 0.2
59 | gyr_n: 0.02
60 | acc_w: 0.0002
61 | gyr_w: 2.0e-5
62 | g_norm: 9.80
63 |
64 | # lidar deskew
65 | enable_deskew: 1
66 | cutoff_deskew: 0
67 |
68 | keep_features: 0
69 |
70 | msg_time_delay: 0.05
--------------------------------------------------------------------------------
/config/indoor_test_config.yaml:
--------------------------------------------------------------------------------
1 | %YAML:1.0
2 | # lidar features
3 | min_plane_dis: 0.2
4 |
5 | min_match_sq_dis: 1.0
6 |
7 | corner_filter_size: 0.2
8 | surf_filter_size: 0.4
9 | map_filter_size: 0.6
10 |
11 | # window sizes
12 | window_size: 12 #7
13 | opt_window_size: 7 #5
14 |
15 | init_window_factor: 2
16 |
17 | # Extrinsic parameter between IMU and Camera (adapted from VINS-mono)
18 | estimate_extrinsic: 2 # 0 Have an accurate extrinsic parameters. We will trust the following imu^R_cam, imu^T_cam, don't change it.
19 | # 1 Have an initial guess about extrinsic parameters. We will optimize around your initial guess.
20 | # 2 Don't know anything about extrinsic parameters. You don't need to give R,T. We will try to calibrate it. Do some rotation movement at beginning.
21 | opt_extrinsic: 1
22 |
23 | extrinsic_rotation: !!opencv-matrix
24 | rows: 3
25 | cols: 3
26 | dt: d
27 | data: [1, 0, 0,
28 | 0, 1, 0,
29 | 0, 0, 1]
30 |
31 | #Translation from imu frame to laser frame, laser^T_imu
32 | extrinsic_translation: !!opencv-matrix
33 | rows: 3
34 | cols: 1
35 | dt: d
36 | data: [0.0, 0.0, -0.081939]
37 |
38 | # optimization options
39 | run_optimization: 1
40 |
41 | update_laser_imu: 1
42 | gravity_fix: 1
43 |
44 | plane_projection_factor: 0
45 |
46 | imu_factor: 1
47 | point_distance_factor: 1
48 |
49 | prior_factor: 0
50 |
51 | marginalization_factor: 1
52 |
53 | odom_io: 2
54 |
55 | pcl_viewer: 0
56 |
57 | # IMU noises
58 | acc_n: 0.2
59 | gyr_n: 0.02
60 | acc_w: 0.0002
61 | gyr_w: 2.0e-5
62 | g_norm: 9.805
63 |
64 | # lidar deskew
65 | enable_deskew: 1
66 | cutoff_deskew: 0
67 |
68 | keep_features: 1
69 |
70 | msg_time_delay: 0.05
--------------------------------------------------------------------------------
/config/outdoor_test_config_64.yaml:
--------------------------------------------------------------------------------
1 | %YAML:1.0
2 | # lidar features
3 | min_plane_dis: 0.2
4 |
5 | min_match_sq_dis: 1.0
6 |
7 | corner_filter_size: 0.2
8 | surf_filter_size: 0.4
9 | map_filter_size: 0.6
10 |
11 | # window sizes
12 | window_size: 7
13 | opt_window_size: 5
14 |
15 | init_window_factor: 1
16 |
17 | # Extrinsic parameter between IMU and Camera (adapted from VINS-mono)
18 | estimate_extrinsic: 1 # 0 Have an accurate extrinsic parameters. We will trust the following imu^R_cam, imu^T_cam, don't change it.
19 | # 1 Have an initial guess about extrinsic parameters. We will optimize around your initial guess.
20 | # 2 Don't know anything about extrinsic parameters. You don't need to give R,T. We will try to calibrate it. Do some rotation movement at beginning.
21 | opt_extrinsic: 1
22 |
23 | # KITTI 00
24 | extrinsic_rotation: !!opencv-matrix
25 | rows: 3
26 | cols: 3
27 | dt: d
28 | data: [9.999976e-01,7.553071e-04,-2.035826e-03,
29 | -7.854027e-04,9.998898e-01,-1.482298e-02,
30 | 2.024406e-03,1.482454e-02,9.998881e-01]
31 |
32 | #Translation from imu frame to laser frame, laser^T_imu
33 | extrinsic_translation: !!opencv-matrix
34 | rows: 3
35 | cols: 1
36 | dt: d
37 | data: [-8.086759e-01,3.195559e-01,-7.997231e-01]
38 |
39 | # optimization options
40 | run_optimization: 1
41 |
42 | update_laser_imu: 1
43 | gravity_fix: 1
44 |
45 | plane_projection_factor: 0
46 |
47 | imu_factor: 1
48 | point_distance_factor: 1
49 |
50 | prior_factor: 1
51 |
52 | marginalization_factor: 1
53 |
54 | odom_io: 3
55 |
56 | pcl_viewer: 0
57 |
58 | # IMU noises
59 | acc_n: 0.2
60 | gyr_n: 0.02
61 | acc_w: 0.0002
62 | gyr_w: 2.0e-5
63 | g_norm: 9.80
64 |
65 | # lidar deskew
66 | enable_deskew: 1
67 | cutoff_deskew: 1
68 |
69 | keep_features: 0
70 |
71 | msg_time_delay: 0.00
72 |
--------------------------------------------------------------------------------
/test/test_visualizaer.cc:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 5/7/18.
29 | //
30 |
31 | #include
32 | #include
33 | #include
34 |
35 | #include "lio/LineObject.h"
36 | #include "utils/TicToc.h"
37 | #include "visualizer/Visualizer.h"
38 |
39 | using namespace lio;
40 | using namespace std;
41 |
42 | TEST(LineObjectTest, LineObjectCreate) {
43 |
44 | }
45 |
46 |
47 | int main(int argc, char **argv) {
48 | testing::InitGoogleTest(&argc, argv);
49 |
50 | google::InitGoogleLogging(argv[0]);
51 | google::ParseCommandLineFlags(&argc, &argv, true);
52 |
53 | FLAGS_alsologtostderr = true;
54 |
55 | PlaneNormalVisualizer vis;
56 |
57 | vis.Spin();
58 |
59 | return RUN_ALL_TESTS();
60 | }
--------------------------------------------------------------------------------
/include/factor/GravityLocalParameterization.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 4/11/18.
29 | //
30 |
31 | #ifndef LIO_GRAVITYLOCALPARAMETERIZATION_H_
32 | #define LIO_GRAVITYLOCALPARAMETERIZATION_H_
33 |
34 | #include
35 | #include
36 |
37 | #include "utils/math_utils.h"
38 |
39 | namespace lio {
40 |
41 | using namespace mathutils;
42 |
43 | class GravityLocalParameterization : public ceres::LocalParameterization {
44 |
45 | virtual bool Plus(const double *x, const double *delta, double *x_plus_delta) const;
46 | virtual bool ComputeJacobian(const double *x, double *jacobian) const;
47 | virtual int GlobalSize() const { return 4; };
48 | virtual int LocalSize() const { return 2; };
49 |
50 | };
51 |
52 | }
53 |
54 | #endif //LIO_GRAVITYLOCALPARAMETERIZATION_H_
55 |
--------------------------------------------------------------------------------
/include/factor/PoseLocalParameterization.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 4/4/18.
29 | //
30 |
31 | #ifndef LIO_POSELOCALPARAMETERIZATION_H_
32 | #define LIO_POSELOCALPARAMETERIZATION_H_
33 |
34 | #include
35 | #include
36 |
37 | #include "utils/math_utils.h"
38 |
39 | namespace lio {
40 |
41 | using namespace mathutils;
42 |
43 | class PoseLocalParameterization : public ceres::LocalParameterization {
44 |
45 | virtual bool Plus(const double *x, const double *delta, double *x_plus_delta) const;
46 | virtual bool ComputeJacobian(const double *x, double *jacobian) const;
47 | virtual int GlobalSize() const { return 7; };
48 | virtual int LocalSize() const { return 6; };
49 |
50 | };
51 |
52 | } // namespace lio
53 |
54 | #endif //LIO_POSELOCALPARAMETERIZATION_H_
55 |
--------------------------------------------------------------------------------
/include/utils/TicToc.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 3/14/18.
29 | //
30 |
31 | #ifndef LIO_TICTOC_H
32 | #define LIO_TICTOC_H
33 |
34 | #include
35 | #include
36 | #include
37 |
38 | class TicToc {
39 | public:
40 | TicToc() {
41 | Tic();
42 | }
43 |
44 | void Tic() {
45 | start_ = std::chrono::system_clock::now();
46 | }
47 |
48 | double Toc() {
49 | end_ = std::chrono::system_clock::now();
50 | elapsed_seconds_ = end_ - start_;
51 | return elapsed_seconds_.count() * 1000;
52 | }
53 |
54 | double GetLastStop() {
55 | return elapsed_seconds_.count() * 1000;
56 | }
57 |
58 | private:
59 | std::chrono::time_point start_, end_;
60 | std::chrono::duration elapsed_seconds_;
61 | };
62 |
63 | #endif //LIO_TICTOC_H
64 |
--------------------------------------------------------------------------------
/include/factor/PriorFactor.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 4/13/18.
29 | //
30 |
31 | #ifndef LIO_PRIORFACTOR_H_
32 | #define LIO_PRIORFACTOR_H_
33 |
34 | #include
35 | #include "imu_processor/IntegrationBase.h"
36 | #include "utils/math_utils.h"
37 |
38 | namespace lio {
39 |
40 | using namespace mathutils;
41 |
42 | class PriorFactor : public ceres::SizedCostFunction<6, 7> {
43 |
44 | public:
45 | PriorFactor() = delete;
46 | PriorFactor(const Eigen::Vector3d &pos, const Eigen::Quaterniond &rot) : pos_{pos}, rot_{rot} {}
47 |
48 | bool Evaluate(double const *const *parameters, double *residuals, double **jacobians) const;
49 |
50 | void Check(double const *const *parameters);
51 |
52 | Eigen::Vector3d pos_;
53 | Eigen::Quaterniond rot_;
54 |
55 | };
56 |
57 | }
58 |
59 | #endif //LIO_PRIORFACTOR_H_
60 |
--------------------------------------------------------------------------------
/include/utils/common_ros.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 3/16/18.
29 | //
30 |
31 | #ifndef LIO_COMMON_ROS_H_
32 | #define LIO_COMMON_ROS_H_
33 |
34 | #include
35 | #include
36 | #include
37 | #include
38 |
39 | namespace lio {
40 |
41 | template
42 | inline void PublishCloudMsg(ros::Publisher& publisher,
43 | const pcl::PointCloud& cloud,
44 | const ros::Time& stamp,
45 | std::string frame_id) {
46 | sensor_msgs::PointCloud2 msg;
47 | pcl::toROSMsg(cloud, msg);
48 | msg.header.stamp = stamp;
49 | msg.header.frame_id = frame_id;
50 | publisher.publish(msg);
51 | }
52 |
53 | } // namespace lio
54 |
55 | #endif //LIO_COMMON_ROS_H_
56 |
--------------------------------------------------------------------------------
/src/factor/GravityLocalParameterization.cc:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 4/11/18.
29 | //
30 |
31 | #include "factor/GravityLocalParameterization.h"
32 |
33 | namespace lio {
34 |
35 | bool GravityLocalParameterization::Plus(const double *x, const double *delta, double *x_plus_delta) const
36 | {
37 | Eigen::Map q(x);
38 |
39 | Eigen::Map dq_xy(delta);
40 |
41 | Eigen::Quaterniond dq = DeltaQ(Eigen::Vector3d(dq_xy.x(), dq_xy.y(), 0.0));
42 |
43 | Eigen::Map q_plus(x_plus_delta);
44 |
45 | q_plus = (q * dq).normalized();
46 |
47 | return true;
48 | }
49 | bool GravityLocalParameterization::ComputeJacobian(const double *x, double *jacobian) const
50 | {
51 | Eigen::Map> j(jacobian);
52 | j.topRows<2>().setIdentity();
53 | j.bottomRows<2>().setZero();
54 |
55 | return true;
56 | }
57 |
58 | }
--------------------------------------------------------------------------------
/include/point_processor/point_types.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | // adapted from velodyne ros driver
28 |
29 | #ifndef LIO_POINT_TYPES_H_
30 | #define LIO_POINT_TYPES_H_
31 |
32 | #include
33 |
34 | namespace lio {
35 |
36 | /** Euclidean coordinate, including intensity and ring number. */
37 | struct PointXYZIR
38 | {
39 | PCL_ADD_POINT4D; // quad-word XYZ
40 | float intensity; ///< laser intensity reading
41 | uint16_t ring; ///< laser ring number
42 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW // ensure proper alignment
43 | }
44 | EIGEN_ALIGN16;
45 | } // namespace lio
46 |
47 | POINT_CLOUD_REGISTER_POINT_STRUCT(lio::PointXYZIR,
48 | (float, x, x)
49 | (float, y, y)
50 | (float, z, z)
51 | (float, intensity, intensity)
52 | (uint16_t, ring, ring))
53 |
54 | #endif // LIO_POINT_TYPES_H_
--------------------------------------------------------------------------------
/src/factor/PoseLocalParameterization.cc:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 4/4/18.
29 | //
30 |
31 | #include "factor/PoseLocalParameterization.h"
32 |
33 | namespace lio {
34 |
35 | bool PoseLocalParameterization::Plus(const double *x, const double *delta, double *x_plus_delta) const
36 | {
37 | Eigen::Map p(x);
38 | Eigen::Map q(x + 3);
39 |
40 | Eigen::Map dp(delta);
41 |
42 | Eigen::Quaterniond dq = DeltaQ(Eigen::Map(delta + 3));
43 |
44 | Eigen::Map p_plus(x_plus_delta);
45 | Eigen::Map q_plus(x_plus_delta + 3);
46 |
47 | p_plus = p + dp;
48 | q_plus = (q * dq).normalized();
49 |
50 | return true;
51 | }
52 | bool PoseLocalParameterization::ComputeJacobian(const double *x, double *jacobian) const
53 | {
54 | Eigen::Map> j(jacobian);
55 | j.topRows<6>().setIdentity();
56 | j.bottomRows<1>().setZero();
57 |
58 | return true;
59 | }
60 |
61 | }
--------------------------------------------------------------------------------
/docker/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM osrf/ros:melodic-desktop-full
2 |
3 | ARG your_name
4 |
5 | # see: https://gitlab.com/nvidia/opengl/tree/ubuntu18.04
6 |
7 | RUN dpkg --add-architecture i386 && \
8 | apt-get update && apt-get install -y --no-install-recommends \
9 | libxau6 libxau6:i386 \
10 | libxdmcp6 libxdmcp6:i386 \
11 | libxcb1 libxcb1:i386 \
12 | libxext6 libxext6:i386 \
13 | libx11-6 libx11-6:i386 && \
14 | rm -rf /var/lib/apt/lists/*
15 |
16 | # nvidia-container-runtime
17 | ENV NVIDIA_VISIBLE_DEVICES \
18 | ${NVIDIA_VISIBLE_DEVICES:-all}
19 | ENV NVIDIA_DRIVER_CAPABILITIES \
20 | ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics,compat32,utility
21 |
22 | RUN echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
23 | echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf
24 |
25 | # Required for non-glvnd setups.
26 | ENV LD_LIBRARY_PATH /usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
27 |
28 | RUN apt-get update && apt-get install -y --no-install-recommends \
29 | libglvnd0 libglvnd0:i386 \
30 | libgl1 libgl1:i386 \
31 | libglx0 libglx0:i386 \
32 | libegl1 libegl1:i386 \
33 | libgles2 libgles2:i386 && \
34 | rm -rf /var/lib/apt/lists/*
35 |
36 | COPY --from=nvidia/opengl:1.0-glvnd-runtime-ubuntu18.04 \
37 | /usr/share/glvnd/egl_vendor.d/10_nvidia.json \
38 | /usr/share/glvnd/egl_vendor.d/10_nvidia.json
39 |
40 | # Prerequisites
41 | # ENV USER=$your_name
42 | RUN adduser $your_name
43 | RUN curl http://ceres-solver.org/ceres-solver-1.14.0.tar.gz --output ceres-solver-1.14.0.tar.gz
44 | RUN apt-get update && apt-get install -y --no-install-recommends \
45 | libgoogle-glog-dev libatlas-base-dev libeigen3-dev libsuitesparse-dev
46 | RUN tar zxf ceres-solver-1.14.0.tar.gz && mkdir ceres-bin && cd ceres-bin && cmake ../ceres-solver-1.14.0 && make -j3 && make install
47 | # USER $yourname
48 | # RUN mkdir -p /workspace && chmod -R 777 /workspace
49 | # COPY --chown=1000:1000 . /workspace/src/
50 | COPY . /workspace/src/
51 | RUN /bin/bash -c "source /opt/ros/melodic/setup.bash && cd /workspace && catkin_make -DCMAKE_BUILD_TYPE=Release"
52 |
--------------------------------------------------------------------------------
/include/map_builder/MapBuilder.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 5/31/18.
29 | //
30 |
31 | #ifndef LIO_MAPBUILDER_H_
32 | #define LIO_MAPBUILDER_H_
33 |
34 | #include "point_processor/PointMapping.h"
35 |
36 | namespace lio {
37 |
38 | using namespace std;
39 | using namespace mathutils;
40 |
41 | struct MapBuilderConfig {
42 | float corner_filter_size = 0.2;
43 | float surf_filter_size = 0.4;
44 | float map_filter_size = 0.6;
45 |
46 | float min_match_sq_dis = 1.0;
47 | float min_plane_dis = 0.2;
48 | };
49 |
50 | class MapBuilder : public PointMapping {
51 | public:
52 | MapBuilder() = delete;
53 | MapBuilder(MapBuilderConfig config);
54 | void SetupRos(ros::NodeHandle &nh);
55 | void ProcessMap();
56 | void OptimizeMap();
57 | void PublishMapBuilderResults();
58 | void Transform4DAssociateToMap();
59 | void Transform4DUpdate();
60 |
61 | private:
62 | bool system_init_ = false;
63 | bool enable_4d_ = true;
64 | int skip_count_ = 2;
65 | MapBuilderConfig config_;
66 | int odom_count_ = 0;
67 |
68 | };
69 |
70 | }
71 |
72 | #endif //LIO_MAPBUILDER_H_
73 |
--------------------------------------------------------------------------------
/src/mapping_node.cc:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 3/25/18.
29 | //
30 |
31 | //
32 | // Created by hyye on 3/15/18.
33 | //
34 |
35 | #include
36 | #include
37 | #include
38 |
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 |
45 | #include
46 |
47 | #include "point_processor/PointMapping.h"
48 | #include "utils/TicToc.h"
49 |
50 | using namespace lio;
51 | using namespace std;
52 | using namespace mathutils;
53 |
54 | int main(int argc, char **argv) {
55 |
56 | google::InitGoogleLogging(argv[0]);
57 | FLAGS_alsologtostderr = true;
58 |
59 | ros::init(argc, argv, "point_mapping");
60 |
61 | ros::NodeHandle nh("~");;
62 |
63 | PointMapping mapper;
64 | mapper.SetupRos(nh);
65 | mapper.Reset();
66 |
67 | ros::Rate r(100);
68 | while (ros::ok()) {
69 | mapper.Process();
70 | ros::spinOnce();
71 | r.sleep();
72 | }
73 |
74 | return 0;
75 | }
--------------------------------------------------------------------------------
/include/factor/PlaneProjectionFactor.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 4/12/18.
29 | //
30 |
31 | #ifndef LIO_PLANEPROJECTIONFACTOR_H_
32 | #define LIO_PLANEPROJECTIONFACTOR_H_
33 |
34 | #include
35 | #include
36 |
37 | #include "utils/CircularBuffer.h"
38 | #include "utils/Twist.h"
39 | #include "utils/common_ros.h"
40 | #include "utils/TicToc.h"
41 | #include "utils/math_utils.h"
42 | #include "utils/geometry_utils.h"
43 |
44 | namespace lio {
45 |
46 | using namespace mathutils;
47 |
48 | class PlaneProjectionFactor : public ceres::SizedCostFunction<4, 7, 7, 7> {
49 |
50 | public:
51 | PlaneProjectionFactor(const Eigen::Vector4d &local_coeffi, const Eigen::Vector4d &local_coeffj, const double &score);
52 | virtual bool Evaluate(double const *const *parameters, double *residuals, double **jacobians) const;
53 |
54 | void Check(double **parameters);
55 |
56 | Eigen::Vector4d local_coeffi_;
57 | Eigen::Vector4d local_coeffj_;
58 | double score_;
59 |
60 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW
61 |
62 | };
63 |
64 | }
65 |
66 | #endif //LIO_PLANEPROJECTIONFACTOR_H_
67 |
--------------------------------------------------------------------------------
/src/odometry_node.cc:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 3/15/18.
29 | //
30 |
31 | #include
32 | #include
33 | #include
34 |
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 |
41 | #include
42 |
43 | #include "point_processor/PointOdometry.h"
44 | #include "utils/TicToc.h"
45 |
46 | using namespace lio;
47 | using namespace std;
48 | using namespace mathutils;
49 |
50 | DEFINE_int32(io_ratio, 2, "ratio of io");
51 |
52 | int main(int argc, char **argv) {
53 |
54 | google::InitGoogleLogging(argv[0]);
55 | FLAGS_alsologtostderr = true;
56 |
57 | ros::init(argc, argv, "point_odometry");
58 |
59 | ros::NodeHandle nh("~");
60 |
61 | PointOdometry odometry(0.1, FLAGS_io_ratio);
62 | odometry.SetupRos(nh);
63 | odometry.Reset();
64 |
65 | ros::Rate r(100);
66 | while (ros::ok()) {
67 | odometry.Process();
68 | ros::spinOnce();
69 | r.sleep();
70 | }
71 |
72 | return 0;
73 | }
--------------------------------------------------------------------------------
/include/factor/PivotPointPlaneFactor.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 5/17/18.
29 | //
30 |
31 | #ifndef LIO_PIVOTPOINTPLANEFACTOR_H_
32 | #define LIO_PIVOTPOINTPLANEFACTOR_H_
33 |
34 | #include
35 | #include
36 |
37 | #include "utils/CircularBuffer.h"
38 | #include "utils/Twist.h"
39 | #include "utils/common_ros.h"
40 | #include "utils/TicToc.h"
41 | #include "utils/math_utils.h"
42 | #include "utils/geometry_utils.h"
43 |
44 | namespace lio {
45 |
46 | using namespace mathutils;
47 |
48 | class PivotPointPlaneFactor : public ceres::SizedCostFunction<1, 7, 7, 7> {
49 |
50 | public:
51 | PivotPointPlaneFactor(const Eigen::Vector3d &point,
52 | const Eigen::Vector4d &coeff);
53 | virtual bool Evaluate(double const *const *parameters, double *residuals, double **jacobians) const;
54 | void Check(double **parameters);
55 |
56 | Eigen::Vector3d point_;
57 | Eigen::Vector4d coeff_;
58 |
59 | // TODO: necessary?
60 | // static Eigen::Matrix3d sqrt_info;
61 | static double sum_t;
62 |
63 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW
64 |
65 | };
66 |
67 | }
68 |
69 | #endif //LIO_PIVOTPOINTPLANEFACTOR_H_
70 |
--------------------------------------------------------------------------------
/src/map_builder_node.cc:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 5/31/18.
29 | //
30 |
31 | #include
32 | #include
33 |
34 | #include
35 | #include
36 | #include
37 | #include
38 |
39 | #include
40 |
41 | #include
42 |
43 | #include
44 | #include
45 |
46 | #include "map_builder/MapBuilder.h"
47 | #include "utils/TicToc.h"
48 |
49 | using namespace lio;
50 | using namespace std;
51 | using namespace mathutils;
52 |
53 | static ros::NodeHandlePtr nh_ptr;
54 |
55 | int main(int argc, char **argv) {
56 |
57 | google::InitGoogleLogging(argv[0]);
58 | FLAGS_alsologtostderr = true;
59 |
60 | ros::init(argc, argv, "map_builder");
61 |
62 | ros::NodeHandle nh("~");
63 |
64 | MapBuilderConfig config;
65 | config.map_filter_size = 0.2;
66 |
67 | MapBuilder mapper(config);
68 | mapper.SetupRos(nh);
69 | mapper.Reset();
70 |
71 | ros::Rate r(100);
72 | while (ros::ok()) {
73 | mapper.ProcessMap();
74 | ros::spinOnce();
75 | r.sleep();
76 | }
77 |
78 | return 0;
79 | }
80 |
--------------------------------------------------------------------------------
/include/factor/PointDistanceFactor.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 4/3/18.
29 | //
30 |
31 | #ifndef LIO_POINTDISTANCEFACTOR_H_
32 | #define LIO_POINTDISTANCEFACTOR_H_
33 |
34 | #include
35 | #include
36 |
37 | #include "utils/CircularBuffer.h"
38 | #include "utils/Twist.h"
39 | #include "utils/common_ros.h"
40 | #include "utils/TicToc.h"
41 | #include "utils/math_utils.h"
42 | #include "utils/geometry_utils.h"
43 |
44 | namespace lio {
45 |
46 | using namespace mathutils;
47 |
48 | class PointDistanceFactor : public ceres::SizedCostFunction<1, 7, 7> {
49 |
50 | public:
51 | PointDistanceFactor(const Eigen::Vector3d &point,
52 | const Eigen::Vector4d &coeff,
53 | const Eigen::Matrix info_mat);
54 | virtual bool Evaluate(double const *const *parameters, double *residuals, double **jacobians) const;
55 | void Check(double **parameters);
56 |
57 | Eigen::Vector3d point_;
58 | Eigen::Vector4d coeff_;
59 | Twist transform_lb_;
60 | Eigen::Matrix info_mat_;
61 |
62 | // TODO: necessary?
63 | static Eigen::Matrix3d sqrt_info;
64 | static double sum_t;
65 |
66 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW
67 |
68 | };
69 |
70 | } // namespace lio
71 |
72 | #endif //LIO_POINTDISTANCEFACTOR_H_
73 |
--------------------------------------------------------------------------------
/include/factor/PlaneToPlaneFactor.h:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 5/9/18.
29 | //
30 |
31 | #ifndef LIO_PLANETOPLANEFACTOR_H_
32 | #define LIO_PLANETOPLANEFACTOR_H_
33 |
34 | #include
35 | #include
36 |
37 | #include "utils/CircularBuffer.h"
38 | #include "utils/Twist.h"
39 | #include "utils/common_ros.h"
40 | #include "utils/TicToc.h"
41 | #include "utils/math_utils.h"
42 | #include "utils/geometry_utils.h"
43 |
44 | #include "feature_manager/FeatureManager.h"
45 |
46 | namespace lio {
47 |
48 | using namespace mathutils;
49 |
50 | class PlaneToPlaneFactor : public ceres::SizedCostFunction<3, 7, 7, 7> {
51 | public:
52 | PlaneToPlaneFactor(const Eigen::Vector3d &pi_local, const Eigen::Vector3d &ni_local,
53 | const Eigen::Vector3d &pj_local, const Eigen::Vector3d &nj_local);
54 | virtual bool Evaluate(double const *const *parameters, double *residuals, double **jacobians) const;
55 |
56 | void Check(double **parameters);
57 |
58 | Eigen::Vector3d pi_local_;
59 | Eigen::Vector3d ni_local_;
60 | Eigen::Vector3d pj_local_;
61 | Eigen::Vector3d nj_local_;
62 | // Eigen::Matrix3d mahalanobis_;
63 |
64 | PointNormalFeature pfi_;
65 | PointNormalFeature pfj_;
66 |
67 | const double eps_ = 1e-8;
68 |
69 | static double sum_t_;
70 |
71 | EIGEN_MAKE_ALIGNED_OPERATOR_NEW
72 | };
73 |
74 | }
75 |
76 | #endif //LIO_PLANETOPLANEFACTOR_H_
77 |
--------------------------------------------------------------------------------
/test/test_point_processor/test_point_odometry.cc:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 3/15/18.
29 | //
30 |
31 | #include
32 | #include
33 | #include
34 |
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 |
41 | #include
42 |
43 | #include "point_processor/PointOdometry.h"
44 | #include "utils/TicToc.h"
45 |
46 | using namespace lio;
47 | using namespace std;
48 | using namespace mathutils;
49 |
50 | static ros::Publisher test_pub;
51 | static ros::NodeHandlePtr nh_ptr;
52 |
53 | TEST(PointProcessorTest, ObjectTest) {
54 | PointOdometry odometry;
55 | odometry.SetupRos(*nh_ptr);
56 | odometry.Reset();
57 |
58 | ros::Rate r(100);
59 | while (ros::ok()) {
60 | odometry.Process();
61 | ros::spinOnce();
62 | r.sleep();
63 | }
64 |
65 | }
66 |
67 | int main(int argc, char **argv) {
68 | testing::InitGoogleTest(&argc, argv);
69 |
70 | google::InitGoogleLogging(argv[0]);
71 | google::ParseCommandLineFlags(&argc, &argv, true);
72 |
73 | ros::init(argc, argv, "test_point_odometry");
74 | {
75 | ros::NodeHandle nh("~");
76 | nh_ptr = boost::make_shared(nh);
77 | }
78 |
79 | FLAGS_alsologtostderr = true;
80 |
81 | return RUN_ALL_TESTS();
82 | }
--------------------------------------------------------------------------------
/test/test_point_processor/test_point_mapping.cc:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 3/25/18.
29 | //
30 |
31 | //
32 | // Created by hyye on 3/15/18.
33 | //
34 |
35 | #include
36 | #include
37 | #include
38 |
39 | #include
40 | #include
41 | #include
42 | #include
43 | #include
44 |
45 | #include
46 |
47 | #include "point_processor/PointMapping.h"
48 | #include "utils/TicToc.h"
49 |
50 | using namespace lio;
51 | using namespace std;
52 | using namespace mathutils;
53 |
54 | static ros::NodeHandlePtr nh_ptr;
55 |
56 | TEST(PointMappingTest, ObjectTest) {
57 | PointMapping mapper;
58 | mapper.SetupRos(*nh_ptr);
59 | mapper.Reset();
60 |
61 | ros::Rate r(100);
62 | while (ros::ok()) {
63 | mapper.Process();
64 | ros::spinOnce();
65 | r.sleep();
66 | }
67 |
68 | }
69 |
70 | int main(int argc, char **argv) {
71 | testing::InitGoogleTest(&argc, argv);
72 |
73 | google::InitGoogleLogging(argv[0]);
74 | google::ParseCommandLineFlags(&argc, &argv, true);
75 |
76 | ros::init(argc, argv, "test_point_mapping");
77 | {
78 | ros::NodeHandle nh("~");
79 | nh_ptr = boost::make_shared(nh);
80 | }
81 |
82 | FLAGS_alsologtostderr = true;
83 |
84 | return RUN_ALL_TESTS();
85 | }
--------------------------------------------------------------------------------
/docker/1.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM osrf/ros:melodic-desktop-full
2 |
3 | ARG your_name
4 | LABEL com.nvidia.volumes.needed="nvidia_driver"
5 | ENV PATH /usr/local/nvidia/bin:${PATH}
6 | ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64:${LD_LIBRARY_PATH}
7 |
8 | RUN apt-get update \
9 | && apt-get install -y \
10 | wget \
11 | lsb-release \
12 | sudo \
13 | mesa-utils \
14 | && apt-get clean
15 | # see: https://gitlab.com/nvidia/opengl/tree/ubuntu18.04
16 | # RUN dpkg --add-architecture i386 && \
17 | # apt-get update && apt-get install -y --no-install-recommends \
18 | # libxau6 libxau6:i386 \
19 | # libxdmcp6 libxdmcp6:i386 \
20 | # libxcb1 libxcb1:i386 \
21 | # libxext6 libxext6:i386 \
22 | # libx11-6 libx11-6:i386 && \
23 | # rm -rf /var/lib/apt/lists/*
24 | #
25 | # # nvidia-container-runtime
26 | # ENV NVIDIA_VISIBLE_DEVICES \
27 | # ${NVIDIA_VISIBLE_DEVICES:-all}
28 | # ENV NVIDIA_DRIVER_CAPABILITIES \
29 | # ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics,compat32,utility
30 | #
31 | # RUN echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
32 | # echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf
33 | #
34 | # # Required for non-glvnd setups.
35 | # ENV LD_LIBRARY_PATH /usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}:/usr/local/nvidia/lib:/usr/local/nvidia/lib64
36 | #
37 | # RUN apt-get update && apt-get install -y --no-install-recommends \
38 | # libglvnd0 libglvnd0:i386 \
39 | # libgl1 libgl1:i386 \
40 | # libglx0 libglx0:i386 \
41 | # libegl1 libegl1:i386 \
42 | # libgles2 libgles2:i386 && \
43 | # rm -rf /var/lib/apt/lists/*
44 | #
45 | # COPY --from=nvidia/opengl:1.0-glvnd-runtime-ubuntu18.04 \
46 | # /usr/share/glvnd/egl_vendor.d/10_nvidia.json \
47 | # /usr/share/glvnd/egl_vendor.d/10_nvidia.json
48 | #
49 | # Prerequisites
50 | # ENV USER=$your_name
51 | RUN adduser $your_name
52 | RUN curl http://ceres-solver.org/ceres-solver-1.14.0.tar.gz --output ceres-solver-1.14.0.tar.gz
53 | RUN apt-get update && apt-get install -y --no-install-recommends \
54 | libgoogle-glog-dev libatlas-base-dev libeigen3-dev libsuitesparse-dev
55 | RUN tar zxf ceres-solver-1.14.0.tar.gz && mkdir ceres-bin && cd ceres-bin && cmake ../ceres-solver-1.14.0 && make -j6 && make install
56 | # USER $yourname
57 | # RUN mkdir -p /workspace && chmod -R 777 /workspace
58 | # COPY --chown=1000:1000 . /workspace/src/
59 | COPY . /workspace/src/
60 | RUN /bin/bash -c "source /opt/ros/melodic/setup.bash && cd /workspace && catkin_make -DCMAKE_BUILD_TYPE=Release"
61 |
--------------------------------------------------------------------------------
/include/3rdparty/sophus/velocities.hpp:
--------------------------------------------------------------------------------
1 | #ifndef SOPHUS_VELOCITIES_HPP
2 | #define SOPHUS_VELOCITIES_HPP
3 |
4 | #include
5 |
6 | #include "num_diff.hpp"
7 | #include "se3.hpp"
8 |
9 | namespace Sophus {
10 | namespace experimental {
11 | // Experimental since the API will certainly change drastically in the future.
12 |
13 | // Transforms velocity vector by rotation ``foo_R_bar``.
14 | //
15 | // Note: vel_bar can be either a linear or a rotational velocity vector.
16 | //
17 | template
18 | Vector3 transformVelocity(SO3 const& foo_R_bar,
19 | Vector3 const& vel_bar) {
20 | // For rotational velocities note that:
21 | //
22 | // vel_bar = vee(foo_R_bar * hat(vel_bar) * foo_R_bar^T)
23 | // = vee(hat(Adj(foo_R_bar) * vel_bar))
24 | // = Adj(foo_R_bar) * vel_bar
25 | // = foo_R_bar * vel_bar.
26 | //
27 | return foo_R_bar * vel_bar;
28 | }
29 |
30 | // Transforms velocity vector by pose ``foo_T_bar``.
31 | //
32 | // Note: vel_bar can be either a linear or a rotational velocity vector.
33 | //
34 | template
35 | Vector3 transformVelocity(SE3 const& foo_T_bar,
36 | Vector3 const& vel_bar) {
37 | return transformVelocity(foo_T_bar.so3(), vel_bar);
38 | }
39 |
40 | // finite difference approximation of instantanious velocity in frame foo
41 | //
42 | template
43 | Vector3 finiteDifferenceRotationalVelocity(
44 | std::function(Scalar)> const& foo_R_bar, Scalar t,
45 | Scalar h = Constants::epsilon()) {
46 | // https://en.wikipedia.org/w/index.php?title=Angular_velocity&oldid=791867792#Angular_velocity_tensor
47 | //
48 | // W = dR(t)/dt * R^{-1}(t)
49 | Matrix3 dR_dt_in_frame_foo = curveNumDiff(
50 | [&foo_R_bar](Scalar t0) -> Matrix3 {
51 | return foo_R_bar(t0).matrix();
52 | },
53 | t, h);
54 | // velocity tensor
55 | Matrix3 W_in_frame_foo =
56 | dR_dt_in_frame_foo * (foo_R_bar(t)).inverse().matrix();
57 | return SO3::vee(W_in_frame_foo);
58 | }
59 |
60 | // finite difference approximation of instantanious velocity in frame foo
61 | //
62 | template
63 | Vector3 finiteDifferenceRotationalVelocity(
64 | std::function(Scalar)> const& foo_T_bar, Scalar t,
65 | Scalar h = Constants::epsilon()) {
66 | return finiteDifferenceRotationalVelocity(
67 | [&foo_T_bar](Scalar t) -> SO3 { return foo_T_bar(t).so3(); }, t,
68 | h);
69 | }
70 |
71 | } // namespace experimental
72 | } // namespace Sophus
73 |
74 | #endif // SOPHUS_VELOCITIES_HPP
75 |
--------------------------------------------------------------------------------
/src/processor_node.cc:
--------------------------------------------------------------------------------
1 | /**
2 | * This file is part of LIO-mapping.
3 | *
4 | * Copyright (C) 2019 Haoyang Ye ,
5 | * Robotics and Multiperception Lab (RAM-LAB ),
6 | * The Hong Kong University of Science and Technology
7 | *
8 | * For more information please see
9 | * or .
10 | * If you use this code, please cite the respective publications as
11 | * listed on the above websites.
12 | *
13 | * LIO-mapping is free software: you can redistribute it and/or modify
14 | * it under the terms of the GNU General Public License as published by
15 | * the Free Software Foundation, either version 3 of the License, or
16 | * (at your option) any later version.
17 | *
18 | * LIO-mapping is distributed in the hope that it will be useful,
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 | * GNU General Public License for more details.
22 | *
23 | * You should have received a copy of the GNU General Public License
24 | * along with LIO-mapping. If not, see .
25 | */
26 |
27 | //
28 | // Created by hyye on 3/15/18.
29 | //
30 |
31 | #include
32 | #include
33 | #include
34 |
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 |
41 | #include
42 |
43 | #include "point_processor/PointProcessor.h"
44 | #include "utils/TicToc.h"
45 |
46 | using namespace lio;
47 | using namespace std;
48 | using namespace mathutils;
49 |
50 |
51 | int main(int argc, char **argv) {
52 |
53 | google::InitGoogleLogging(argv[0]);
54 | FLAGS_alsologtostderr = true;
55 | ros::init(argc, argv, "point_processor");
56 |
57 | ros::NodeHandle nh("~");
58 |
59 | int sensor_type;
60 | double rad_diff;
61 | bool infer_start_ori;
62 | nh.param("sensor_type", sensor_type, 16);
63 | nh.param("rad_diff", rad_diff, 0.2);
64 | nh.param("infer_start_ori", infer_start_ori, false);
65 |
66 | PointProcessor processor; // Default sensor_type is 16
67 |
68 | if (sensor_type == 32) {
69 | processor = PointProcessor(-30.67f, 10.67f, 32);
70 | } else if (sensor_type == 64) {
71 | processor = PointProcessor(-24.9f, 2, 64);
72 | } else if (sensor_type == 320) {
73 | processor = PointProcessor(-25, 15, 32, true);
74 | }
75 |
76 | PointProcessorConfig config;
77 | config.rad_diff = rad_diff;
78 | config.infer_start_ori_ = infer_start_ori;
79 | processor.SetupConfig(config);
80 |
81 | LOG(INFO) << "Sensor type: " << processor.laser_scans.size();
82 |
83 | processor.SetupRos(nh);
84 |
85 | ros::Rate r(100);
86 | while (ros::ok()) {
87 | ros::spinOnce();
88 | r.sleep();
89 | }
90 |
91 | return 0;
92 | }
--------------------------------------------------------------------------------
/include/3rdparty/sophus/rotation_matrix.hpp:
--------------------------------------------------------------------------------
1 | #ifndef SOPHUS_ROTATION_MATRIX_HPP
2 | #define SOPHUS_ROTATION_MATRIX_HPP
3 |
4 | #include
5 | #include
6 |
7 | #include "types.hpp"
8 |
9 | namespace Sophus {
10 |
11 | // Takes in arbiray square matrix and returns true if it is
12 | // orthogonal.
13 | template
14 | SOPHUS_FUNC bool isOrthogonal(Eigen::MatrixBase const& R) {
15 | using Scalar = typename D::Scalar;
16 | static int const N = D::RowsAtCompileTime;
17 | static int const M = D::ColsAtCompileTime;
18 |
19 | static_assert(N == M, "must be a square matrix");
20 | static_assert(N >= 2, "must have compile time dimension >= 2");
21 |
22 | return (R * R.transpose() - Matrix::Identity()).norm() <
23 | Constants::epsilon();
24 | }
25 |
26 | // Takes in arbiray square matrix and returns true if it is
27 | // "scaled-orthogonal" with positive determinant.
28 | //
29 | template
30 | SOPHUS_FUNC bool isScaledOrthogonalAndPositive(Eigen::MatrixBase const& sR) {
31 | using Scalar = typename D::Scalar;
32 | static int const N = D::RowsAtCompileTime;
33 | static int const M = D::ColsAtCompileTime;
34 | using std::pow;
35 | using std::sqrt;
36 |
37 | Scalar det = sR.determinant();
38 |
39 | if (det <= Scalar(0)) {
40 | return false;
41 | }
42 |
43 | Scalar scale_sqr = pow(det, Scalar(2. / N));
44 |
45 | static_assert(N == M, "must be a square matrix");
46 | static_assert(N >= 2, "must have compile time dimension >= 2");
47 |
48 | return (sR * sR.transpose() - scale_sqr * Matrix::Identity())
49 | .template lpNorm() <
50 | sqrt(Constants::epsilon());
51 | }
52 |
53 | // Takes in arbiray square matrix (2x2 or larger) and returns closest
54 | // orthogonal matrix with positive determinant.
55 | template
56 | SOPHUS_FUNC enable_if_t<
57 | std::is_floating_point::value,
58 | Matrix>
59 | makeRotationMatrix(Eigen::MatrixBase const& R) {
60 | using Scalar = typename D::Scalar;
61 | static int const N = D::RowsAtCompileTime;
62 | static int const M = D::ColsAtCompileTime;
63 |
64 | static_assert(N == M, "must be a square matrix");
65 | static_assert(N >= 2, "must have compile time dimension >= 2");
66 |
67 | Eigen::JacobiSVD> svd(
68 | R, Eigen::ComputeFullU | Eigen::ComputeFullV);
69 |
70 | // Determine determinant of orthogonal matrix U*V'.
71 | Scalar d = (svd.matrixU() * svd.matrixV().transpose()).determinant();
72 | // Starting from the identity matrix D, set the last entry to d (+1 or
73 | // -1), so that det(U*D*V') = 1.
74 | Matrix Diag = Matrix::Identity();
75 | Diag(N - 1, N - 1) = d;
76 | return svd.matrixU() * Diag * svd.matrixV().transpose();
77 | }
78 |
79 | } // namespace Sophus
80 |
81 | #endif // SOPHUS_ROTATION_MATRIX_HPP
82 |
--------------------------------------------------------------------------------
/scripts/transform_monitor.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import numpy as np
3 | import rospy
4 | from nav_msgs.msg import Odometry
5 | from geometry_msgs.msg import Twist, Quaternion, Vector3, Vector3Stamped
6 | from tf.transformations import euler_from_quaternion, quaternion_matrix, quaternion_from_matrix, euler_from_quaternion, euler_from_matrix, euler_matrix
7 |
8 |
9 | class transform_monitor(object):
10 | def __init__(self):
11 | rospy.init_node('transform_monitor')
12 | self.laser_odom = rospy.get_param('~laser_odom', default='/local_laser_odom/')
13 | self.imu_odom = rospy.get_param('~imu_odom', default='/predict_odom')
14 |
15 | def get_odom(self, odom_msg):
16 | pos = odom_msg.pose.pose.position
17 | quat = odom_msg.pose.pose.orientation
18 | explicit_pos = [pos.x, pos.y, pos.z]
19 | explicit_quat = [quat.x, quat.y, quat.z, quat.w]
20 |
21 | transform_world_laser = quaternion_matrix(explicit_quat)
22 | transform_world_laser[0:3, 3] = explicit_pos
23 | euler_angles = euler_from_quaternion(explicit_quat, 'rzyx')
24 | z = euler_angles[0]
25 | y = euler_angles[1]
26 | x = euler_angles[2]
27 |
28 | v = Vector3Stamped()
29 | v.header = odom_msg.header
30 | v.vector.x = x
31 | v.vector.y = y
32 | v.vector.z = z
33 |
34 | self.imu_rot_pub.publish(v)
35 |
36 | # print('imu_rot_y', y)
37 |
38 | def get_laser_odom(self, odom_msg):
39 | pos = odom_msg.pose.pose.position
40 | quat = odom_msg.pose.pose.orientation
41 | explicit_pos = [pos.x, pos.y, pos.z]
42 | explicit_quat = [quat.x, quat.y, quat.z, quat.w]
43 |
44 | transform_world_laser = quaternion_matrix(explicit_quat)
45 | transform_world_laser[0:3, 3] = explicit_pos
46 | euler_angles = euler_from_quaternion(explicit_quat, 'rzyx')
47 | z = euler_angles[0]
48 | y = euler_angles[1]
49 | x = euler_angles[2]
50 |
51 | v = Vector3Stamped()
52 | v.header = odom_msg.header
53 | v.vector.x = x
54 | v.vector.y = y
55 | v.vector.z = z
56 |
57 | self.laser_rot_pub.publish(v)
58 |
59 | # print('laser_rot_y', y)
60 |
61 | def main(self):
62 | r = rospy.Rate(1000)
63 | self.odom_sub = rospy.Subscriber(self.imu_odom, Odometry, self.get_odom)
64 | self.laser_odom_sub = rospy.Subscriber(self.laser_odom, Odometry, self.get_laser_odom)
65 | print('self.imu_odom', self.imu_odom)
66 | print('self.laser_odom', self.laser_odom)
67 | self.imu_rot_pub = rospy.Publisher('/debug/imu_rot', Vector3Stamped, queue_size=10)
68 | self.laser_rot_pub = rospy.Publisher('/debug/laser_rot', Vector3Stamped, queue_size=10)
69 | while not rospy.is_shutdown():
70 | r.sleep()
71 |
72 |
73 | if __name__ == '__main__':
74 | monitor = transform_monitor()
75 | try:
76 | monitor.main()
77 | except rospy.ROSException:
78 | print 'Interrupted'
79 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # LIO-mapping
2 | ## A Tightly Coupled 3D Lidar and Inertial Odometry and Mapping Approach
3 | #### Authors: Haoyang Ye, Yuying Chen, and Ming Liu from [RAM-LAB](https://ram-lab.com/).
4 | [[Paper]](https://arxiv.org/abs/1904.06993), [[Project]](https://sites.google.com/view/lio-mapping), [[Bib]](https://ram-lab.com/papers/2019/icra_2019_ye.bib). ICRA 2019.
5 | ## Table of Contents
6 | * [Demo Results](#demo-results)
7 | * [Prerequisites](#prerequisites)
8 | * [Build](#build)
9 | * [Examples](#examples)
10 | * [Docker](#docker)
11 | * [Credits](#credits)
12 | * [Licence](#licence)
13 |
14 | ## Demo Results
15 |
16 |
17 |
18 | Video: [[More indoor and outdoor tests]](https://ram-lab.com/file/hyye/lio-mapping.mp4).
19 |
20 | ## Prerequisites
21 | See [Dockerfile](docker/Dockerfile) as a reference:
22 | 1. [ROS](http://wiki.ros.org/melodic/Installation) with Ubuntu 18.04 or Ubuntu 16.04.
23 | 2. [Ceres-solver](http://ceres-solver.org/installation.html#linux).
24 | 3. [PCL](http://www.pointclouds.org/downloads/), the default version accompanying by ROS.
25 | 4. [OpenCV](https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html), the default version accompanying by ROS.
26 |
27 | ## Build
28 | 1. `git clone git@github.com:hyye/lio-mapping.git` into the `src` folder of your catkin workspace.
29 | 2. `catkin build -DCMAKE_BUILD_TYPE=Release lio` or `catkin_make -DCMAKE_BUILD_TYPE=Release`.
30 |
31 | ## Examples
32 | Some [sample data](https://drive.google.com/drive/folders/1dPy667dAnJy9wgXmlnRgQZxQF_ESuve3).
33 | 1. `source devel/setup.zsh`, or `setup.bash` if your prefer `bash`.
34 | 2. `roslaunch lio test_indoor.launch &`.
35 | 3. `roslaunch lio map_4D_indoor.launch &`.
36 | 4. `rosbag play fast1.bag`.
37 |
38 | ## Docker
39 | Try it out using docker:
40 | 1. Run `docker/build_docker.sh`.
41 | 2. Run `docker/run_docker.sh`.
42 | 3. Run `rosbag play fast1.bag`, in your host machine or in the running container.
43 |
44 | Note: Visualization (rviz) can run in the running container with [nvidia-docker](https://github.com/NVIDIA/nvidia-docker). The [Dockerfile](docker/Dockerfile) is compatible with [nvidia-docker 2.0](https://github.com/nvidia/nvidia-docker/wiki/Installation-(version-2.0)); [1.Dockerfile](docker/1.Dockerfile) with [nvidia-docker 1.0](https://github.com/nvidia/nvidia-docker/wiki/Installation-(version-1.0)).
45 |
46 | ## Credits
47 | The feature extraction, lidar-only odometry and baseline implemented were heavily derived or taken from the original [LOAM](http://wiki.ros.org/loam_velodyne) and its [modified version](https://github.com/laboshinl/loam_velodyne) (the point_processor in our project), and one of the initialization methods and the optimization pipeline from [VINS-mono](https://github.com/HKUST-Aerial-Robotics/VINS-Mono). The copyright headers are retained for the relevant files.
48 |
49 | ## Licence
50 | The source code is released under [GPL-3.0](https://www.gnu.org/licenses/).
51 |
--------------------------------------------------------------------------------
/include/3rdparty/sophus/interpolate_details.hpp:
--------------------------------------------------------------------------------
1 | #ifndef SOPHUS_INTERPOLATE_DETAILS_HPP
2 | #define SOPHUS_INTERPOLATE_DETAILS_HPP
3 |
4 | #include "rxso2.hpp"
5 | #include "rxso3.hpp"
6 | #include "se2.hpp"
7 | #include "se3.hpp"
8 | #include "sim2.hpp"
9 | #include "sim3.hpp"
10 | #include "so2.hpp"
11 | #include "so3.hpp"
12 |
13 | namespace Sophus {
14 | namespace interp_details {
15 |
16 | template
17 | struct Traits;
18 |
19 | template
20 | struct Traits> {
21 | static bool constexpr supported = true;
22 |
23 | static bool hasShortestPathAmbiguity(SO2 const& foo_T_bar) {
24 | using std::abs;
25 | Scalar angle = foo_T_bar.log();
26 | return abs(abs(angle) - Constants::pi()) <
27 | Constants::epsilon();
28 | }
29 | };
30 |
31 | template
32 | struct Traits> {
33 | static bool constexpr supported = true;
34 |
35 | static bool hasShortestPathAmbiguity(RxSO2 const& foo_T_bar) {
36 | return Traits>::hasShortestPathAmbiguity(foo_T_bar.so2());
37 | }
38 | };
39 |
40 | template
41 | struct Traits> {
42 | static bool constexpr supported = true;
43 |
44 | static bool hasShortestPathAmbiguity(SO3 const& foo_T_bar) {
45 | using std::abs;
46 | Scalar angle = foo_T_bar.logAndTheta().theta;
47 | return abs(abs(angle) - Constants::pi()) <
48 | Constants::epsilon();
49 | }
50 | };
51 |
52 | template
53 | struct Traits> {
54 | static bool constexpr supported = true;
55 |
56 | static bool hasShortestPathAmbiguity(RxSO3 const& foo_T_bar) {
57 | return Traits>::hasShortestPathAmbiguity(foo_T_bar.so3());
58 | }
59 | };
60 |
61 | template
62 | struct Traits> {
63 | static bool constexpr supported = true;
64 |
65 | static bool hasShortestPathAmbiguity(SE2 const& foo_T_bar) {
66 | return Traits>::hasShortestPathAmbiguity(foo_T_bar.so2());
67 | }
68 | };
69 |
70 | template
71 | struct Traits> {
72 | static bool constexpr supported = true;
73 |
74 | static bool hasShortestPathAmbiguity(SE3 const& foo_T_bar) {
75 | return Traits>::hasShortestPathAmbiguity(foo_T_bar.so3());
76 | }
77 | };
78 |
79 | template
80 | struct Traits> {
81 | static bool constexpr supported = true;
82 |
83 | static bool hasShortestPathAmbiguity(Sim2