├── orthomap_viewer
├── package.xml
├── CMakeLists.txt
├── README.md
└── src
│ └── orthomap_viewer.cpp
├── hawkeye
├── package.xml
├── launch
│ ├── hawkeye_rt.launch
│ ├── sample_single.launch
│ └── sample.launch
├── include
│ ├── hawkeye_define.hpp
│ ├── util
│ │ ├── error.hpp
│ │ ├── timer.hpp
│ │ ├── arg.hpp
│ │ ├── tf_messages.hpp
│ │ ├── pose_stamped_helper.hpp
│ │ └── pose_synchronize.hpp
│ ├── hawkeye_base
│ │ ├── histogram.hpp
│ │ ├── node.hpp
│ │ └── base.hpp
│ └── map
│ │ └── orthomap.hpp
├── CMakeLists.txt
├── config
│ └── hawkeye.yaml
├── src
│ ├── util
│ │ ├── tf_messages.cpp
│ │ └── pose_stamped_helper.cpp
│ ├── hawkeye_base
│ │ ├── config.cpp
│ │ ├── node.cpp
│ │ └── base.cpp
│ ├── map
│ │ ├── orthomap.cpp
│ │ └── orthomap_read.cpp
│ └── hawkeye_rt
│ │ ├── hawkeye_node.cpp
│ │ └── hawkeye_ws_node.cpp
└── rviz
│ ├── hawkeye.rviz
│ └── hawkeye_ws.rviz
├── LICENSE
└── README.md
/orthomap_viewer/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | orthomap_viewer
4 | 1.0.0
5 | The orthomap_viewer package
6 | Kunihiro Ueda
7 |
8 | BSD 3-Clause
9 |
10 | catkin
11 |
12 | roscpp
13 | std_msgs
14 | nav_msgs
15 | pcl_ros
16 | sensor_msgs
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/hawkeye/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | hawkeye
4 | 1.0.0
5 | Hawkeye package
6 | Kunihiro Ueda
7 |
8 | BSD 3-Clause
9 |
10 | catkin
11 |
12 | roscpp
13 | std_msgs
14 | nav_msgs
15 | pcl_ros
16 | sensor_msgs
17 | tf2
18 | tf2_ros
19 | tf2_eigen
20 | tf2_geometry_msgs
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/orthomap_viewer/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.0.2)
2 | project(orthomap_viewer)
3 |
4 | set(CMAKE_CXX_STANDARD 17)
5 |
6 | find_package(Boost REQUIRED)
7 | find_package(PCL REQUIRED)
8 | find_package(catkin REQUIRED)
9 | find_package(OpenCV REQUIRED)
10 |
11 | find_package(catkin REQUIRED COMPONENTS
12 | roscpp
13 | std_msgs
14 | nav_msgs
15 | pcl_ros
16 | sensor_msgs
17 | )
18 |
19 | catkin_package(
20 | #INCLUDE_DIRS include
21 | DEPENDS PCL
22 | DEPENDS OpenCV
23 | )
24 |
25 | include_directories(include
26 | ${catkin_INCLUDE_DIRS}
27 | ${PCL_INCLUDE_DIRS}
28 | ${OpenCV_INCLUDE_DIRS}
29 | )
30 |
31 | add_executable(orthomap_viewer
32 | src/orthomap_viewer.cpp
33 | )
34 | target_link_libraries(orthomap_viewer
35 | ${catkin_LIBRARIES}
36 | ${OpenCV_LIBRARIES}
37 | )
38 |
39 | add_dependencies(orthomap_viewer ${catkin_EXPORTED_TARGETS})
40 |
--------------------------------------------------------------------------------
/hawkeye/launch/hawkeye_rt.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2022, Map IV, Inc.
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 | * Redistributions of source code must retain the above copyright notice,
7 | this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright notice,
9 | this list of conditions and the following disclaimer in the documentation
10 | and/or other materials provided with the distribution.
11 | * Neither the name of the Map IV, Inc. nor the names of its contributors
12 | may be used to endorse or promote products derived from this software
13 | without specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY
19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
--------------------------------------------------------------------------------
/hawkeye/launch/sample_single.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/hawkeye/include/hawkeye_define.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022, Map IV, Inc.
2 | // All rights reserved.
3 |
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are met:
6 | // * Redistributions of source code must retain the above copyright notice,
7 | // this list of conditions and the following disclaimer.
8 | // * Redistributions in binary form must reproduce the above copyright notice,
9 | // this list of conditions and the following disclaimer in the documentation
10 | // and/or other materials provided with the distribution.
11 | // * Neither the name of the Map IV, Inc. nor the names of its contributors
12 | // may be used to endorse or promote products derived from this software
13 | // without specific prior written permission.
14 |
15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | // DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY
19 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | #pragma once
27 |
28 | #include
29 | #include
30 |
31 | namespace hawkeye
32 | {
33 | using PCPoint_t = pcl::PointXYZI;
34 | using PC_t = pcl::PointCloud;
35 | } // namespace hawkeye
--------------------------------------------------------------------------------
/hawkeye/launch/sample.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/hawkeye/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.0.2)
2 | project(hawkeye)
3 |
4 | set(CMAKE_CXX_STANDARD 17)
5 |
6 | find_package(Boost REQUIRED)
7 | find_package(PCL REQUIRED)
8 | find_package(catkin REQUIRED)
9 | find_package(OpenCV REQUIRED)
10 | pkg_check_modules(YAML_CPP REQUIRED yaml-cpp)
11 | link_directories(${PCL_LIBRARY_DIRS})
12 | link_directories(${OpenCV_LIBRARY_DIRS})
13 | add_definitions(${PCL_DEFINITIONS})
14 | add_definitions(${OpenCV_DEFINITIONS})
15 |
16 | find_package(catkin REQUIRED COMPONENTS
17 | roscpp
18 | std_msgs
19 | nav_msgs
20 | pcl_ros
21 | sensor_msgs
22 | tf2
23 | tf2_ros
24 | tf2_eigen
25 | tf2_geometry_msgs
26 | cv_bridge
27 | )
28 |
29 | catkin_package(
30 | INCLUDE_DIRS include
31 | DEPENDS PCL
32 | DEPENDS OpenCV
33 | )
34 |
35 | include_directories(include
36 | ${catkin_INCLUDE_DIRS}
37 | ${PCL_INCLUDE_DIRS}
38 | ${OpenCV_INCLUDE_DIRS}
39 | ${YAML_CPP_INCLUDE_DIRS}
40 | ${Boost_INCLUDE_DIRS}
41 | )
42 |
43 | set(srcs
44 | src/map/orthomap.cpp
45 | src/map/orthomap_read.cpp
46 | src/util/tf_messages.cpp
47 | src/util/pose_stamped_helper.cpp
48 | )
49 |
50 | set(hawkeye_srcs
51 | src/hawkeye_base/base.cpp
52 | src/hawkeye_base/node.cpp
53 | src/hawkeye_base/config.cpp
54 | )
55 |
56 | # hawkeye_rt
57 | add_executable(hawkeye_rt
58 | ${srcs}
59 | ${hawkeye_srcs}
60 | src/hawkeye_rt/hawkeye_node.cpp
61 | )
62 | target_link_libraries(hawkeye_rt
63 | ${catkin_LIBRARIES}
64 | ${PCL_LIBRARIES}
65 | ${OpenCV_LIBRARIES}
66 | ${YAML_CPP_LIBRARIES}
67 | )
68 | add_dependencies(hawkeye_rt ${catkin_EXPORTED_TARGETS})
69 |
70 | # hawkeye_rt_ws
71 | add_executable(hawkeye_rt_ws
72 | ${srcs}
73 | ${hawkeye_srcs}
74 | src/hawkeye_rt/hawkeye_ws_node.cpp
75 | )
76 | target_link_libraries(hawkeye_rt_ws
77 | ${catkin_LIBRARIES}
78 | ${PCL_LIBRARIES}
79 | ${OpenCV_LIBRARIES}
80 | ${YAML_CPP_LIBRARIES}
81 | )
82 | add_dependencies(hawkeye_rt_ws ${catkin_EXPORTED_TARGETS})
83 |
84 | add_library(${PROJECT_NAME}_lib
85 | ${srcs}
86 | ${hawkeye_srcs}
87 | )
88 |
89 | target_link_libraries(${PROJECT_NAME}_lib
90 | ${catkin_LIBRARIES}
91 | ${PCL_LIBRARIES}
92 | ${OpenCV_LIBRARIES}
93 | ${YAML_CPP_LIBRARIES}
94 | )
95 |
--------------------------------------------------------------------------------
/hawkeye/include/util/error.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022, Map IV, Inc.
2 | // All rights reserved.
3 |
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are met:
6 | // * Redistributions of source code must retain the above copyright notice,
7 | // this list of conditions and the following disclaimer.
8 | // * Redistributions in binary form must reproduce the above copyright notice,
9 | // this list of conditions and the following disclaimer in the documentation
10 | // and/or other materials provided with the distribution.
11 | // * Neither the name of the Map IV, Inc. nor the names of its contributors
12 | // may be used to endorse or promote products derived from this software
13 | // without specific prior written permission.
14 |
15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | // DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY
19 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | #pragma once
27 |
28 | #include
29 | #include
30 | #include
31 |
32 | namespace hawkeye
33 | {
34 | constexpr char ERROR_PREFIX[] = "\033[1;31mError: ";
35 | constexpr char ERROR_SUFFIX[] = "\033[0m";
36 |
37 | inline void exitBadFile(const std::string& filename, const std::string& message = "")
38 | {
39 | if (message.empty())
40 | {
41 | std::cerr << ERROR_PREFIX << "Bad file: " << std::quoted(filename) << ERROR_SUFFIX << std::endl;
42 | }
43 | else
44 | {
45 | std::cerr << ERROR_PREFIX << "Bad file " << std::quoted(filename) << ": " << message << ERROR_SUFFIX << std::endl;
46 | }
47 | exit(2);
48 | }
49 |
50 | inline void exitOpenError(const std::string& filename)
51 | {
52 | std::cerr << ERROR_PREFIX << std::quoted(filename) << " can not be opened." << ERROR_SUFFIX << std::endl;
53 | exit(2);
54 | }
55 | } // namespace hawkeye
--------------------------------------------------------------------------------
/hawkeye/include/util/timer.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022, Map IV, Inc.
2 | // All rights reserved.
3 |
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are met:
6 | // * Redistributions of source code must retain the above copyright notice,
7 | // this list of conditions and the following disclaimer.
8 | // * Redistributions in binary form must reproduce the above copyright notice,
9 | // this list of conditions and the following disclaimer in the documentation
10 | // and/or other materials provided with the distribution.
11 | // * Neither the name of the Map IV, Inc. nor the names of its contributors
12 | // may be used to endorse or promote products derived from this software
13 | // without specific prior written permission.
14 |
15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | // DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY
19 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | namespace hawkeye
31 | {
32 | namespace chrono = std::chrono;
33 |
34 | class Stopwatch
35 | {
36 | public:
37 | Stopwatch() : counter_{ chrono::system_clock::now() }, latest_duration_{ 0 } {};
38 | Stopwatch(const Stopwatch& sw) : counter_{ sw.counter_ }, latest_duration_{ sw.latest_duration_ } {};
39 |
40 | inline double count()
41 | {
42 | auto end = chrono::system_clock::now();
43 | latest_duration_ = chrono::duration_cast(end - counter_).count() / 1000.;
44 | return latest_duration_;
45 | }
46 | inline void reset()
47 | {
48 | counter_ = chrono::system_clock::now();
49 | }
50 | inline double get()
51 | {
52 | return latest_duration_;
53 | }
54 |
55 | private:
56 | chrono::system_clock::time_point counter_;
57 | double latest_duration_;
58 | };
59 |
60 | } // namespace hawkeye
--------------------------------------------------------------------------------
/hawkeye/config/hawkeye.yaml:
--------------------------------------------------------------------------------
1 | hawkeye:
2 | template_size: [192, 192] # size of template image
3 | map_size: [256, 256] # ROI size of ortho image map for template matching
4 | # the size of histogram filter is map_size - template_size + [1,1]
5 | error_rate: 0.01 # alpha in the paper
6 | coeff_diminish: 0.996 # beta in the paper
7 | coeff_weight: 0.07 # k in the paper
8 | coeff_negative: 0.025 # b in the paper
9 | coeff_gain: 0.3 # g in the paper
10 | center_shift_threshold: 0.5 # The threshold for judgement whether the histogram center should shift. Set the real number in [0,1] closed set.
11 | # If 0, the center shifts by any non-zero difference between the center and the estimated pose.
12 | # If 1, the center shifts when the center is out of the histogram range, which means the center never shifts.
13 | edge_copy_shift: false # Parameter for hawkeye_rt
14 | # When the histogram center shifts, points on the histogram edge are newly created.
15 | # If true, those points are initialized by the nearby point. If false, those are initialized by zero.
16 | histogram_weight: 1 # Parameter for hawkeye_rt_ws
17 | # It configures how the histogram weight affects estimation. Set the real number in [0,1] closed set.
18 | # The histogram weight means the upper limmit of each histogram point. This is calculated as histogram, using the the upper limmit of the matching result instead of the match result.
19 | # It is effective when the histogram points newly created at the center shift are smaller due to a lack of accumulation.
20 | # If 0, the weight is ignored. If 1, the values divided by the histogram weight are used in estimation.
21 | lidar_accumulate: # For making template image, LiDAR data are accumulated to satisfy the following two conditions.
22 | max_count: 30 # Size condition: The count of LiDAR data does not exceed the number. If it exceeds while meeting the second condition, one of the closest continuous pair of LiDAR data is removed.
23 | max_length: 20 # Length threshold [m]: If a LiDAR data which position by Eagleye is farther than the threshold from the current pose is removed.
24 | intensity_accumulate_threshold_min: 0 # Correct outlier points of the measured point cloud in intensity to within a specified range.
25 | intensity_accumulate_threshold_max: 0.98 # The upper and lower limits of the range are set as the cumulative distribution of intensity.
26 | stop_threshold: 0.05 # While the displacement from the previous step is less than this parameter, histogram update are stopped.
27 |
28 | # TF from Eagleye to lidar
29 | gnss:
30 | tf_x: 0.0
31 | tf_y: 0.0
32 | tf_z: 0.0
33 | tf_roll: 0.0
34 | tf_pitch: 0.0
35 | tf_yaw: 0.0
--------------------------------------------------------------------------------
/hawkeye/include/hawkeye_base/histogram.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022, Map IV, Inc.
2 | // All rights reserved.
3 |
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are met:
6 | // * Redistributions of source code must retain the above copyright notice,
7 | // this list of conditions and the following disclaimer.
8 | // * Redistributions in binary form must reproduce the above copyright notice,
9 | // this list of conditions and the following disclaimer in the documentation
10 | // and/or other materials provided with the distribution.
11 | // * Neither the name of the Map IV, Inc. nor the names of its contributors
12 | // may be used to endorse or promote products derived from this software
13 | // without specific prior written permission.
14 |
15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | // DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY
19 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | #pragma once
27 |
28 | #include
29 | #include
30 |
31 | #include
32 | #include
33 |
34 | #include "hawkeye_define.hpp"
35 |
36 | namespace hawkeye::hawkeye_base
37 | {
38 | using scale_t = double;
39 | using weight_t = double;
40 | using h_image_t = cv::Mat; // for histogram : CV_64F
41 | using w_image_t = cv::Mat; // for weight : CV_64F
42 | using o_image_t = cv::Mat; // for output : CV_8U
43 |
44 | using template_image_t = std::tuple;
45 | using match_result_t = std::tuple;
46 | using weighted_histogram_t = std::tuple;
47 |
48 | using pose_PC_t = std::pair;
49 |
50 | struct Hawkeye_CopyShiftMode
51 | {
52 | static constexpr bool is_weighted_ = false;
53 | };
54 |
55 | struct Hawkeye_WeightedShiftMode
56 | {
57 | static constexpr bool is_weighted_ = true;
58 | };
59 |
60 | using histogram_t = std::tuple;
61 |
62 | } // namespace hawkeye::hawkeye_base
--------------------------------------------------------------------------------
/hawkeye/include/util/arg.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022, Map IV, Inc.
2 | // All rights reserved.
3 |
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are met:
6 | // * Redistributions of source code must retain the above copyright notice,
7 | // this list of conditions and the following disclaimer.
8 | // * Redistributions in binary form must reproduce the above copyright notice,
9 | // this list of conditions and the following disclaimer in the documentation
10 | // and/or other materials provided with the distribution.
11 | // * Neither the name of the Map IV, Inc. nor the names of its contributors
12 | // may be used to endorse or promote products derived from this software
13 | // without specific prior written permission.
14 |
15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | // DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY
19 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | template
31 | struct argLoader
32 | {
33 | constexpr static bool ty_func_ = std::is_function<_Ty>::value;
34 | using func_type_ = std::conditional_t;
35 |
36 | argLoader(int argc, char** argv, _Ty&& error_exiter)
37 | : argc_{ argc }, argv_{ argv }, i_{ 0 }, error_exiter_{ std::forward<_Ty&&>(error_exiter) } {};
38 |
39 | ~argLoader()
40 | {
41 | end();
42 | }
43 |
44 | bool valid()
45 | {
46 | return i_ < argc_;
47 | }
48 |
49 | int left()
50 | {
51 | return argc_ - i_;
52 | }
53 |
54 | void drop()
55 | {
56 | if (!valid())
57 | err();
58 | ++i_;
59 | }
60 |
61 | char* top()
62 | {
63 | if (!valid())
64 | err();
65 | return argv_[i_];
66 | }
67 |
68 | char* pop()
69 | {
70 | if (!valid())
71 | err();
72 | return argv_[i_++];
73 | }
74 |
75 | void end()
76 | {
77 | if (valid())
78 | err();
79 | }
80 |
81 | void err()
82 | {
83 | error_exiter_("Invalid arguments. argc: " + std::to_string(argc_));
84 | }
85 |
86 | private:
87 | int argc_;
88 | char** argv_;
89 |
90 | func_type_ error_exiter_;
91 | int i_;
92 | };
--------------------------------------------------------------------------------
/hawkeye/include/util/tf_messages.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022, Map IV, Inc.
2 | // All rights reserved.
3 |
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are met:
6 | // * Redistributions of source code must retain the above copyright notice,
7 | // this list of conditions and the following disclaimer.
8 | // * Redistributions in binary form must reproduce the above copyright notice,
9 | // this list of conditions and the following disclaimer in the documentation
10 | // and/or other materials provided with the distribution.
11 | // * Neither the name of the Map IV, Inc. nor the names of its contributors
12 | // may be used to endorse or promote products derived from this software
13 | // without specific prior written permission.
14 |
15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | // DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY
19 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 |
37 | namespace hawkeye
38 | {
39 | template
40 | void tf2_print(Output_& out, const std::string& name, const tf2::Transform& tf)
41 | {
42 | out << name << " :" << std::endl;
43 | out << tf.getOrigin().x() << ' ';
44 | out << tf.getOrigin().y() << ' ';
45 | out << tf.getOrigin().z() << std::endl;
46 | out << tf.getRotation().x() << ' ';
47 | out << tf.getRotation().y() << ' ';
48 | out << tf.getRotation().z() << ' ';
49 | out << tf.getRotation().w() << std::endl;
50 | }
51 |
52 | class TfTrajPublisher
53 | {
54 | public:
55 | TfTrajPublisher(ros::NodeHandle& node) : node_{ node }
56 | {
57 | }
58 |
59 | bool remove(const std::string& frame_target);
60 | bool reset(const std::string& frame_target);
61 |
62 | bool addNewPublisher(const std::string& frame_target, const std::string& topic_name, const std::string& frame_base);
63 |
64 | void broadcastStatic(const std::string& frame_target, const tf2::Transform& tf_tf2, const ros::Time& time,
65 | const std::string& frame_base);
66 | bool broadcast(const std::string& frame_target, const tf2::Transform& tf_tf2, const ros::Time& time);
67 |
68 | private:
69 | ros::NodeHandle& node_;
70 |
71 | using traj_t = std::pair;
72 | tf2_ros::TransformBroadcaster dynamic_broadcaster_;
73 | tf2_ros::StaticTransformBroadcaster static_broadcaster_;
74 | std::map markers_;
75 | };
76 | } // namespace hawkeye
--------------------------------------------------------------------------------
/hawkeye/include/hawkeye_base/node.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022, Map IV, Inc.
2 | // All rights reserved.
3 |
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are met:
6 | // * Redistributions of source code must retain the above copyright notice,
7 | // this list of conditions and the following disclaimer.
8 | // * Redistributions in binary form must reproduce the above copyright notice,
9 | // this list of conditions and the following disclaimer in the documentation
10 | // and/or other materials provided with the distribution.
11 | // * Neither the name of the Map IV, Inc. nor the names of its contributors
12 | // may be used to endorse or promote products derived from this software
13 | // without specific prior written permission.
14 |
15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | // DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY
19 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | #pragma once
27 |
28 | #include
29 |
30 | #include "hawkeye_define.hpp"
31 | #include "hawkeye_base/histogram.hpp"
32 | #include "map/orthomap.hpp"
33 |
34 | namespace hawkeye::hawkeye_base
35 | {
36 | struct HawkeyeConfig
37 | {
38 | cv::Size template_size_;
39 | cv::Size map_size_;
40 | double error_rate_;
41 | double coeff_diminish_;
42 | double coeff_weight_;
43 | double coeff_negative_;
44 | double coeff_gain_;
45 | size_t lidar_accumulate_max_count_;
46 | double lidar_accumulate_max_length_;
47 | tf2::Transform lidar_pose_;
48 | double center_shift_threshold_;
49 | double histogram_weight_; // for Hawkeye_WeightedShiftMode
50 | bool edge_copy_shift_; // for Hawkeye_CopyShiftMode
51 | double intensity_accumulate_threshold_min_;
52 | double intensity_accumulate_threshold_max_;
53 | double stop_threshold_;
54 |
55 | static HawkeyeConfig defaultConfig();
56 | template
57 | void readYamlConfig(const std::string& yaml_filename);
58 | };
59 |
60 | template
61 | class Hawkeye
62 | {
63 | public:
64 | using Config = HawkeyeConfig;
65 |
66 | static Config readYamlConfig(const std::string& yaml_filename);
67 |
68 | Hawkeye(double scale, const Config& config = Config::defaultConfig());
69 |
70 | tf2::Transform shift(const tf2::Transform& pose) const;
71 |
72 | const tf2::Transform& getLidarTf() const;
73 |
74 | tf2::Transform update(const tf2::Transform& pose, const PC_t::Ptr pc_ptr, OrthoMap& map, bool print_info = true);
75 | double getDuration() const
76 | {
77 | return essential_time_;
78 | };
79 |
80 | tf2::Transform getHistogramPeak() const;
81 | tf2::Transform getShftedCenter() const;
82 | tf2::Transform getMatchPeak() const;
83 |
84 | cv::Mat getTemplateImage() const;
85 | cv::Mat getMatchImage() const;
86 | cv::Mat getSubmapImage() const;
87 | cv::Mat getWeightImage() const;
88 |
89 | const visualization_msgs::MarkerArray& getHistogramMarkers(const std_msgs::Header& header, bool as_array = false);
90 |
91 | private:
92 | void adjustPCs();
93 |
94 | private:
95 | histogram_t histogram_;
96 | histogram_t shifted_histogram_;
97 | template_image_t template_image_;
98 | weighted_histogram_t weighted_histogram_;
99 | match_result_t match_result_;
100 | cv::Mat submap_;
101 |
102 | std::list pc_list_;
103 |
104 | cv::Moments moments_;
105 | tf2::Vector3 offset_;
106 | tf2::Vector3 center_shift_;
107 | tf2::Vector3 average_;
108 | tf2::Transform odometry_;
109 | tf2::Transform histogram_center_;
110 |
111 | double essential_time_;
112 | size_t counter_;
113 |
114 | visualization_msgs::MarkerArray marker_array_;
115 |
116 | const Config config_;
117 | const double histogram_weight_;
118 | };
119 |
120 | extern template class Hawkeye;
121 | extern template class Hawkeye;
122 |
123 | } // namespace hawkeye::hawkeye_base
--------------------------------------------------------------------------------
/hawkeye/include/util/pose_stamped_helper.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022, Map IV, Inc.
2 | // All rights reserved.
3 |
4 | // Redistribution and use in source and binary forms, with or without
5 | // modification, are permitted provided that the following conditions are met:
6 | // * Redistributions of source code must retain the above copyright notice,
7 | // this list of conditions and the following disclaimer.
8 | // * Redistributions in binary form must reproduce the above copyright notice,
9 | // this list of conditions and the following disclaimer in the documentation
10 | // and/or other materials provided with the distribution.
11 | // * Neither the name of the Map IV, Inc. nor the names of its contributors
12 | // may be used to endorse or promote products derived from this software
13 | // without specific prior written permission.
14 |
15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | // DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY
19 | // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 | #pragma once
27 |
28 | #include
29 | #include
30 | #include