上传第一版代码

pull/1/head
詹力 2023-12-11 11:51:46 +08:00
commit 36a0da7c29
884 changed files with 98172 additions and 0 deletions

View File

@ -0,0 +1,69 @@
# toplevel CMakeLists.txt for a catkin workspace
# catkin/cmake/toplevel.cmake
cmake_minimum_required(VERSION 3.0.2)
project(Project)
set(CATKIN_TOPLEVEL TRUE)
# search for catkin within the workspace
set(_cmd "catkin_find_pkg" "catkin" "${CMAKE_SOURCE_DIR}")
execute_process(COMMAND ${_cmd}
RESULT_VARIABLE _res
OUTPUT_VARIABLE _out
ERROR_VARIABLE _err
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
)
if(NOT _res EQUAL 0 AND NOT _res EQUAL 2)
# searching fot catkin resulted in an error
string(REPLACE ";" " " _cmd_str "${_cmd}")
message(FATAL_ERROR "Search for 'catkin' in workspace failed (${_cmd_str}): ${_err}")
endif()
# include catkin from workspace or via find_package()
if(_res EQUAL 0)
set(catkin_EXTRAS_DIR "${CMAKE_SOURCE_DIR}/${_out}/cmake")
# include all.cmake without add_subdirectory to let it operate in same scope
include(${catkin_EXTRAS_DIR}/all.cmake NO_POLICY_SCOPE)
add_subdirectory("${_out}")
else()
# use either CMAKE_PREFIX_PATH explicitly passed to CMake as a command line argument
# or CMAKE_PREFIX_PATH from the environment
if(NOT DEFINED CMAKE_PREFIX_PATH)
if(NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "")
if(NOT WIN32)
string(REPLACE ":" ";" CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
else()
set(CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
endif()
endif()
endif()
# list of catkin workspaces
set(catkin_search_path "")
foreach(path ${CMAKE_PREFIX_PATH})
if(EXISTS "${path}/.catkin")
list(FIND catkin_search_path ${path} _index)
if(_index EQUAL -1)
list(APPEND catkin_search_path ${path})
endif()
endif()
endforeach()
# search for catkin in all workspaces
set(CATKIN_TOPLEVEL_FIND_PACKAGE TRUE)
find_package(catkin QUIET
NO_POLICY_SCOPE
PATHS ${catkin_search_path}
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
unset(CATKIN_TOPLEVEL_FIND_PACKAGE)
if(NOT catkin_FOUND)
message(FATAL_ERROR "find_package(catkin) failed. catkin was neither found in the workspace nor in the CMAKE_PREFIX_PATH. One reason may be that no ROS setup.sh was sourced before.")
endif()
endif()
catkin_workspace()

View File

@ -0,0 +1,7 @@
---
platforms:
ubuntu1604:
build_targets:
- "..."
test_targets:
- "..."

View File

@ -0,0 +1,23 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Do an optimized build by default, or otherwise Cartographer cannot run
# real-time and certain tests will timeout.
build -c opt
# By default, an optimized C++ build with Bazel will build each library twice,
# with and without -fPIC. --force_pic avoids the unnecessary actions and
# reduces build time.
build --force_pic

View File

@ -0,0 +1,4 @@
**/Dockerfile*
**/.dockerignore
**/.git
**/.travis.yml

View File

@ -0,0 +1,2 @@
Want to contribute? Great! Make sure you've read and understood
[CONTRIBUTING.md](https://github.com/cartographer-project/cartographer/blob/master/CONTRIBUTING.md).

View File

@ -0,0 +1,2 @@
build
bazel-*

View File

@ -0,0 +1,36 @@
# Copyright 2016 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
sudo: required
services: docker
# Cache intermediate Docker layers. For a description of how this works, see:
# https://giorgos.sealabs.net/docker-cache-on-travis-and-docker-112.html
cache:
directories:
- /home/travis/docker/
env:
- LSB_RELEASE=bionic DOCKER_CACHE_FILE=/home/travis/docker/bionic-cache.tar.gz CC=gcc CXX=g++
- LSB_RELEASE=focal DOCKER_CACHE_FILE=/home/travis/docker/focal-cache.tar.gz CC=gcc CXX=g++
- LSB_RELEASE=stretch DOCKER_CACHE_FILE=/home/travis/docker/stretch-cache.tar.gz CC=gcc CXX=g++
- LSB_RELEASE=buster DOCKER_CACHE_FILE=/home/travis/docker/buster-cache.tar.gz CC=gcc CXX=g++
before_install: scripts/load_docker_cache.sh
install: true
script:
- docker build ${TRAVIS_BUILD_DIR} -t cartographer:${LSB_RELEASE} -f Dockerfile.${LSB_RELEASE}
--build-arg cc=$CC --build-arg cxx=$CXX
- scripts/save_docker_cache.sh

View File

@ -0,0 +1,7 @@
# This is the list of Cartographer authors for copyright purposes.
#
# This does not necessarily list everyone who has contributed code, since in
# some cases, their employer may be the copyright holder. To see the full list
# of contributors, see the revision history in source control.
Google Inc.
and other contributors

View File

@ -0,0 +1,30 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Cartographer is a system that provides real-time simultaneous localization
# and mapping (SLAM) in 2D and 3D across multiple platforms and sensor
# configurations.
licenses(["notice"]) # Apache 2.0
package(default_visibility = ["//visibility:public"])
exports_files(["LICENSE"])
filegroup(
name = "configuration_files",
srcs = glob([
"configuration_files/*.lua",
]),
)

View File

@ -0,0 +1,23 @@
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Changelog for package cartographer
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2.0.0 (2021-03-09)
------------------
https://github.com/cartographer-project/cartographer/compare/1.0.0...2.0.0
1.0.0 (2018-06-01)
------------------
https://github.com/googlecartographer/cartographer/compare/0.3.0...1.0.0
0.3.0 (2017-11-23)
------------------
https://github.com/googlecartographer/cartographer/compare/0.2.0...0.3.0
0.2.0 (2017-06-19)
------------------
https://github.com/googlecartographer/cartographer/compare/0.1.0...0.2.0
0.1.0 (2017-05-18)
------------------
* First unstable development release

View File

@ -0,0 +1,389 @@
# Copyright 2016 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.2)
project(cartographer)
set(CARTOGRAPHER_MAJOR_VERSION 1)
set(CARTOGRAPHER_MINOR_VERSION 0)
set(CARTOGRAPHER_PATCH_VERSION 0)
set(CARTOGRAPHER_VERSION ${CARTOGRAPHER_MAJOR_VERSION}.${CARTOGRAPHER_MINOR_VERSION}.${CARTOGRAPHER_PATCH_VERSION})
set(CARTOGRAPHER_SOVERSION ${CARTOGRAPHER_MAJOR_VERSION}.${CARTOGRAPHER_MINOR_VERSION})
option(BUILD_GRPC "build Cartographer gRPC support" false)
set(CARTOGRAPHER_HAS_GRPC ${BUILD_GRPC})
option(BUILD_PROMETHEUS "build Prometheus monitoring support" false)
include("${PROJECT_SOURCE_DIR}/cmake/functions.cmake")
google_initialize_cartographer_project()
google_enable_testing()
find_package(absl REQUIRED)
set(BOOST_COMPONENTS iostreams)
if(WIN32)
list(APPEND BOOST_COMPONENTS zlib)
set(Boost_USE_STATIC_LIBS FALSE)
endif()
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
find_package(Ceres REQUIRED COMPONENTS SuiteSparse)
find_package(Eigen3 REQUIRED)
find_package(LuaGoogle REQUIRED)
if(WIN32)
# On Windows, Protobuf is incorrectly found by the bundled CMake module, so prefer native CMake config.
set(protobuf_MODULE_COMPATIBLE TRUE CACHE INTERNAL "")
find_package(Protobuf 3.0.0 CONFIG)
else()
find_package(Protobuf 3.0.0 REQUIRED)
endif()
if (${BUILD_GRPC})
find_package(async_grpc REQUIRED)
endif()
if(${BUILD_PROMETHEUS})
find_package( ZLIB REQUIRED )
endif()
include(FindPkgConfig)
if (NOT WIN32)
PKG_SEARCH_MODULE(CAIRO REQUIRED cairo>=1.12.16)
else()
find_library(CAIRO_LIBRARIES cairo)
endif()
# Only build the documentation if we can find Sphinx.
find_package(Sphinx)
if(SPHINX_FOUND)
add_subdirectory("docs")
endif()
# Install catkin package.xml
install(FILES package.xml DESTINATION share/cartographer)
set(CARTOGRAPHER_CONFIGURATION_FILES_DIRECTORY ${CMAKE_INSTALL_PREFIX}/share/cartographer/configuration_files
CACHE PATH ".lua configuration files directory")
install(DIRECTORY configuration_files DESTINATION share/cartographer/)
install(DIRECTORY cmake DESTINATION share/cartographer/)
file(GLOB_RECURSE ALL_LIBRARY_HDRS "cartographer/*.h")
file(GLOB_RECURSE ALL_LIBRARY_SRCS "cartographer/*.cc")
file(GLOB_RECURSE TEST_LIBRARY_HDRS "cartographer/fake_*.h" "cartographer/*test_helpers*.h" "cartographer/mock_*.h")
file(GLOB_RECURSE TEST_LIBRARY_SRCS "cartographer/fake_*.cc" "cartographer/*test_helpers*.cc" "cartographer/mock_*.cc")
file(GLOB_RECURSE ALL_TESTS "cartographer/*_test.cc")
file(GLOB_RECURSE ALL_EXECUTABLES "cartographer/*_main.cc")
# Remove dotfiles/-folders that could potentially pollute the build.
file(GLOB_RECURSE ALL_DOTFILES ".*/*")
if (ALL_DOTFILES)
list(REMOVE_ITEM ALL_LIBRARY_HDRS ${ALL_DOTFILES})
list(REMOVE_ITEM ALL_LIBRARY_SRCS ${ALL_DOTFILES})
list(REMOVE_ITEM TEST_LIBRARY_HDRS ${ALL_DOTFILES})
list(REMOVE_ITEM TEST_LIBRARY_SRCS ${ALL_DOTFILES})
list(REMOVE_ITEM ALL_TESTS ${ALL_DOTFILES})
list(REMOVE_ITEM ALL_EXECUTABLES ${ALL_DOTFILES})
endif()
list(REMOVE_ITEM ALL_LIBRARY_SRCS ${ALL_EXECUTABLES})
list(REMOVE_ITEM ALL_LIBRARY_SRCS ${ALL_TESTS})
list(REMOVE_ITEM ALL_LIBRARY_HDRS ${TEST_LIBRARY_HDRS})
list(REMOVE_ITEM ALL_LIBRARY_SRCS ${TEST_LIBRARY_SRCS})
file(GLOB_RECURSE ALL_GRPC_FILES "cartographer/cloud/*")
file(GLOB_RECURSE ALL_PROMETHEUS_FILES "cartographer/cloud/metrics/prometheus/*")
list(REMOVE_ITEM ALL_GRPC_FILES ${ALL_PROMETHEUS_FILES})
if (NOT ${BUILD_GRPC})
list(REMOVE_ITEM ALL_LIBRARY_HDRS ${ALL_GRPC_FILES})
list(REMOVE_ITEM ALL_LIBRARY_SRCS ${ALL_GRPC_FILES})
list(REMOVE_ITEM TEST_LIBRARY_HDRS ${ALL_GRPC_FILES})
list(REMOVE_ITEM TEST_LIBRARY_SRCS ${ALL_GRPC_FILES})
list(REMOVE_ITEM ALL_TESTS ${ALL_GRPC_FILES})
list(REMOVE_ITEM ALL_EXECUTABLES ${ALL_GRPC_FILES})
endif()
if (NOT ${BUILD_PROMETHEUS})
list(REMOVE_ITEM ALL_LIBRARY_HDRS ${ALL_PROMETHEUS_FILES})
list(REMOVE_ITEM ALL_LIBRARY_SRCS ${ALL_PROMETHEUS_FILES})
list(REMOVE_ITEM TEST_LIBRARY_HDRS ${ALL_PROMETHEUS_FILES})
list(REMOVE_ITEM TEST_LIBRARY_SRCS ${ALL_PROMETHEUS_FILES})
list(REMOVE_ITEM ALL_TESTS ${ALL_PROMETHEUS_FILES})
list(REMOVE_ITEM ALL_EXECUTABLES ${ALL_PROMETHEUS_FILES})
endif()
set(INSTALL_SOURCE_HDRS ${ALL_LIBRARY_HDRS} ${TEST_LIBRARY_HDRS})
file(GLOB_RECURSE INTERNAL_HDRS "cartographer/*/internal/*.h")
list(REMOVE_ITEM INSTALL_SOURCE_HDRS ${INTERNAL_HDRS})
file(GLOB_RECURSE ALL_PROTOS "cartographer/*.proto")
file(GLOB_RECURSE ALL_GRPC_SERVICES "cartographer/*_service.proto")
list(REMOVE_ITEM ALL_PROTOS ALL_GRPC_SERVICES)
if (NOT ${BUILD_GRPC})
list(REMOVE_ITEM ALL_PROTOS ${ALL_GRPC_FILES})
endif()
# TODO(cschuet): Move proto compilation to separate function.
set(ALL_PROTO_SRCS)
set(ALL_PROTO_HDRS)
foreach(ABS_FIL ${ALL_PROTOS})
file(RELATIVE_PATH REL_FIL ${PROJECT_SOURCE_DIR} ${ABS_FIL})
get_filename_component(DIR ${REL_FIL} DIRECTORY)
get_filename_component(FIL_WE ${REL_FIL} NAME_WE)
list(APPEND ALL_PROTO_SRCS "${PROJECT_BINARY_DIR}/${DIR}/${FIL_WE}.pb.cc")
list(APPEND ALL_PROTO_HDRS "${PROJECT_BINARY_DIR}/${DIR}/${FIL_WE}.pb.h")
add_custom_command(
OUTPUT "${PROJECT_BINARY_DIR}/${DIR}/${FIL_WE}.pb.cc"
"${PROJECT_BINARY_DIR}/${DIR}/${FIL_WE}.pb.h"
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
ARGS --cpp_out ${PROJECT_BINARY_DIR} -I
${PROJECT_SOURCE_DIR} ${ABS_FIL}
DEPENDS ${ABS_FIL}
COMMENT "Running C++ protocol buffer compiler on ${ABS_FIL}"
VERBATIM
)
endforeach()
set_source_files_properties(${ALL_PROTO_SRCS} ${ALL_PROTO_HDRS} PROPERTIES GENERATED TRUE)
list(APPEND ALL_LIBRARY_HDRS ${ALL_PROTO_HDRS})
list(APPEND ALL_LIBRARY_SRCS ${ALL_PROTO_SRCS})
if(${BUILD_GRPC})
set(ALL_GRPC_SERVICE_SRCS)
set(ALL_GRPC_SERVICE_HDRS)
foreach(ABS_FIL ${ALL_GRPC_SERVICES})
file(RELATIVE_PATH REL_FIL ${PROJECT_SOURCE_DIR} ${ABS_FIL})
get_filename_component(DIR ${REL_FIL} DIRECTORY)
get_filename_component(FIL_WE ${REL_FIL} NAME_WE)
list(APPEND ALL_GRPC_SERVICE_SRCS "${PROJECT_BINARY_DIR}/${DIR}/${FIL_WE}.pb.cc")
list(APPEND ALL_GRPC_SERVICE_HDRS "${PROJECT_BINARY_DIR}/${DIR}/${FIL_WE}.pb.h")
add_custom_command(
OUTPUT "${PROJECT_BINARY_DIR}/${DIR}/${FIL_WE}.pb.cc"
"${PROJECT_BINARY_DIR}/${DIR}/${FIL_WE}.pb.h"
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
ARGS --cpp_out ${PROJECT_BINARY_DIR}
-I ${PROJECT_SOURCE_DIR}
${ABS_FIL}
DEPENDS ${ABS_FIL}
COMMENT "Running C++ protocol buffer compiler on ${ABS_FIL}"
VERBATIM
)
endforeach()
set_source_files_properties(${ALL_GRPC_SERVICE_SRCS} ${ALL_GRPC_SERVICE_HDRS} PROPERTIES GENERATED TRUE)
list(APPEND ALL_LIBRARY_HDRS ${ALL_GRPC_SERVICE_HDRS})
list(APPEND ALL_LIBRARY_SRCS ${ALL_GRPC_SERVICE_SRCS})
endif()
set(INSTALL_GENERATED_HDRS ${ALL_PROTO_HDRS} ${ALL_GRPC_SERVICE_HDRS})
add_library(${PROJECT_NAME} STATIC ${ALL_LIBRARY_HDRS} ${ALL_LIBRARY_SRCS})
configure_file(
${PROJECT_SOURCE_DIR}/cartographer/common/config.h.cmake
${PROJECT_BINARY_DIR}/cartographer/common/config.h)
google_binary(cartographer_autogenerate_ground_truth
SRCS
cartographer/ground_truth/autogenerate_ground_truth_main.cc
)
google_binary(cartographer_compute_relations_metrics
SRCS
cartographer/ground_truth/compute_relations_metrics_main.cc
)
google_binary(cartographer_pbstream
SRCS
cartographer/io/pbstream_main.cc
)
google_binary(cartographer_print_configuration
SRCS
cartographer/common/print_configuration_main.cc
)
if(${BUILD_GRPC})
google_binary(cartographer_grpc_server
SRCS
cartographer/cloud/map_builder_server_main.cc
)
target_link_libraries(cartographer_grpc_server PUBLIC grpc++)
target_link_libraries(cartographer_grpc_server PUBLIC async_grpc)
if(${BUILD_PROMETHEUS})
target_link_libraries(cartographer_grpc_server PUBLIC ${ZLIB_LIBRARIES})
target_link_libraries(cartographer_grpc_server PUBLIC prometheus-cpp-core)
target_link_libraries(cartographer_grpc_server PUBLIC prometheus-cpp-pull)
endif()
endif()
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
"${EIGEN3_INCLUDE_DIR}")
target_link_libraries(${PROJECT_NAME} PUBLIC ${EIGEN3_LIBRARIES})
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
"${CERES_INCLUDE_DIRS}")
target_link_libraries(${PROJECT_NAME} PUBLIC ${CERES_LIBRARIES})
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
"${LUA_INCLUDE_DIR}")
target_link_libraries(${PROJECT_NAME} PUBLIC ${LUA_LIBRARIES})
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
"${Boost_INCLUDE_DIRS}")
target_link_libraries(${PROJECT_NAME} PUBLIC ${Boost_LIBRARIES})
if (WIN32)
find_package(glog REQUIRED)
set(GLOG_LIBRARY glog::glog)
else()
set(GLOG_LIBRARY glog)
endif()
target_link_libraries(${PROJECT_NAME} PUBLIC ${GLOG_LIBRARY})
target_link_libraries(${PROJECT_NAME} PUBLIC gflags)
if(WIN32)
# Needed to fix conflict with MSVC's error macro.
target_compile_definitions(${PROJECT_NAME} PUBLIC -DGLOG_NO_ABBREVIATED_SEVERITIES)
endif()
if(MSVC)
# Needed for VS 2017 5.8
target_compile_definitions(${PROJECT_NAME} PUBLIC -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_USE_MATH_DEFINES)
endif()
if("${CAIRO_INCLUDE_DIRS}")
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
"${CAIRO_INCLUDE_DIRS}")
endif()
target_link_libraries(${PROJECT_NAME} PUBLIC ${CAIRO_LIBRARIES})
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
${PROTOBUF_INCLUDE_DIR})
# TODO(hrapp): This should not explicitly list pthread and use
# PROTOBUF_LIBRARIES, but that failed on first try.
target_link_libraries(${PROJECT_NAME} PUBLIC ${PROTOBUF_LIBRARY}
absl::algorithm
absl::base
absl::debugging
absl::flat_hash_map
absl::memory
absl::meta
absl::numeric
absl::str_format
absl::strings
absl::synchronization
absl::time
absl::utility
)
if (NOT WIN32)
target_link_libraries(${PROJECT_NAME} PUBLIC pthread)
endif()
if(${BUILD_GRPC})
target_link_libraries(${PROJECT_NAME} PUBLIC grpc++)
target_link_libraries(${PROJECT_NAME} PUBLIC async_grpc)
endif()
if(${BUILD_PROMETHEUS})
target_link_libraries(${PROJECT_NAME} PUBLIC ${ZLIB_LIBRARIES})
target_link_libraries(${PROJECT_NAME} PUBLIC prometheus-cpp-core)
target_link_libraries(${PROJECT_NAME} PUBLIC prometheus-cpp-pull)
target_compile_definitions(${PROJECT_NAME} PUBLIC USE_PROMETHEUS=1)
endif()
set(TARGET_COMPILE_FLAGS "${TARGET_COMPILE_FLAGS} ${GOOG_CXX_FLAGS}")
set_target_properties(${PROJECT_NAME} PROPERTIES
COMPILE_FLAGS ${TARGET_COMPILE_FLAGS})
set(TEST_LIB
cartographer_test_library
)
add_library(${TEST_LIB} ${TEST_LIBRARY_HDRS} ${TEST_LIBRARY_SRCS})
target_include_directories(${TEST_LIB} SYSTEM PRIVATE
"${GMOCK_INCLUDE_DIRS}")
# Needed for dynamically linked GTest on Windows.
if (WIN32)
target_compile_definitions(${TEST_LIB} PUBLIC -DGTEST_LINKED_AS_SHARED_LIBRARY)
endif()
target_link_libraries(${TEST_LIB} PUBLIC ${GMOCK_LIBRARY})
target_link_libraries(${TEST_LIB} PUBLIC ${PROJECT_NAME})
set_target_properties(${TEST_LIB} PROPERTIES
COMPILE_FLAGS ${TARGET_COMPILE_FLAGS})
foreach(ABS_FIL ${ALL_TESTS})
file(RELATIVE_PATH REL_FIL ${PROJECT_SOURCE_DIR} ${ABS_FIL})
get_filename_component(DIR ${REL_FIL} DIRECTORY)
get_filename_component(FIL_WE ${REL_FIL} NAME_WE)
# Replace slashes as required for CMP0037.
string(REPLACE "/" "." TEST_TARGET_NAME "${DIR}/${FIL_WE}")
google_test("${TEST_TARGET_NAME}" ${ABS_FIL})
if(${BUILD_GRPC})
target_link_libraries("${TEST_TARGET_NAME}" PUBLIC grpc++)
target_link_libraries("${TEST_TARGET_NAME}" PUBLIC async_grpc)
endif()
if(${BUILD_PROMETHEUS})
target_link_libraries("${TEST_TARGET_NAME}" PUBLIC ${ZLIB_LIBRARIES})
target_link_libraries("${TEST_TARGET_NAME}" PUBLIC prometheus-cpp-core)
target_link_libraries("${TEST_TARGET_NAME}" PUBLIC prometheus-cpp-pull)
endif()
target_link_libraries("${TEST_TARGET_NAME}" PUBLIC ${TEST_LIB})
endforeach()
# Add the binary directory first, so that port.h is included after it has
# been generated.
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
install(
TARGETS ${PROJECT_NAME}
EXPORT CartographerExport
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
foreach(HDR ${INSTALL_SOURCE_HDRS})
file(RELATIVE_PATH REL_FIL ${PROJECT_SOURCE_DIR} ${HDR})
get_filename_component(DIR ${REL_FIL} DIRECTORY)
install(
FILES ${HDR}
DESTINATION include/${DIR}
)
endforeach()
foreach(HDR ${INSTALL_GENERATED_HDRS})
file(RELATIVE_PATH REL_FIL ${PROJECT_BINARY_DIR} ${HDR})
get_filename_component(DIR ${REL_FIL} DIRECTORY)
install(
FILES ${HDR}
DESTINATION include/${DIR}
)
endforeach()
set(CARTOGRAPHER_CMAKE_DIR share/cartographer/cmake)
include(CMakePackageConfigHelpers)
configure_package_config_file(
cartographer-config.cmake.in
${PROJECT_BINARY_DIR}/cmake/cartographer/cartographer-config.cmake
PATH_VARS CARTOGRAPHER_CMAKE_DIR
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/cartographer
)
install(
EXPORT CartographerExport
DESTINATION share/cartographer/cmake/
FILE CartographerTargets.cmake
)
install(
FILES ${PROJECT_BINARY_DIR}/cmake/cartographer/cartographer-config.cmake
DESTINATION share/cartographer/
)

View File

@ -0,0 +1,51 @@
Want to contribute? Great! First, read this page.
### Before you contribute
Any contribution that you make to this repository will
be under the Apache 2 License, as dictated by that
[license](http://www.apache.org/licenses/LICENSE-2.0):
```
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
```
### Developer Certificate of Origin
Contributors must sign-off each commit by adding a `Signed-off-by: ...`
line to commit messages to certify that they have the right to submit
the code they are contributing to the project according to the
[Developer Certificate of Origin (DCO)](https://developercertificate.org/).
You can sign-off a commit via `git commit -s`.
### Code reviews
All submissions, including submissions by project members, require review.
We use GitHub pull requests for this purpose. Make sure you've read,
understood and considered all the points below before creating your PR.
#### Style guide
C++ code should adhere to the
[Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html).
You can handle the formatting part of the style guide via `git clang-format`.
#### Best practices
When preparing your PR and also during the code review make sure to follow
[best practices](https://google.github.io/eng-practices/review/developer/).
Most importantly, keep your PR under 200 lines of code and address a single
concern.
#### Testing
- Add unit tests and documentation (these do not count toward your 200 lines).
- Run `ninja test` or `catkin_make_isolated --install --use-ninja --pkg cartographer --make-args test` as appropriate.
- Keep rebasing (or merging) of master branch to a minimum. It triggers Travis
runs for every update which blocks merging of other changes.

View File

@ -0,0 +1,41 @@
# Copyright 2020 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM ubuntu:bionic
ARG cc
ARG cxx
# Set the preferred C/C++ compiler toolchain, if given (otherwise default).
ENV CC=$cc
ENV CXX=$cxx
# This base image doesn't ship with sudo, apt-utils. tzdata is installed here to avoid hanging later
# when it would wait for user input.
RUN apt-get update && apt-get install -y sudo apt-utils tzdata && rm -rf /var/lib/apt/lists/*
COPY scripts/install_debs_cmake.sh cartographer/scripts/
RUN cartographer/scripts/install_debs_cmake.sh && rm -rf /var/lib/apt/lists/*
COPY scripts/install_abseil.sh cartographer/scripts/
RUN cartographer/scripts/install_abseil.sh && rm -rf /var/lib/apt/lists/*
COPY scripts/install_proto3.sh cartographer/scripts/
RUN cartographer/scripts/install_proto3.sh && rm -rf protobuf
COPY scripts/install_grpc.sh cartographer/scripts/
RUN cartographer/scripts/install_grpc.sh && rm -rf grpc
COPY scripts/install_async_grpc.sh cartographer/scripts/
RUN cartographer/scripts/install_async_grpc.sh && rm -rf async_grpc
COPY scripts/install_prometheus_cpp.sh cartographer/scripts/
RUN cartographer/scripts/install_prometheus_cpp.sh && rm -rf prometheus-cpp
COPY . cartographer
RUN cartographer/scripts/install_cartographer_cmake_with_grpc.sh && rm -rf cartographer

View File

@ -0,0 +1,32 @@
# Copyright 2020 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM debian:buster
ARG cc
ARG cxx
# Set the preferred C/C++ compiler toolchain, if given (otherwise default).
ENV CC=$cc
ENV CXX=$cxx
# This base image doesn't ship with sudo.
RUN apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/*
COPY scripts/install_debs_cmake.sh cartographer/scripts/
RUN cartographer/scripts/install_debs_cmake.sh && rm -rf /var/lib/apt/lists/*
COPY scripts/install_abseil.sh cartographer/scripts/
RUN cartographer/scripts/install_abseil.sh && rm -rf /var/lib/apt/lists/*
COPY . cartographer
RUN cartographer/scripts/install_cartographer_cmake.sh && rm -rf cartographer

View File

@ -0,0 +1,33 @@
# Copyright 2020 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM ubuntu:focal
ARG cc
ARG cxx
# Set the preferred C/C++ compiler toolchain, if given (otherwise default).
ENV CC=$cc
ENV CXX=$cxx
# This base image doesn't ship with sudo, apt-utils. tzdata is installed here to avoid hanging later
# when it would wait for user input.
RUN apt-get update && apt-get install -y sudo apt-utils tzdata && rm -rf /var/lib/apt/lists/*
COPY scripts/install_debs_cmake.sh cartographer/scripts/
RUN cartographer/scripts/install_debs_cmake.sh && rm -rf /var/lib/apt/lists/*
COPY scripts/install_abseil.sh cartographer/scripts/
RUN cartographer/scripts/install_abseil.sh && rm -rf /var/lib/apt/lists/*
COPY . cartographer
RUN cartographer/scripts/install_cartographer_cmake.sh && rm -rf cartographer

View File

@ -0,0 +1,36 @@
# Copyright 2016 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM debian:stretch
ARG cc
ARG cxx
# Set the preferred C/C++ compiler toolchain, if given (otherwise default).
ENV CC=$cc
ENV CXX=$cxx
# This base image doesn't ship with sudo.
RUN apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/*
COPY scripts/install_debs_cmake.sh cartographer/scripts/
RUN cartographer/scripts/install_debs_cmake.sh && rm -rf /var/lib/apt/lists/*
COPY scripts/install_abseil.sh cartographer/scripts/
RUN cartographer/scripts/install_abseil.sh && rm -rf /var/lib/apt/lists/*
COPY scripts/install_ceres.sh cartographer/scripts/
RUN cartographer/scripts/install_ceres.sh && rm -rf ceres-solver
COPY scripts/install_proto3.sh cartographer/scripts/
RUN cartographer/scripts/install_proto3.sh && rm -rf protobuf
COPY . cartographer
RUN cartographer/scripts/install_cartographer_cmake.sh && rm -rf cartographer

View File

@ -0,0 +1,27 @@
# Copyright 2016 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
FROM ubuntu:trusty
ARG cc
ARG cxx
# Set the preferred C/C++ compiler toolchain, if given (otherwise default).
ENV CC=$cc
ENV CXX=$cxx
COPY scripts/install_debs_bazel.sh cartographer/scripts/
RUN cartographer/scripts/install_debs_bazel.sh && rm -rf /var/lib/apt/lists/*
COPY . cartographer
RUN cartographer/scripts/install_cartographer_bazel.sh && rm -rf cartographer

View File

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,101 @@
.. Copyright 2016 The Cartographer Authors
.. Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
.. http://www.apache.org/licenses/LICENSE-2.0
.. Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
============
Cartographer
============
|build| |docs| |license|
Purpose
=======
`Cartographer`_ is a system that provides real-time simultaneous localization
and mapping (`SLAM`_) in 2D and 3D across multiple platforms and sensor
configurations.
|video|
.. _Cartographer: https://github.com/cartographer-project/cartographer
.. _SLAM: https://en.wikipedia.org/wiki/Simultaneous_localization_and_mapping
Getting started
===============
* Learn to use Cartographer at `our Read the Docs site`_.
* You can ask a question by `creating an issue`_.
.. _our Read the Docs site: https://google-cartographer.readthedocs.io
.. _creating an issue: https://github.com/cartographer-project/cartographer_ros/issues/new?labels=question
Contributing
============
You can find information about contributing to Cartographer at `our Contribution
page`_.
.. _our Contribution page: https://github.com/cartographer-project/cartographer/blob/master/CONTRIBUTING.md
Open house slide archive
========================
In the past there had been regular open-for-all meetings to discuss progress and plans for Cartographer.
Slides of these Cartographer Open House meetings are listed below.
- March 14, 2019: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/190314/slides.pdf>`_
- February 21, 2019: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/190221/slides.pdf>`_
- January 17, 2019: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/190117/slides.pdf>`_
- November 22, 2018: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/181122/slides.pdf>`_
- October 25, 2018: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/181025/slides.pdf>`_
- September 13, 2018: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/180913/slides.pdf>`_
- August 16, 2018: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/180816/slides.pdf>`_
- August 2, 2018: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/180802/slides.pdf>`_
- July 5, 2018: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/180705/slides.pdf>`_
- June 21, 2018: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/180621/slides.pdf>`_
- June 7, 2018: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/180607/slides.pdf>`_
- May 24, 2018: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/180524/slides.pdf>`_
- May 3, 2018: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/180503/slides.pdf>`_
- March 29, 2018: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/180329/slides.pdf>`_
- February 22, 2018: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/180222/slides.pdf>`_
- February 8, 2018: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/180208/slides.pdf>`_
- January 18, 2018: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/180125/slides.pdf>`_
- January 11, 2018: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/180111/slides.pdf>`_
- December 7, 2017: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/171207/slides.pdf>`_
- November 23, 2017: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/171123/slides.pdf>`_
- November 9, 2017: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/171109/slides.pdf>`_
- October 26, 2017: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/171026/slides.pdf>`_
- October 12, 2017: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/171012/slides.pdf>`_
- September 14, 2017: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/170914/slides.pdf>`_
- August 17, 2017: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/170817/slides.pdf>`_
- July 20, 2017: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/170720/slides.pdf>`_
- July 6, 2017: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/170706/slides.pdf>`_
- June 22, 2017: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/170622/sildes.pdf>`_
- June 8, 2017: `Slides <https://storage.googleapis.com/cartographer-public-data/cartographer-open-house/170608/slides.pdf>`_
.. |build| image:: https://travis-ci.org/cartographer-project/cartographer.svg?branch=master
:alt: Build Status
:scale: 100%
:target: https://travis-ci.org/cartographer-project/cartographer
.. |docs| image:: https://readthedocs.org/projects/google-cartographer/badge/?version=latest
:alt: Documentation Status
:scale: 100%
:target: https://google-cartographer.readthedocs.io/en/latest/?badge=latest
.. |license| image:: https://img.shields.io/badge/License-Apache%202.0-blue.svg
:alt: Apache 2 license.
:scale: 100%
:target: https://github.com/cartographer-project/cartographer/blob/master/LICENSE
.. |video| image:: https://j.gifs.com/wp3BJM.gif
:alt: Cartographer 3D SLAM Demo
:scale: 100%
:target: https://youtu.be/DM0dpHLhtX0

View File

@ -0,0 +1,15 @@
Steps for Releasing
-------------------
.. code-block:: bash
catkin_generate_changelog
* Update changelog to point to GitHub release log (e.g.
https://github.com/cartographer-project/cartographer/compare/0.1.0...0.2.0)
.. code-block:: bash
git commit -am"Update changelog for release"
catkin_prepare_release --bump minor --no-push
* Create PR
* Add release via GitHub web UI

View File

@ -0,0 +1,33 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
workspace(name = "com_github_googlecartographer_cartographer")
load("//:bazel/repositories.bzl", "cartographer_repositories")
cartographer_repositories()
# This can't be inside cartographer_repositories() because of:
# https://github.com/bazelbuild/bazel/issues/1550
load("@com_github_nelhage_rules_boost//:boost/boost.bzl", "boost_deps")
boost_deps()
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
grpc_deps()
load("@com_github_jupp0r_prometheus_cpp//:repositories.bzl", "prometheus_cpp_repositories")
prometheus_cpp_repositories()

View File

@ -0,0 +1,60 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
jobs:
- job: Build
pool:
vmImage: 'vs2017-win2016'
timeoutInMinutes: 360
steps:
- script: |
choco sources add -n=roswin -s https://aka.ms/ros/public --priority 1
rem Azure VM runs out of space on C:, so use D: for ros and rosdeps
mkdir D:\opt && mklink /J C:\opt D:\opt
choco upgrade %ROS_METAPACKAGE% -y
robocopy "." ".\src\cartographer" /E /MOVE /XD "src" > NUL
call "C:\opt\ros\melodic\x64\env.bat" rosdep install --from-paths src --ignore-src -r -y
env:
ROS_METAPACKAGE: 'ros-melodic-desktop'
displayName: Install prerequisites
- script: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
call "C:\opt\ros\melodic\x64\setup.bat"
call src\cartographer\scripts\remove_mingw_cygwin_from_path.bat
catkin_make_isolated --use-ninja --install
displayName: Build
- script: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
call "C:\opt\ros\melodic\x64\setup.bat"
call src\cartographer\scripts\remove_mingw_cygwin_from_path.bat
cd build_isolated\cartographer\install && ctest --no-compress-output -T Test
displayName: Run tests
- script: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
call "C:\opt\ros\melodic\x64\setup.bat"
call src\cartographer\scripts\remove_mingw_cygwin_from_path.bat
python src\cartographer\scripts\ctest_to_junit.py build_isolated\cartographer\install
displayName: Convert tests to jUnit
condition: always()
- task: PublishTestResults@2
displayName: Publish test results
inputs:
testRunner: 'jUnit'
testResultsFiles: '**\jUnit.xml'
searchFolder: '$(Build.SourcesDirectory)\build_isolated\cartographer\install\Testing'
condition: always()

View File

@ -0,0 +1,302 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""External dependencies for Cartographer."""
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
def cartographer_repositories():
_maybe(
http_archive,
name = "com_github_nelhage_rules_boost",
sha256 = "371f49e7b29e44a718baf8b9a2dd3eca865005a851c9ecf8fb6a10a715aa58dd",
strip_prefix = "rules_boost-a5a95642f6097f8949020646ffe89d7243008981",
urls = [
"https://mirror.bazel.build/github.com/nelhage/rules_boost/archive/a5a95642f6097f8949020646ffe89d7243008981.tar.gz",
"https://github.com/nelhage/rules_boost/archive/a5a95642f6097f8949020646ffe89d7243008981.tar.gz",
],
)
_maybe(
http_archive,
name = "com_github_antonovvk_bazel_rules",
sha256 = "2f5327a2dc9a0cc8ead93953a5d2ae2e0308aece685e46cc89c27538a7e9a73a",
strip_prefix = "bazel_rules-c76e47ebe6f0a03b9dd99e245d5a0611813c36f9",
urls = [
"https://github.com/drigz/bazel_rules/archive/c76e47ebe6f0a03b9dd99e245d5a0611813c36f9.tar.gz",
],
)
_maybe(
http_archive,
name = "com_github_gflags_gflags",
sha256 = "6e16c8bc91b1310a44f3965e616383dbda48f83e8c1eaa2370a215057b00cabe",
strip_prefix = "gflags-77592648e3f3be87d6c7123eb81cbad75f9aef5a",
urls = [
"https://mirror.bazel.build/github.com/gflags/gflags/archive/77592648e3f3be87d6c7123eb81cbad75f9aef5a.tar.gz",
"https://github.com/gflags/gflags/archive/77592648e3f3be87d6c7123eb81cbad75f9aef5a.tar.gz",
],
)
_maybe(
http_archive,
name = "com_google_glog",
sha256 = "dfc074b41a5b86fc5dda4f0e2e2d6cc5b21f798c9fcc8ed5fea9c8f7c4613be6",
strip_prefix = "glog-dd2b93d761a19860190cb3fa92066c8031e912e3",
urls = [
"https://mirror.bazel.build/github.com/google/glog/archive/dd2b93d761a19860190cb3fa92066c8031e912e3.tar.gz",
"https://github.com/google/glog/archive/dd2b93d761a19860190cb3fa92066c8031e912e3.tar.gz",
],
)
_maybe(
http_archive,
name = "net_zlib_zlib",
sha256 = "6d4d6640ca3121620995ee255945161821218752b551a1a180f4215f7d124d45",
build_file = "@com_github_googlecartographer_cartographer//bazel/third_party:zlib.BUILD",
strip_prefix = "zlib-cacf7f1d4e3d44d871b605da3b647f07d718623f",
urls = [
"https://mirror.bazel.build/github.com/madler/zlib/archive/cacf7f1d4e3d44d871b605da3b647f07d718623f.tar.gz",
"https://github.com/madler/zlib/archive/cacf7f1d4e3d44d871b605da3b647f07d718623f.tar.gz",
],
)
_maybe(
http_archive,
name = "org_cairographics_pixman",
build_file = "@com_github_googlecartographer_cartographer//bazel/third_party/pixman:pixman.BUILD",
sha256 = "21b6b249b51c6800dc9553b65106e1e37d0e25df942c90531d4c3997aa20a88e",
strip_prefix = "pixman-0.34.0",
urls = [
"https://mirror.bazel.build/www.cairographics.org/releases/pixman-0.34.0.tar.gz",
"https://www.cairographics.org/releases/pixman-0.34.0.tar.gz",
],
)
_maybe(
http_archive,
name = "org_cairographics_cairo",
build_file = "@com_github_googlecartographer_cartographer//bazel/third_party/cairo:cairo.BUILD",
sha256 = "7e87878658f2c9951a14fc64114d4958c0e65ac47530b8ac3078b2ce41b66a09",
strip_prefix = "cairo-1.14.10",
urls = [
"https://mirror.bazel.build/www.cairographics.org/releases/cairo-1.14.10.tar.xz",
"https://www.cairographics.org/releases/cairo-1.14.10.tar.xz",
],
)
_maybe(
http_archive,
name = "org_freetype_freetype2",
build_file = "@com_github_googlecartographer_cartographer//bazel/third_party:freetype2.BUILD",
sha256 = "33a28fabac471891d0523033e99c0005b95e5618dc8ffa7fa47f9dadcacb1c9b",
strip_prefix = "freetype-2.8",
urls = [
"https://mirror.bazel.build/download.savannah.gnu.org/releases/freetype/freetype-2.8.tar.gz",
"http://download.savannah.gnu.org/releases/freetype/freetype-2.8.tar.gz",
],
)
_maybe(
http_archive,
name = "org_libgd_libgd",
build_file = "@com_github_googlecartographer_cartographer//bazel/third_party:gd.BUILD",
sha256 = "a66111c9b4a04e818e9e2a37d7ae8d4aae0939a100a36b0ffb52c706a09074b5",
strip_prefix = "libgd-2.2.5",
urls = [
"https://mirror.bazel.build/github.com/libgd/libgd/releases/download/gd-2.2.5/libgd-2.2.5.tar.gz",
"https://github.com/libgd/libgd/releases/download/gd-2.2.5/libgd-2.2.5.tar.gz",
],
)
_maybe(
http_archive,
name = "org_freedesktop_fontconfig",
build_file = "@com_github_googlecartographer_cartographer//bazel/third_party/fontconfig:fontconfig.BUILD",
sha256 = "fd5a6a663f4c4a00e196523902626654dd0c4a78686cbc6e472f338e50fdf806",
strip_prefix = "fontconfig-2.12.4",
urls = [
"https://mirror.bazel.build/www.freedesktop.org/software/fontconfig/release/fontconfig-2.12.4.tar.gz",
"https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.12.4.tar.gz",
],
)
_maybe(
http_archive,
name = "org_ceres_solver_ceres_solver",
build_file = "@com_github_googlecartographer_cartographer//bazel/third_party:ceres.BUILD",
sha256 = "ede5b4205ee8d7c7e029e9da74c7ee759fee6961f7e6bfa694274e4a55b8c7ca",
strip_prefix = "ceres-solver-58c5edae2f7c4d2533fe8a975c1f5f0b892dfd3e",
urls = [
"https://mirror.bazel.build/github.com/ceres-solver/ceres-solver/archive/58c5edae2f7c4d2533fe8a975c1f5f0b892dfd3e.tar.gz",
"https://github.com/ceres-solver/ceres-solver/archive/58c5edae2f7c4d2533fe8a975c1f5f0b892dfd3e.tar.gz",
],
)
_maybe(
http_archive,
name = "org_tuxfamily_eigen",
build_file = "@com_github_googlecartographer_cartographer//bazel/third_party:eigen.BUILD",
sha256 = "ca7beac153d4059c02c8fc59816c82d54ea47fe58365e8aded4082ded0b820c4",
strip_prefix = "eigen-eigen-f3a22f35b044",
urls = [
"http://mirror.bazel.build/bitbucket.org/eigen/eigen/get/f3a22f35b044.tar.gz",
"https://bitbucket.org/eigen/eigen/get/f3a22f35b044.tar.gz",
],
)
_maybe(
http_archive,
name = "com_github_libexpat_libexpat",
build_file = "@com_github_googlecartographer_cartographer//bazel/third_party:expat.BUILD",
sha256 = "b5dcb503e40f615a0296a18acc6d975f2f1a3d01c7b3a4b3bb69de27bc9475c3",
strip_prefix = "libexpat-R_2_2_4/expat",
urls = [
"https://mirror.bazel.build/github.com/libexpat/libexpat/archive/R_2_2_4.tar.gz",
"https://github.com/libexpat/libexpat/archive/R_2_2_4.tar.gz",
],
)
_maybe(
http_archive,
name = "libjpeg",
build_file = "@com_github_googlecartographer_cartographer//bazel/third_party:libjpeg.BUILD",
sha256 = "240fd398da741669bf3c90366f58452ea59041cacc741a489b99f2f6a0bad052",
strip_prefix = "jpeg-9b",
urls = [
"https://mirror.bazel.build/www.ijg.org/files/jpegsrc.v9b.tar.gz",
"http://www.ijg.org/files/jpegsrc.v9b.tar.gz",
],
)
_maybe(
http_archive,
name = "org_libpng_libpng",
build_file = "@com_github_googlecartographer_cartographer//bazel/third_party:libpng.BUILD",
sha256 = "7f415186d38ca71c23058386d7cf5135c8beda821ee1beecdc2a7a26c0356615",
strip_prefix = "libpng-1.2.57",
urls = [
"https://mirror.bazel.build/github.com/glennrp/libpng/archive/v1.2.57.tar.gz",
"https://github.com/glennrp/libpng/archive/v1.2.57.tar.gz",
],
)
_maybe(
http_archive,
name = "com_google_googletest",
sha256 = "c18f281fd6621bb264570b99860a0241939b4a251c9b1af709b811d33bc63af8",
strip_prefix = "googletest-e3bd4cbeaeef3cee65a68a8bd3c535cb779e9b6d",
urls = [
"https://mirror.bazel.build/github.com/google/googletest/archive/e3bd4cbeaeef3cee65a68a8bd3c535cb779e9b6d.tar.gz",
"https://github.com/google/googletest/archive/e3bd4cbeaeef3cee65a68a8bd3c535cb779e9b6d.tar.gz",
],
)
_maybe(
http_archive,
name = "bazel_skylib",
sha256 = "e5d90f0ec952883d56747b7604e2a15ee36e288bb556c3d0ed33e818a4d971f2",
strip_prefix = "bazel-skylib-1.0.2",
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/1.0.2.tar.gz"],
)
_maybe(
http_archive,
name = "com_google_protobuf",
sha256 = "1c744a6a1f2c901e68c5521bc275e22bdc66256eeb605c2781923365b7087e5f",
strip_prefix = "protobuf-3.13.0",
urls = [
"https://mirror.bazel.build/github.com/google/protobuf/archive/v3.13.0.zip",
"https://github.com/google/protobuf/archive/v3.13.0.zip",
],
repo_mapping = {"@zlib": "@net_zlib_zlib"},
)
_maybe(
http_archive,
name = "org_lua_lua",
build_file = "@com_github_googlecartographer_cartographer//bazel/third_party:lua.BUILD",
sha256 = "b9e2e4aad6789b3b63a056d442f7b39f0ecfca3ae0f1fc0ae4e9614401b69f4b",
strip_prefix = "lua-5.2.4",
urls = [
"https://mirror.bazel.build/www.lua.org/ftp/lua-5.2.4.tar.gz",
"https://www.lua.org/ftp/lua-5.2.4.tar.gz",
],
)
_maybe(
http_archive,
name = "com_github_grpc_grpc",
sha256 = "f869c648090e8bddaa1260a271b1089caccbe735bf47ac9cd7d44d35a02fb129",
strip_prefix = "grpc-1.19.1",
urls = [
"https://mirror.bazel.build/github.com/grpc/grpc/archive/v1.19.1.tar.gz",
"https://github.com/grpc/grpc/archive/v1.19.1.tar.gz",
],
)
_maybe(
http_archive,
name = "com_github_jupp0r_prometheus_cpp",
sha256 = "07a704819cb90ed619cbf1a2713ba39faab27b8898b4561cc11a3c8b3ace83ea",
strip_prefix = "prometheus-cpp-4b11ee7a0aa7157494df06c4a324bf6d11bd0eec",
urls = [
"https://github.com/jupp0r/prometheus-cpp/archive/4b11ee7a0aa7157494df06c4a324bf6d11bd0eec.tar.gz",
],
)
_maybe(
http_archive,
name = "com_github_googlecartographer_async_grpc",
sha256 = "83c2a27c92979787f38810adc4b6bb67aa09607c53dbadca3430a5f29e0a1cd3",
strip_prefix = "async_grpc-771af45374af7f7bfc3b622ed7efbe29a4aba403",
urls = [
"https://github.com/cartographer-project/async_grpc/archive/771af45374af7f7bfc3b622ed7efbe29a4aba403.tar.gz",
],
)
_maybe(
http_archive,
name = "com_google_absl",
sha256 = "c8ba586a9ab12bc4a67bb419fc0d2146200942b072bac95f50490f977b7fb04f",
strip_prefix = "abseil-cpp-5441bbe1db5d0f2ca24b5b60166367b0966790af",
urls = ["https://github.com/abseil/abseil-cpp/archive/5441bbe1db5d0f2ca24b5b60166367b0966790af.tar.gz"],
)
_maybe(
http_archive,
name = "rules_python",
sha256 = "e5470e92a18aa51830db99a4d9c492cc613761d5bdb7131c04bd92b9834380f6",
strip_prefix = "rules_python-4b84ad270387a7c439ebdccfd530e2339601ef27",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_python/archive/4b84ad270387a7c439ebdccfd530e2339601ef27.tar.gz",
"https://github.com/bazelbuild/rules_python/archive/4b84ad270387a7c439ebdccfd530e2339601ef27.tar.gz",
],
)
# TODO(rodrigoq): remove these binds once grpc#14140 has been merged, as well
# as removing `use_external` in cartographer_grpc/BUILD.bazel.
# https://github.com/grpc/grpc/pull/14140
native.bind(
name = "grpc_cpp_plugin",
actual = "@com_github_grpc_grpc//:grpc_cpp_plugin",
)
native.bind(
name = "grpc++_codegen_proto",
actual = "@com_github_grpc_grpc//:grpc++_codegen_proto",
)
def _maybe(repo_rule, name, **kwargs):
if name not in native.existing_rules():
repo_rule(name = name, **kwargs)

View File

@ -0,0 +1,22 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Bazel build support for third-party packages.
licenses(["notice"]) # Apache 2.0
exports_files(
glob(["*.BUILD"]),
visibility = ["//visibility:public"],
)

View File

@ -0,0 +1,26 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Files required for building Cairo with Bazel.
licenses(["notice"])
exports_files(
[
"cairo.BUILD",
"config.h",
"cairo-features.h",
],
visibility = ["//visibility:public"],
)

View File

@ -0,0 +1,50 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CAIRO_FEATURES_H
#define CAIRO_FEATURES_H
#define CAIRO_HAS_FC_FONT 1
#define CAIRO_HAS_FT_FONT 1
#define CAIRO_HAS_GOBJECT_FUNCTIONS 1
#define CAIRO_HAS_IMAGE_SURFACE 1
#define CAIRO_HAS_MIME_SURFACE 1
#define CAIRO_HAS_OBSERVER_SURFACE 1
#define CAIRO_HAS_PDF_SURFACE 1
#define CAIRO_HAS_PNG_FUNCTIONS 1
#define CAIRO_HAS_PS_SURFACE 1
#define CAIRO_HAS_RECORDING_SURFACE 1
#define CAIRO_HAS_SCRIPT_SURFACE 1
#define CAIRO_HAS_SVG_SURFACE 1
#define CAIRO_HAS_TEE_SURFACE 1
#define CAIRO_HAS_USER_FONT 1
#define CAIRO_HAS_GIF_FUNCTIONS 1
#define CAIRO_HAS_JPEG_FUNCTIONS 1
/*#undef CAIRO_HAS_EGL_FUNCTIONS */
/*#undef CAIRO_HAS_GLX_FUNCTIONS */
/*#undef CAIRO_HAS_QUARTZ_FONT */
/*#undef CAIRO_HAS_QUARTZ_SURFACE */
/*#undef CAIRO_HAS_WGL_FUNCTIONS */
/*#undef CAIRO_HAS_WIN32_FONT */
/*#undef CAIRO_HAS_WIN32_SURFACE */
/*#undef CAIRO_HAS_XCB_SHM_FUNCTIONS */
/*#undef CAIRO_HAS_XCB_SURFACE */
/*#undef CAIRO_HAS_XLIB_SURFACE */
/*#undef CAIRO_HAS_XLIB_XRENDER_SURFACE */
#endif

View File

@ -0,0 +1,304 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Description:
# Cairo is a 2D graphics library with support for multiple output devices.
licenses(["reciprocal"]) # MPL 1.1
genrule(
name = "config_h",
srcs = ["@com_github_googlecartographer_cartographer//bazel/third_party/cairo:config.h"],
outs = ["cairo_internal/config.h"],
cmd = "cp $< $@",
)
genrule(
name = "cairo_features_h",
srcs = ["@com_github_googlecartographer_cartographer//bazel/third_party/cairo:cairo-features.h"],
outs = ["src/cairo-features.h"],
cmd = "cp $< $@",
)
cc_library(
name = "cairo",
srcs = [
"cairo-version.h",
"cairo_internal/config.h",
"src/cairo.c",
"src/cairo.h",
"src/cairo-analysis-surface.c",
"src/cairo-analysis-surface-private.h",
"src/cairo-arc.c",
"src/cairo-arc-private.h",
"src/cairo-array.c",
"src/cairo-array-private.h",
"src/cairo-atomic.c",
"src/cairo-atomic-private.h",
"src/cairo-backend-private.h",
"src/cairo-base64-stream.c",
"src/cairo-base85-stream.c",
"src/cairo-bentley-ottmann.c",
"src/cairo-bentley-ottmann-rectangular.c",
"src/cairo-bentley-ottmann-rectilinear.c",
"src/cairo-botor-scan-converter.c",
"src/cairo-box-inline.h",
"src/cairo-boxes.c",
"src/cairo-boxes-intersect.c",
"src/cairo-boxes-private.h",
"src/cairo-cache.c",
"src/cairo-cache-private.h",
"src/cairo-cff-subset.c",
"src/cairo-clip.c",
"src/cairo-clip-boxes.c",
"src/cairo-clip-inline.h",
"src/cairo-clip-polygon.c",
"src/cairo-clip-private.h",
"src/cairo-clip-region.c",
"src/cairo-clip-surface.c",
"src/cairo-clip-tor-scan-converter.c",
"src/cairo-color.c",
"src/cairo-combsort-inline.h",
"src/cairo-compiler-private.h",
"src/cairo-composite-rectangles.c",
"src/cairo-composite-rectangles-private.h",
"src/cairo-compositor.c",
"src/cairo-compositor-private.h",
"src/cairo-contour.c",
"src/cairo-contour-inline.h",
"src/cairo-contour-private.h",
"src/cairo-damage.c",
"src/cairo-damage-private.h",
"src/cairo-debug.c",
"src/cairo-default-context.c",
"src/cairo-default-context-private.h",
"src/cairo-deflate-stream.c",
"src/cairo-deprecated.h",
"src/cairo-device.c",
"src/cairo-device-private.h",
"src/cairo-error.c",
"src/cairo-error-private.h",
"src/cairo-fallback-compositor.c",
"src/cairo-features.h",
"src/cairo-fixed.c",
"src/cairo-fixed-private.h",
"src/cairo-fixed-type-private.h",
"src/cairo-font-face.c",
"src/cairo-font-face-twin.c",
"src/cairo-font-face-twin-data.c",
"src/cairo-font-options.c",
"src/cairo-fontconfig-private.h",
"src/cairo-freed-pool.c",
"src/cairo-freed-pool-private.h",
"src/cairo-freelist.c",
"src/cairo-freelist-private.h",
"src/cairo-freelist-type-private.h",
"src/cairo-ft.h",
"src/cairo-ft-font.c",
"src/cairo-ft-private.h",
"src/cairo-gstate.c",
"src/cairo-gstate-private.h",
"src/cairo-hash.c",
"src/cairo-hash-private.h",
"src/cairo-hull.c",
"src/cairo-image-compositor.c",
"src/cairo-image-info.c",
"src/cairo-image-info-private.h",
"src/cairo-image-source.c",
"src/cairo-image-surface.c",
"src/cairo-image-surface-inline.h",
"src/cairo-image-surface-private.h",
"src/cairo-line.c",
"src/cairo-line-inline.h",
"src/cairo-line-private.h",
"src/cairo-list-inline.h",
"src/cairo-list-private.h",
"src/cairo-lzw.c",
"src/cairo-malloc-private.h",
"src/cairo-mask-compositor.c",
"src/cairo-matrix.c",
"src/cairo-mempool.c",
"src/cairo-mempool-private.h",
"src/cairo-mesh-pattern-rasterizer.c",
"src/cairo-misc.c",
"src/cairo-mono-scan-converter.c",
"src/cairo-mutex.c",
"src/cairo-mutex-impl-private.h",
"src/cairo-mutex-list-private.h",
"src/cairo-mutex-private.h",
"src/cairo-mutex-type-private.h",
"src/cairo-no-compositor.c",
"src/cairo-observer.c",
"src/cairo-output-stream.c",
"src/cairo-output-stream-private.h",
"src/cairo-paginated-private.h",
"src/cairo-paginated-surface.c",
"src/cairo-paginated-surface-private.h",
"src/cairo-path.c",
"src/cairo-path-bounds.c",
"src/cairo-path-fill.c",
"src/cairo-path-fixed.c",
"src/cairo-path-fixed-private.h",
"src/cairo-path-in-fill.c",
"src/cairo-path-private.h",
"src/cairo-path-stroke.c",
"src/cairo-path-stroke-boxes.c",
"src/cairo-path-stroke-polygon.c",
"src/cairo-path-stroke-traps.c",
"src/cairo-path-stroke-tristrip.c",
"src/cairo-pattern.c",
"src/cairo-pattern-inline.h",
"src/cairo-pattern-private.h",
"src/cairo-pdf.h",
"src/cairo-pdf-operators.c",
"src/cairo-pdf-operators-private.h",
"src/cairo-pdf-shading.c",
"src/cairo-pdf-shading-private.h",
"src/cairo-pdf-surface.c",
"src/cairo-pdf-surface-private.h",
"src/cairo-pen.c",
"src/cairo-pixman-private.h",
"src/cairo-png.c",
"src/cairo-polygon.c",
"src/cairo-polygon-intersect.c",
"src/cairo-polygon-reduce.c",
"src/cairo-private.h",
"src/cairo-ps.h",
"src/cairo-ps-surface.c",
"src/cairo-ps-surface-private.h",
"src/cairo-raster-source-pattern.c",
"src/cairo-recording-surface.c",
"src/cairo-recording-surface-inline.h",
"src/cairo-recording-surface-private.h",
"src/cairo-rectangle.c",
"src/cairo-rectangular-scan-converter.c",
"src/cairo-reference-count-private.h",
"src/cairo-region.c",
"src/cairo-region-private.h",
"src/cairo-rtree.c",
"src/cairo-rtree-private.h",
"src/cairo-scaled-font.c",
"src/cairo-scaled-font-private.h",
"src/cairo-scaled-font-subsets.c",
"src/cairo-scaled-font-subsets-private.h",
"src/cairo-script.h",
"src/cairo-script-private.h",
"src/cairo-script-surface.c",
"src/cairo-shape-mask-compositor.c",
"src/cairo-slope.c",
"src/cairo-slope-private.h",
"src/cairo-spans.c",
"src/cairo-spans-compositor.c",
"src/cairo-spans-compositor-private.h",
"src/cairo-spans-private.h",
"src/cairo-spline.c",
"src/cairo-stroke-dash.c",
"src/cairo-stroke-dash-private.h",
"src/cairo-stroke-style.c",
"src/cairo-surface.c",
"src/cairo-surface-backend-private.h",
"src/cairo-surface-clipper.c",
"src/cairo-surface-clipper-private.h",
"src/cairo-surface-fallback.c",
"src/cairo-surface-fallback-private.h",
"src/cairo-surface-inline.h",
"src/cairo-surface-observer.c",
"src/cairo-surface-observer-inline.h",
"src/cairo-surface-observer-private.h",
"src/cairo-surface-offset.c",
"src/cairo-surface-offset-private.h",
"src/cairo-surface-private.h",
"src/cairo-surface-snapshot.c",
"src/cairo-surface-snapshot-inline.h",
"src/cairo-surface-snapshot-private.h",
"src/cairo-surface-subsurface.c",
"src/cairo-surface-subsurface-inline.h",
"src/cairo-surface-subsurface-private.h",
"src/cairo-surface-wrapper.c",
"src/cairo-surface-wrapper-private.h",
"src/cairo-svg.h",
"src/cairo-svg-surface.c",
"src/cairo-svg-surface-private.h",
"src/cairo-tee.h",
"src/cairo-tee-surface.c",
"src/cairo-tee-surface-private.h",
"src/cairo-time.c",
"src/cairo-time-private.h",
"src/cairo-tor-scan-converter.c",
"src/cairo-tor22-scan-converter.c",
"src/cairo-toy-font-face.c",
"src/cairo-traps.c",
"src/cairo-traps-compositor.c",
"src/cairo-traps-private.h",
"src/cairo-tristrip.c",
"src/cairo-tristrip-private.h",
"src/cairo-truetype-subset.c",
"src/cairo-truetype-subset-private.h",
"src/cairo-type1-fallback.c",
"src/cairo-type1-glyph-names.c",
"src/cairo-type1-private.h",
"src/cairo-type1-subset.c",
"src/cairo-type3-glyph-surface.c",
"src/cairo-type3-glyph-surface-private.h",
"src/cairo-types-private.h",
"src/cairo-unicode.c",
"src/cairo-user-font.c",
"src/cairo-user-font-private.h",
"src/cairo-version.c",
"src/cairo-version.h",
"src/cairo-wideint.c",
"src/cairo-wideint-private.h",
"src/cairo-wideint-type-private.h",
"src/cairoint.h",
],
hdrs = [
"src/cairo.h",
"src/cairo-deprecated.h",
"src/cairo-features.h",
"src/cairo-version.h",
],
copts = [
"-DHAVE_CONFIG_H",
"-D_REENTRANT",
"-Wno-attributes",
"-Wno-cpp",
"-Wno-int-in-bool-context",
"-Wno-maybe-uninitialized",
"-Wno-misleading-indentation",
"-Wno-strict-aliasing",
"-Wno-unused-but-set-variable",
"-Wno-unused-function",
"-I$(GENDIR)/external/org_cairographics_cairo/src",
"-I$(GENDIR)/external/org_cairographics_cairo/cairo_internal",
"-DCAIRO_HAS_XLIB_SURFACE=1", # Only effect is to create xlib display mutex
],
include_prefix = "cairo",
linkopts = [
"-lpthread",
"-lrt",
"-lm",
],
strip_include_prefix = "src",
visibility = ["//visibility:public"],
deps = [
"@com_github_libexpat_libexpat//:expat",
"@libjpeg//:jpeg",
"@net_zlib_zlib//:zlib",
"@org_cairographics_pixman//:pixman",
"@org_freedesktop_fontconfig//:fontconfig",
"@org_freetype_freetype2//:freetype2",
"@org_libgd_libgd//:gd",
"@org_libpng_libpng//:libpng",
],
)

View File

@ -0,0 +1,428 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Define if building universal (internal helper macro) */
/* #undef AC_APPLE_UNIVERSAL_BUILD */
/* whether memory barriers are needed around atomic operations */
/* #undef ATOMIC_OP_NEEDS_MEMORY_BARRIER */
/* Define to 1 if the PDF backend can be tested (need poppler and other
dependencies for pdf2png) */
/* #undef CAIRO_CAN_TEST_PDF_SURFACE */
/* Define to 1 if the PS backend can be tested (needs ghostscript) */
#define CAIRO_CAN_TEST_PS_SURFACE 1
/* Define to 1 if the SVG backend can be tested */
/* #undef CAIRO_CAN_TEST_SVG_SURFACE */
/* Define to 1 if the Win32 Printing backend can be tested (needs ghostscript)
*/
/* #undef CAIRO_CAN_TEST_WIN32_PRINTING_SURFACE */
/* Define to 1 if dlsym is available */
#define CAIRO_HAS_DLSYM 1
/* Define to 1 to enable cairo's cairo-script-interpreter feature */
/* #undef CAIRO_HAS_INTERPRETER */
/* Define to 1 to enable cairo's pthread feature */
#define CAIRO_HAS_PTHREAD 1
/* Define to 1 if we have full pthread support */
#define CAIRO_HAS_REAL_PTHREAD 1
/* Define to 1 if libspectre is available */
/* #undef CAIRO_HAS_SPECTRE */
/* Define to 1 to enable cairo's symbol-lookup feature */
/* #undef CAIRO_HAS_SYMBOL_LOOKUP */
/* Define to 1 to enable cairo's test surfaces feature */
/* #undef CAIRO_HAS_TEST_SURFACES */
/* Define to 1 to enable cairo's cairo-trace feature */
/* #undef CAIRO_HAS_TRACE */
/* Define to 1 to disable certain code paths that rely heavily on double
precision floating-point calculation */
/* #undef DISABLE_SOME_FLOATING_POINT */
/* Define to 1 if your system stores words within floats with the most
significant word first */
/* #undef FLOAT_WORDS_BIGENDIAN */
/* Enable pixman glyph cache */
#define HAS_PIXMAN_GLYPHS 1
/* Define to 1 if you have the `alarm' function. */
#define HAVE_ALARM 1
/* Define to 1 if you have the binutils development files installed */
/* #undef HAVE_BFD */
/* Define to 1 if your compiler supports the __builtin_return_address()
intrinsic. */
#define HAVE_BUILTIN_RETURN_ADDRESS 1
/* Define to 1 if you have the <byteswap.h> header file. */
#define HAVE_BYTESWAP_H 1
/* Define to 1 if you have the `clock_gettime' function. */
#define HAVE_CLOCK_GETTIME 1
/* Define to 1 if you have the `ctime_r' function. */
#define HAVE_CTIME_R 1
/* Enable if your compiler supports the GCC __atomic_* atomic primitives */
#define HAVE_CXX11_ATOMIC_PRIMITIVES 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define to 1 if you have the `drand48' function. */
#define HAVE_DRAND48 1
/* Define to 1 if you have the `FcFini' function. */
/* #undef HAVE_FCFINI */
/* Define to 1 if you have the `FcInit' function. */
/* #undef HAVE_FCINIT */
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define to 1 if you have the `feclearexcept' function. */
#define HAVE_FECLEAREXCEPT 1
/* Define to 1 if you have the `fedisableexcept' function. */
#define HAVE_FEDISABLEEXCEPT 1
/* Define to 1 if you have the `feenableexcept' function. */
#define HAVE_FEENABLEEXCEPT 1
/* Define to 1 if you have the <fenv.h> header file. */
#define HAVE_FENV_H 1
/* Define to 1 if you have the `flockfile' function. */
#define HAVE_FLOCKFILE 1
/* Define to 1 if you have the `fork' function. */
#define HAVE_FORK 1
/* Define to 1 if you have the `FT_Get_X11_Font_Format' function. */
#define HAVE_FT_GET_X11_FONT_FORMAT 1
/* Define to 1 if you have the `FT_GlyphSlot_Embolden' function. */
#define HAVE_FT_GLYPHSLOT_EMBOLDEN 1
/* Define to 1 if you have the `FT_GlyphSlot_Oblique' function. */
#define HAVE_FT_GLYPHSLOT_OBLIQUE 1
/* Define to 1 if you have the `FT_Library_SetLcdFilter' function. */
#define HAVE_FT_LIBRARY_SETLCDFILTER 1
/* Define to 1 if you have the `FT_Load_Sfnt_Table' function. */
#define HAVE_FT_LOAD_SFNT_TABLE 1
/* Define to 1 if you have the `funlockfile' function. */
#define HAVE_FUNLOCKFILE 1
/* Whether you have gcov */
/* #undef HAVE_GCOV */
/* Define to 1 if you have the `getline' function. */
#define HAVE_GETLINE 1
/* Enable if your compiler supports the Intel __sync_* atomic primitives */
/* #undef HAVE_INTEL_ATOMIC_PRIMITIVES */
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <io.h> header file. */
/* #undef HAVE_IO_H */
/* Define to 1 if you have the <libgen.h> header file. */
#define HAVE_LIBGEN_H 1
/* Define to 1 if you have the `rt' library (-lrt). */
#define HAVE_LIBRT 1
/* Enable if you have libatomic-ops-dev installed */
/* #undef HAVE_LIB_ATOMIC_OPS */
/* Define to 1 if you have the `link' function. */
#define HAVE_LINK 1
/* Define to 1 if you have the Valgrind lockdep tool */
/* #undef HAVE_LOCKDEP */
/* Define to 1 if you have lzo available */
/* #undef HAVE_LZO */
/* Define to 1 if you have the Valgrind memfault tool */
/* #undef HAVE_MEMFAULT */
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to non-zero if your system has mkdir, and to 2 if your version of
mkdir requires a mode parameter */
#define HAVE_MKDIR 2
/* Define to 1 if you have the `mmap' function. */
#define HAVE_MMAP 1
/* Enable if you have MacOS X atomic operations */
/* #undef HAVE_OS_ATOMIC_OPS */
/* Define to 1 if you have the `poppler_page_render' function. */
/* #undef HAVE_POPPLER_PAGE_RENDER */
/* Define to 1 if you have the `raise' function. */
#define HAVE_RAISE 1
/* Define to 1 if you have the `rsvg_pixbuf_from_file' function. */
/* #undef HAVE_RSVG_PIXBUF_FROM_FILE */
/* Define to 1 if you have the `sched_getaffinity' function. */
#define HAVE_SCHED_GETAFFINITY 1
/* Define to 1 if you have the <sched.h> header file. */
#define HAVE_SCHED_H 1
/* Define to 1 if you have the <setjmp.h> header file. */
#define HAVE_SETJMP_H 1
/* Define to 1 if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the `strndup' function. */
#define HAVE_STRNDUP 1
/* Define to 1 if you have the <sys/int_types.h> header file. */
/* #undef HAVE_SYS_INT_TYPES_H */
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#define HAVE_SYS_IOCTL_H 1
/* Define to 1 if you have the <sys/mman.h> header file. */
#define HAVE_SYS_MMAN_H 1
/* Define to 1 if you have the <sys/poll.h> header file. */
#define HAVE_SYS_POLL_H 1
/* Define to 1 if you have the <sys/socket.h> header file. */
#define HAVE_SYS_SOCKET_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <sys/un.h> header file. */
#define HAVE_SYS_UN_H 1
/* Define to 1 if you have the <sys/wait.h> header file. */
#define HAVE_SYS_WAIT_H 1
/* Define to 1 if you have the <time.h> header file. */
#define HAVE_TIME_H 1
/* Define to 1 if the system has the type `uint128_t'. */
/* #undef HAVE_UINT128_T */
/* Define to 1 if the system has the type `uint64_t'. */
#define HAVE_UINT64_T 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have Valgrind */
/* #undef HAVE_VALGRIND */
/* Define to 1 if you have the `waitpid' function. */
#define HAVE_WAITPID 1
/* Define to 1 if you have the <windows.h> header file. */
/* #undef HAVE_WINDOWS_H */
/* Define to 1 if you have the <X11/extensions/shmproto.h> header file. */
/* #undef HAVE_X11_EXTENSIONS_SHMPROTO_H */
/* Define to 1 if you have the <X11/extensions/shmstr.h> header file. */
/* #undef HAVE_X11_EXTENSIONS_SHMSTR_H */
/* Define to 1 if you have the <X11/extensions/XShm.h> header file. */
/* #undef HAVE_X11_EXTENSIONS_XSHM_H */
/* Define to 1 if you have the `XRenderCreateConicalGradient' function. */
/* #undef HAVE_XRENDERCREATECONICALGRADIENT */
/* Define to 1 if you have the `XRenderCreateLinearGradient' function. */
/* #undef HAVE_XRENDERCREATELINEARGRADIENT */
/* Define to 1 if you have the `XRenderCreateRadialGradient' function. */
/* #undef HAVE_XRENDERCREATERADIALGRADIENT */
/* Define to 1 if you have zlib available */
#define HAVE_ZLIB 1
/* Define to 1 if the system has the type `__uint128_t'. */
#define HAVE___UINT128_T 1
/* Define to 1 if shared memory segments are released deferred. */
/* #undef IPC_RMID_DEFERRED_RELEASE */
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
/* #undef NO_MINUS_C_MINUS_O */
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT \
"http://bugs.freedesktop.org/enter_bug.cgi?product=cairo"
/* Define to the full name of this package. */
#define PACKAGE_NAME USE_cairo_INSTEAD
/* Define to the full name and version of this package. */
#define PACKAGE_STRING USE_cairo_version_OR_cairo_version_string_INSTEAD
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME USE_cairo_INSTEAD
/* Define to the home page for this package. */
#define PACKAGE_URL "http://cairographics.org/"
/* Define to the version of this package. */
#define PACKAGE_VERSION USE_cairo_version_OR_cairo_version_string_INSTEAD
/* Shared library file extension */
#define SHARED_LIB_EXT "so"
/* The size of `int', as computed by sizeof. */
#define SIZEOF_INT 4
/* The size of `long', as computed by sizeof. */
#define SIZEOF_LONG 8
/* The size of `long long', as computed by sizeof. */
#define SIZEOF_LONG_LONG 8
/* The size of `size_t', as computed by sizeof. */
#define SIZEOF_SIZE_T 8
/* The size of `void *', as computed by sizeof. */
#define SIZEOF_VOID_P 8
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
#define _ALL_SOURCE 1
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
#define _POSIX_PTHREAD_SEMANTICS 1
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
#define _TANDEM_SOURCE 1
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
#define __EXTENSIONS__ 1
#endif
/* Define to the value your compiler uses to support the warn-unused-result
attribute */
#define WARN_UNUSED_RESULT
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
#if defined __BIG_ENDIAN__
#define WORDS_BIGENDIAN 1
#endif
#else
#ifndef WORDS_BIGENDIAN
/* # undef WORDS_BIGENDIAN */
#endif
#endif
/* Deal with multiple architecture compiles on Mac OS X */
#ifdef __APPLE_CC__
#ifdef __BIG_ENDIAN__
#define WORDS_BIGENDIAN 1
#define FLOAT_WORDS_BIGENDIAN 1
#else
/* #undef WORDS_BIGENDIAN */
/* #undef FLOAT_WORDS_BIGENDIAN */
#endif
#endif
/* Define to 1 if the X Window System is missing or not being used. */
/* #undef X_DISPLAY_MISSING */
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
#define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS */
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */
/* Define to 1 if on MINIX. */
/* #undef _MINIX */
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
/* #undef _POSIX_1_SOURCE */
/* Define to 1 if you need to in order for `stat' and other things to work. */
/* #undef _POSIX_SOURCE */
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif

View File

@ -0,0 +1,164 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Description:
# Ceres Solver is an open source C++ library for modeling and solving large,
# complicated optimization problems.
licenses(["notice"]) # New BSD, portions MIT.
CERES_DEFINES = [
"CERES_USE_CXX11",
"CERES_USE_EIGEN_SPARSE",
"CERES_NO_SUITESPARSE",
"CERES_NO_LAPACK",
"CERES_NO_CXSPARSE",
"CERES_STD_UNORDERED_MAP",
"CERES_USE_CXX11_THREADS",
# Use the internal mutex code. Not ideal, but it works.
"CERES_HAVE_PTHREAD",
"CERES_HAVE_RWLOCK",
]
cc_library(
name = "ceres",
srcs = [
"internal/ceres/array_utils.cc",
"internal/ceres/blas.cc",
"internal/ceres/block_evaluate_preparer.cc",
"internal/ceres/block_jacobi_preconditioner.cc",
"internal/ceres/block_jacobian_writer.cc",
"internal/ceres/block_random_access_dense_matrix.cc",
"internal/ceres/block_random_access_diagonal_matrix.cc",
"internal/ceres/block_random_access_matrix.cc",
"internal/ceres/block_random_access_sparse_matrix.cc",
"internal/ceres/block_sparse_matrix.cc",
"internal/ceres/block_structure.cc",
"internal/ceres/callbacks.cc",
"internal/ceres/c_api.cc",
"internal/ceres/canonical_views_clustering.cc",
"internal/ceres/cgnr_solver.cc",
"internal/ceres/coordinate_descent_minimizer.cc",
"internal/ceres/compressed_col_sparse_matrix_utils.cc",
"internal/ceres/compressed_row_jacobian_writer.cc",
"internal/ceres/compressed_row_sparse_matrix.cc",
"internal/ceres/conditioned_cost_function.cc",
"internal/ceres/conjugate_gradients_solver.cc",
"internal/ceres/context_impl.cc",
"internal/ceres/corrector.cc",
"internal/ceres/covariance.cc",
"internal/ceres/covariance_impl.cc",
"internal/ceres/dense_normal_cholesky_solver.cc",
"internal/ceres/dense_qr_solver.cc",
"internal/ceres/dense_sparse_matrix.cc",
"internal/ceres/detect_structure.cc",
"internal/ceres/dogleg_strategy.cc",
"internal/ceres/dynamic_compressed_row_jacobian_writer.cc",
"internal/ceres/dynamic_compressed_row_sparse_matrix.cc",
"internal/ceres/dynamic_sparse_normal_cholesky_solver.cc",
"internal/ceres/eigensparse.cc",
"internal/ceres/evaluator.cc",
"internal/ceres/file.cc",
"internal/ceres/function_sample.cc",
"internal/ceres/gradient_checker.cc",
"internal/ceres/gradient_checking_cost_function.cc",
"internal/ceres/gradient_problem.cc",
"internal/ceres/gradient_problem_solver.cc",
"internal/ceres/implicit_schur_complement.cc",
"internal/ceres/inner_product_computer.cc",
"internal/ceres/is_close.cc",
"internal/ceres/iterative_refiner.cc",
"internal/ceres/iterative_schur_complement_solver.cc",
"internal/ceres/lapack.cc",
"internal/ceres/levenberg_marquardt_strategy.cc",
"internal/ceres/line_search.cc",
"internal/ceres/line_search_direction.cc",
"internal/ceres/line_search_minimizer.cc",
"internal/ceres/line_search_preprocessor.cc",
"internal/ceres/linear_least_squares_problems.cc",
"internal/ceres/linear_operator.cc",
"internal/ceres/linear_solver.cc",
"internal/ceres/local_parameterization.cc",
"internal/ceres/loss_function.cc",
"internal/ceres/low_rank_inverse_hessian.cc",
"internal/ceres/minimizer.cc",
"internal/ceres/normal_prior.cc",
"internal/ceres/parallel_for_cxx.cc",
"internal/ceres/parameter_block_ordering.cc",
"internal/ceres/partitioned_matrix_view.cc",
"internal/ceres/polynomial.cc",
"internal/ceres/preconditioner.cc",
"internal/ceres/preprocessor.cc",
"internal/ceres/problem.cc",
"internal/ceres/problem_impl.cc",
"internal/ceres/program.cc",
"internal/ceres/reorder_program.cc",
"internal/ceres/residual_block.cc",
"internal/ceres/residual_block_utils.cc",
"internal/ceres/schur_complement_solver.cc",
"internal/ceres/schur_eliminator.cc",
"internal/ceres/schur_jacobi_preconditioner.cc",
"internal/ceres/schur_templates.cc",
"internal/ceres/scratch_evaluate_preparer.cc",
"internal/ceres/single_linkage_clustering.cc",
"internal/ceres/solver.cc",
"internal/ceres/solver_utils.cc",
"internal/ceres/sparse_cholesky.cc",
"internal/ceres/sparse_matrix.cc",
"internal/ceres/sparse_normal_cholesky_solver.cc",
"internal/ceres/split.cc",
"internal/ceres/stringprintf.cc",
"internal/ceres/suitesparse.cc",
"internal/ceres/thread_pool.cc",
"internal/ceres/thread_token_provider.cc",
"internal/ceres/trust_region_minimizer.cc",
"internal/ceres/trust_region_preprocessor.cc",
"internal/ceres/trust_region_step_evaluator.cc",
"internal/ceres/trust_region_strategy.cc",
"internal/ceres/triplet_sparse_matrix.cc",
"internal/ceres/types.cc",
"internal/ceres/visibility_based_preconditioner.cc",
"internal/ceres/visibility.cc",
"internal/ceres/wall_time.cc",
] + glob([
"internal/ceres/generated/schur_eliminator_*.cc",
"internal/ceres/generated/partitioned_matrix_view_*.cc",
"config/**/*.h",
"internal/**/*.h",
]),
hdrs = glob([
"include/ceres/*.h",
"include/ceres/internal/*.h",
]),
copts = [
"-fopenmp",
"-Wno-sign-compare",
],
defines = CERES_DEFINES,
includes = [
"config",
"include",
"internal",
],
linkopts = [
"-lgomp",
],
linkstatic = 1,
visibility = ["//visibility:public"],
deps = [
"@com_google_glog//:glog",
"@org_tuxfamily_eigen//:eigen",
],
)

View File

@ -0,0 +1,56 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Description:
# Eigen is a C++ template library for linear algebra: vectors,
# matrices, and related algorithms.
licenses([
# Note: Eigen is an MPL2 library that includes GPL v3 and LGPL v2.1+ code.
# We've taken special care to not reference any restricted code.
"reciprocal", # MPL2
"notice", # Portions BSD
])
exports_files(["COPYING.MPL2"])
EIGEN_FILES = [
"Eigen/**",
"unsupported/Eigen/CXX11/**",
"unsupported/Eigen/FFT",
"unsupported/Eigen/KroneckerProduct",
"unsupported/Eigen/src/FFT/**",
"unsupported/Eigen/src/KroneckerProduct/**",
"unsupported/Eigen/MatrixFunctions",
"unsupported/Eigen/SpecialFunctions",
"unsupported/Eigen/src/MatrixFunctions/**",
"unsupported/Eigen/src/SpecialFunctions/**",
]
# List of files picked up by glob but actually part of another target.
EIGEN_EXCLUDE_FILES = [
"Eigen/src/Core/arch/AVX/PacketMathGoogleTest.cc",
]
EIGEN_MPL2_HEADER_FILES = glob(
EIGEN_FILES,
exclude = EIGEN_EXCLUDE_FILES,
)
cc_library(
name = "eigen",
hdrs = EIGEN_MPL2_HEADER_FILES,
includes = ["."],
visibility = ["//visibility:public"],
)

View File

@ -0,0 +1,93 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Description:
# Expat is an XML parser library written in C.
licenses(["notice"]) # MIT-style
load("@com_github_antonovvk_bazel_rules//:config.bzl", "cc_fix_config")
cc_fix_config(
name = "expat_config_h",
cmake = True,
files = {"expat_config.h.cmake": "expat_config.h"},
values = {
"BYTEORDER": "1234",
"HAVE_BCOPY": "1",
"HAVE_DLFCN": "1",
"HAVE_FCNTL_H": "1",
"HAVE_GETPAGESIZE": "1",
"HAVE_INTTYPES_H": "1",
"HAVE_MEMMOVE": "1",
"HAVE_MEMORY_H": "1",
"HAVE_STDINT_H": "1",
"HAVE_STDLIB_H": "1",
"HAVE_STRINGS_H": "1",
"HAVE_STRING_H": "1",
"HAVE_SYS_PARAM_H": "1",
"HAVE_SYS_STAT_H": "1",
"HAVE_SYS_TYPES_H": "1",
"HAVE_UNISTD_H": "1",
"LT_OBJDIR": "\".libs/\"",
"PACKAGE_BUGREPORT": "expat-bugs@libexpat.org",
"PACKAGE_NAME": "expat",
"PACKAGE_STRING": "expat 2.2.4",
"PACKAGE_TARNAME": "expat",
"PACKAGE_URL": "",
"PACKAGE_VERSION": "2.2.4",
"STDC_HEADERS": "1",
"XML_CONTEXT_BYTES": "1024",
"XML_DTD": "1",
"XML_NS": "1",
},
)
# TODO(rodrigoq): review if we're exposing more headers than users need.
cc_library(
name = "expat",
srcs = [
"lib/xmlparse.c",
"lib/xmlrole.c",
"lib/xmltok.c",
],
hdrs = [
"expat_config.h",
"lib/ascii.h",
"lib/asciitab.h",
"lib/expat.h",
"lib/expat_external.h",
"lib/iasciitab.h",
"lib/internal.h",
"lib/latin1tab.h",
"lib/nametab.h",
"lib/siphash.h",
"lib/utf8tab.h",
"lib/xmlrole.h",
"lib/xmltok.h",
"lib/xmltok_impl.c",
"lib/xmltok_impl.h",
"lib/xmltok_ns.c",
],
copts = [
"-DHAVE_EXPAT_CONFIG_H",
"-DXML_DEV_URANDOM",
],
defines = ["XML_STATIC"],
includes = [
".",
"lib",
],
visibility = ["//visibility:public"],
)

View File

@ -0,0 +1,25 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Files required for building Fontconfig with Bazel.
licenses(["notice"])
exports_files(
[
"fontconfig.BUILD",
"config.h",
],
visibility = ["//visibility:public"],
)

View File

@ -0,0 +1,372 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Define if building universal (internal helper macro) */
/* #undef AC_APPLE_UNIVERSAL_BUILD */
/* The normal alignment of `double', in bytes. */
#define ALIGNOF_DOUBLE 8
/* The normal alignment of `void *', in bytes. */
#define ALIGNOF_VOID_P 8
/* Use libxml2 instead of Expat */
/* #undef ENABLE_LIBXML2 */
/* Additional font directories */
#define FC_ADD_FONTS "yes"
/* Architecture prefix to use for cache file names */
#define FC_ARCHITECTURE "elf64-x86-64"
/* System font directory */
#define FC_DEFAULT_FONTS "/usr/share/fonts"
/* The type of len parameter of the gperf hash/lookup function */
#define FC_GPERF_SIZE_T unsigned int
/* Define to nothing if C supports flexible array members, and to 1 if it does
not. That way, with a declaration like `struct s { int n; double
d[FLEXIBLE_ARRAY_MEMBER]; };', the struct hack can be used with pre-C99
compilers. When computing the size of such an object, don't use 'sizeof
(struct s)' as it overestimates the size. Use 'offsetof (struct s, d)'
instead. Don't use 'offsetof (struct s, d[0])', as this doesn't work with
MSVC and with C++ compilers. */
#define FLEXIBLE_ARRAY_MEMBER /**/
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
*/
#define HAVE_DIRENT_H 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
/* #undef HAVE_DOPRNT */
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define to 1 if you have the `fstatfs' function. */
#define HAVE_FSTATFS 1
/* Define to 1 if you have the `fstatvfs' function. */
#define HAVE_FSTATVFS 1
/* FT_Bitmap_Size structure includes y_ppem field */
#define HAVE_FT_BITMAP_SIZE_Y_PPEM 1
/* Define to 1 if you have the `FT_Get_BDF_Property' function. */
#define HAVE_FT_GET_BDF_PROPERTY 1
/* Define to 1 if you have the `FT_Get_Next_Char' function. */
#define HAVE_FT_GET_NEXT_CHAR 1
/* Define to 1 if you have the `FT_Get_PS_Font_Info' function. */
#define HAVE_FT_GET_PS_FONT_INFO 1
/* Define to 1 if you have the `FT_Get_X11_Font_Format' function. */
#define HAVE_FT_GET_X11_FONT_FORMAT 1
/* Define to 1 if you have the `FT_Has_PS_Glyph_Names' function. */
#define HAVE_FT_HAS_PS_GLYPH_NAMES 1
/* Define to 1 if you have the `FT_Select_Size' function. */
#define HAVE_FT_SELECT_SIZE 1
/* Define to 1 if you have the `getexecname' function. */
/* #undef HAVE_GETEXECNAME */
/* Define to 1 if you have the `getopt' function. */
#define HAVE_GETOPT 1
/* Define to 1 if you have the `getopt_long' function. */
#define HAVE_GETOPT_LONG 1
/* Define to 1 if you have the `getpagesize' function. */
#define HAVE_GETPAGESIZE 1
/* Define to 1 if you have the `getprogname' function. */
/* #undef HAVE_GETPROGNAME */
/* Have Intel __sync_* atomic primitives */
#define HAVE_INTEL_ATOMIC_PRIMITIVES 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `link' function. */
#define HAVE_LINK 1
/* Define to 1 if you have the `lrand48' function. */
#define HAVE_LRAND48 1
/* Define to 1 if you have the `lstat' function. */
#define HAVE_LSTAT 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `mkdtemp' function. */
#define HAVE_MKDTEMP 1
/* Define to 1 if you have the `mkostemp' function. */
#define HAVE_MKOSTEMP 1
/* Define to 1 if you have the `mkstemp' function. */
#define HAVE_MKSTEMP 1
/* Define to 1 if you have a working `mmap' system call. */
#define HAVE_MMAP 1
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
/* #undef HAVE_NDIR_H */
/* Define to 1 if you have the 'posix_fadvise' function. */
#define HAVE_POSIX_FADVISE 1
/* Have POSIX threads */
#define HAVE_PTHREAD 1
/* Have PTHREAD_PRIO_INHERIT. */
#define HAVE_PTHREAD_PRIO_INHERIT 1
/* Define to 1 if you have the `rand' function. */
#define HAVE_RAND 1
/* Define to 1 if you have the `random' function. */
#define HAVE_RANDOM 1
/* Define to 1 if you have the `random_r' function. */
#define HAVE_RANDOM_R 1
/* Define to 1 if you have the `rand_r' function. */
#define HAVE_RAND_R 1
/* Define to 1 if you have the `readlink' function. */
#define HAVE_READLINK 1
/* Define to 1 if you have the <sched.h> header file. */
/* #undef HAVE_SCHED_H */
/* Have sched_yield */
/* #undef HAVE_SCHED_YIELD */
/* Have Solaris __machine_*_barrier and atomic_* operations */
/* #undef HAVE_SOLARIS_ATOMIC_OPS */
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if `d_type' is a member of `struct dirent'. */
#define HAVE_STRUCT_DIRENT_D_TYPE 1
/* Define to 1 if `f_flags' is a member of `struct statfs'. */
#define HAVE_STRUCT_STATFS_F_FLAGS 1
/* Define to 1 if `f_fstypename' is a member of `struct statfs'. */
/* #undef HAVE_STRUCT_STATFS_F_FSTYPENAME */
/* Define to 1 if `f_basetype' is a member of `struct statvfs'. */
/* #undef HAVE_STRUCT_STATVFS_F_BASETYPE */
/* Define to 1 if `f_fstypename' is a member of `struct statvfs'. */
/* #undef HAVE_STRUCT_STATVFS_F_FSTYPENAME */
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_DIR_H */
/* Define to 1 if you have the <sys/mount.h> header file. */
#define HAVE_SYS_MOUNT_H 1
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
*/
/* #undef HAVE_SYS_NDIR_H */
/* Define to 1 if you have the <sys/param.h> header file. */
#define HAVE_SYS_PARAM_H 1
/* Define to 1 if you have the <sys/statfs.h> header file. */
#define HAVE_SYS_STATFS_H 1
/* Define to 1 if you have the <sys/statvfs.h> header file. */
#define HAVE_SYS_STATVFS_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <sys/vfs.h> header file. */
#define HAVE_SYS_VFS_H 1
/* Define to 1 if `usLowerOpticalPointSize' is a member of `TT_OS2'. */
#define HAVE_TT_OS2_USLOWEROPTICALPOINTSIZE 1
/* Define to 1 if `usUpperOpticalPointSize' is a member of `TT_OS2'. */
#define HAVE_TT_OS2_USUPPEROPTICALPOINTSIZE 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the `vprintf' function. */
#define HAVE_VPRINTF 1
/* Can use #warning in C files */
#define HAVE_WARNING_CPP_DIRECTIVE 1
/* Use xmlparse.h instead of expat.h */
/* #undef HAVE_XMLPARSE_H */
/* Define to 1 if you have the `XML_SetDoctypeDeclHandler' function. */
#define HAVE_XML_SETDOCTYPEDECLHANDLER 1
/* Define to 1 if you have the `_mktemp_s' function. */
/* #undef HAVE__MKTEMP_S */
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Name of package */
#define PACKAGE "fontconfig"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT \
"https://bugs.freedesktop.org/enter_bug.cgi?product=fontconfig"
/* Define to the full name of this package. */
#define PACKAGE_NAME "fontconfig"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "fontconfig 2.11.94"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "fontconfig"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "2.11.94"
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
/* #undef PTHREAD_CREATE_JOINABLE */
/* The size of `char', as computed by sizeof. */
/* #undef SIZEOF_CHAR */
/* The size of `int', as computed by sizeof. */
/* #undef SIZEOF_INT */
/* The size of `long', as computed by sizeof. */
/* #undef SIZEOF_LONG */
/* The size of `short', as computed by sizeof. */
/* #undef SIZEOF_SHORT */
/* The size of `void*', as computed by sizeof. */
/* #undef SIZEOF_VOIDP */
/* The size of `void *', as computed by sizeof. */
#define SIZEOF_VOID_P 8
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Use iconv. */
#define USE_ICONV 0
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
#define _ALL_SOURCE 1
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
#define _POSIX_PTHREAD_SEMANTICS 1
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
#define _TANDEM_SOURCE 1
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
#define __EXTENSIONS__ 1
#endif
/* Version number of package */
#define VERSION "2.11.94"
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
#if defined __BIG_ENDIAN__
#define WORDS_BIGENDIAN 1
#endif
#else
#ifndef WORDS_BIGENDIAN
/* # undef WORDS_BIGENDIAN */
#endif
#endif
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
#define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
/* #undef _FILE_OFFSET_BITS */
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */
/* Define to 1 if on MINIX. */
/* #undef _MINIX */
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
/* #undef _POSIX_1_SOURCE */
/* Define to 1 if you need to in order for `stat' and other things to work. */
/* #undef _POSIX_SOURCE */
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif
/* Define to `int' if <sys/types.h> does not define. */
/* #undef pid_t */

View File

@ -0,0 +1,130 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Description:
# Fontconfig is a library for font customization and configuration.
licenses(["notice"]) # BSD-like
genrule(
name = "config_h",
srcs = ["@com_github_googlecartographer_cartographer//bazel/third_party/fontconfig:config.h"],
outs = ["fontconfig_internal/config.h"],
cmd = "cp $< $@",
)
genrule(
name = "fcalias",
srcs = [
"fontconfig/fontconfig.h",
"src/fcdeprecate.h",
"fontconfig/fcprivate.h",
] + glob(["src/*.c"]),
outs = [
"src/fcalias.h",
"src/fcaliastail.h",
],
cmd = """./$(location src/makealias) \
$$(dirname $(location src/makealias)) \
$(OUTS) \
$(location fontconfig/fontconfig.h) \
$(location src/fcdeprecate.h) \
$(location fontconfig/fcprivate.h)""",
tools = ["src/makealias"],
)
genrule(
name = "fcftalias",
srcs = ["fontconfig/fcfreetype.h"] + glob(["src/*.c"]),
outs = [
"src/fcftalias.h",
"src/fcftaliastail.h",
],
cmd = """./$(location src/makealias) \
$$(dirname $(location src/makealias)) \
$(OUTS) \
$(location fontconfig/fcfreetype.h)""",
tools = ["src/makealias"],
)
cc_library(
name = "fontconfig",
srcs = [
"fc-blanks/fcblanks.h",
"fc-case/fccase.h",
"fc-glyphname/fcglyphname.h",
"fc-lang/fclang.h",
"fontconfig/fcfreetype.h",
"fontconfig/fcprivate.h",
"src/fcarch.h",
"src/fcatomic.c",
"src/fcatomic.h",
"src/fcblanks.c",
"src/fccache.c",
"src/fccfg.c",
"src/fccharset.c",
"src/fccompat.c",
"src/fcdbg.c",
"src/fcdefault.c",
"src/fcdeprecate.h",
"src/fcdir.c",
"src/fcformat.c",
"src/fcfreetype.c",
"src/fcfs.c",
"src/fcftint.h",
"src/fcinit.c",
"src/fcint.h",
"src/fclang.c",
"src/fclist.c",
"src/fcmatch.c",
"src/fcmatrix.c",
"src/fcmutex.h",
"src/fcname.c",
"src/fcobjs.c",
"src/fcobjs.h",
"src/fcobjshash.h",
"src/fcpat.c",
"src/fcrange.c",
"src/fcserialize.c",
"src/fcstat.c",
"src/fcstdint.h",
"src/fcstr.c",
"src/fcweight.c",
"src/fcxml.c",
"src/ftglue.c",
"src/ftglue.h",
":config_h",
":fcalias",
":fcftalias",
],
hdrs = [
"fontconfig/fontconfig.h",
],
copts = [
"-Iexternal/org_freedesktop_fontconfig/src",
"-I$(GENDIR)/external/org_freedesktop_fontconfig/src",
"-I$(GENDIR)/external/org_freedesktop_fontconfig/fontconfig_internal",
"-DFC_CACHEDIR='\"/var/cache/fontconfig\"'",
"-DFONTCONFIG_PATH='\"/etc/fonts\"'",
"-DHAVE_CONFIG_H",
"-Wno-strict-aliasing",
],
includes = ["."],
visibility = ["//visibility:public"],
deps = [
"@com_github_libexpat_libexpat//:expat",
"@net_zlib_zlib//:zlib",
"@org_freetype_freetype2//:freetype2",
],
)

View File

@ -0,0 +1,262 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Description:
# A free font library.
licenses(["notice"]) # BSD-style
cc_library(
name = "freetype2",
srcs = [
"builds/unix/ftsystem.c",
"src/autofit/autofit.c",
"src/base/ftbase.c",
"src/base/ftbbox.c",
"src/base/ftbdf.c",
"src/base/ftbitmap.c",
"src/base/ftcid.c",
"src/base/ftdebug.c",
"src/base/ftfntfmt.c",
"src/base/ftfstype.c",
"src/base/ftgasp.c",
"src/base/ftglyph.c",
"src/base/ftgxval.c",
"src/base/ftinit.c",
"src/base/ftlcdfil.c",
"src/base/ftmm.c",
"src/base/ftotval.c",
"src/base/ftpatent.c",
"src/base/ftpfr.c",
"src/base/ftstroke.c",
"src/base/ftsynth.c",
"src/base/fttype1.c",
"src/base/ftwinfnt.c",
"src/bdf/bdf.c",
"src/bzip2/ftbzip2.c",
"src/cache/ftcache.c",
"src/cff/cff.c",
"src/cid/type1cid.c",
"src/gxvalid/gxvalid.c",
"src/gzip/ftgzip.c",
"src/lzw/ftlzw.c",
"src/otvalid/otvalid.c",
"src/pcf/pcf.c",
"src/pfr/pfr.c",
"src/psaux/psaux.c",
"src/pshinter/pshinter.c",
"src/psnames/psnames.c",
"src/raster/raster.c",
"src/sfnt/sfnt.c",
"src/smooth/smooth.c",
"src/truetype/truetype.c",
"src/type1/type1.c",
"src/type42/type42.c",
"src/winfonts/winfnt.c",
] + glob([
"src/**/*.h",
"builds/unix/*.h",
"include/freetype/internal/**/*.h",
]),
hdrs = glob([
"include/freetype/*.h",
"include/freetype/config/*.h",
"include/ft2build.h",
]) + [
"src/autofit/afangles.c",
"src/autofit/afblue.c",
"src/autofit/afcjk.c",
"src/autofit/afdummy.c",
"src/autofit/afglobal.c",
"src/autofit/afhints.c",
"src/autofit/afindic.c",
"src/autofit/aflatin.c",
"src/autofit/aflatin2.c",
"src/autofit/afloader.c",
"src/autofit/afmodule.c",
"src/autofit/afpic.c",
"src/autofit/afranges.c",
"src/autofit/afwarp.c",
"src/autofit/afshaper.c",
"src/base/basepic.c",
"src/base/ftadvanc.c",
"src/base/ftapi.c",
"src/base/ftcalc.c",
"src/base/ftdbgmem.c",
"src/base/ftgloadr.c",
"src/base/fthash.c",
"src/base/ftmac.c",
"src/base/ftobjs.c",
"src/base/ftoutln.c",
"src/base/ftpic.c",
"src/base/ftrfork.c",
"src/base/ftsnames.c",
"src/base/ftstream.c",
"src/base/ftsystem.c",
"src/base/fttrigon.c",
"src/base/ftutil.c",
"src/base/md5.c",
"src/bdf/bdfdrivr.c",
"src/bdf/bdflib.c",
"src/cache/ftcbasic.c",
"src/cache/ftccache.c",
"src/cache/ftccmap.c",
"src/cache/ftcglyph.c",
"src/cache/ftcimage.c",
"src/cache/ftcmanag.c",
"src/cache/ftcmru.c",
"src/cache/ftcsbits.c",
"src/cff/cf2arrst.c",
"src/cff/cf2blues.c",
"src/cff/cf2error.c",
"src/cff/cf2font.c",
"src/cff/cf2ft.c",
"src/cff/cf2hints.c",
"src/cff/cf2intrp.c",
"src/cff/cf2read.c",
"src/cff/cf2stack.c",
"src/cff/cffcmap.c",
"src/cff/cffdrivr.c",
"src/cff/cffgload.c",
"src/cff/cffload.c",
"src/cff/cffobjs.c",
"src/cff/cffparse.c",
"src/cff/cffpic.c",
"src/cid/cidgload.c",
"src/cid/cidload.c",
"src/cid/cidobjs.c",
"src/cid/cidparse.c",
"src/cid/cidriver.c",
"src/gxvalid/gxvalid.c",
"src/gxvalid/gxvbsln.c",
"src/gxvalid/gxvcommn.c",
"src/gxvalid/gxvfeat.c",
"src/gxvalid/gxvfgen.c",
"src/gxvalid/gxvjust.c",
"src/gxvalid/gxvkern.c",
"src/gxvalid/gxvlcar.c",
"src/gxvalid/gxvmod.c",
"src/gxvalid/gxvmort.c",
"src/gxvalid/gxvmort0.c",
"src/gxvalid/gxvmort1.c",
"src/gxvalid/gxvmort2.c",
"src/gxvalid/gxvmort4.c",
"src/gxvalid/gxvmort5.c",
"src/gxvalid/gxvmorx.c",
"src/gxvalid/gxvmorx0.c",
"src/gxvalid/gxvmorx1.c",
"src/gxvalid/gxvmorx2.c",
"src/gxvalid/gxvmorx4.c",
"src/gxvalid/gxvmorx5.c",
"src/gxvalid/gxvopbd.c",
"src/gxvalid/gxvprop.c",
"src/gxvalid/gxvtrak.c",
"src/gzip/adler32.c",
"src/gzip/infblock.c",
"src/gzip/infcodes.c",
"src/gzip/inflate.c",
"src/gzip/inftrees.c",
"src/gzip/infutil.c",
"src/gzip/zutil.c",
"src/lzw/ftzopen.c",
"src/otvalid/otvalid.c",
"src/otvalid/otvbase.c",
"src/otvalid/otvcommn.c",
"src/otvalid/otvgdef.c",
"src/otvalid/otvgpos.c",
"src/otvalid/otvgsub.c",
"src/otvalid/otvjstf.c",
"src/otvalid/otvmath.c",
"src/otvalid/otvmod.c",
"src/pcf/pcfdrivr.c",
"src/pcf/pcfread.c",
"src/pcf/pcfutil.c",
"src/pfr/pfrcmap.c",
"src/pfr/pfrdrivr.c",
"src/pfr/pfrgload.c",
"src/pfr/pfrload.c",
"src/pfr/pfrobjs.c",
"src/pfr/pfrsbit.c",
"src/psaux/afmparse.c",
"src/psaux/psauxmod.c",
"src/psaux/psconv.c",
"src/psaux/psobjs.c",
"src/psaux/t1cmap.c",
"src/psaux/t1decode.c",
"src/pshinter/pshalgo.c",
"src/pshinter/pshglob.c",
"src/pshinter/pshmod.c",
"src/pshinter/pshpic.c",
"src/pshinter/pshrec.c",
"src/psnames/psmodule.c",
"src/psnames/pspic.c",
"src/raster/ftraster.c",
"src/raster/ftrend1.c",
"src/raster/rastpic.c",
"src/sfnt/pngshim.c",
"src/sfnt/sfdriver.c",
"src/sfnt/sfntpic.c",
"src/sfnt/sfobjs.c",
"src/sfnt/ttbdf.c",
"src/sfnt/ttcmap.c",
"src/sfnt/ttkern.c",
"src/sfnt/ttload.c",
"src/sfnt/ttmtx.c",
"src/sfnt/ttpost.c",
"src/sfnt/ttsbit.c",
"src/smooth/ftgrays.c",
"src/smooth/ftsmooth.c",
"src/smooth/ftspic.c",
"src/tools/ftrandom/ftrandom.c",
"src/tools/test_afm.c",
"src/tools/test_bbox.c",
"src/tools/test_trig.c",
"src/truetype/ttdriver.c",
"src/truetype/ttgload.c",
"src/truetype/ttgxvar.c",
"src/truetype/ttinterp.c",
"src/truetype/ttobjs.c",
"src/truetype/ttpic.c",
"src/truetype/ttpload.c",
"src/truetype/ttsubpix.c",
"src/type1/t1afm.c",
"src/type1/t1driver.c",
"src/type1/t1gload.c",
"src/type1/t1load.c",
"src/type1/t1objs.c",
"src/type1/t1parse.c",
"src/type42/t42drivr.c",
"src/type42/t42objs.c",
"src/type42/t42parse.c",
],
copts = [
"-Wno-covered-switch-default",
"-DFT_CONFIG_OPTION_SYSTEM_ZLIB",
"-DFT_CONFIG_CONFIG_H=<ftconfig.h>",
"-DFT_CONFIG_OPTION_USE_PNG",
"-DFT2_BUILD_LIBRARY",
"-DFT_CONFIG_MODULES_H=<ftmodule.h>",
"-DHAVE_UNISTD_H=1",
"-DHAVE_FCNTL_H=1",
"-DHAVE_STDINT_H=1",
"-Iexternal/org_freetype_freetype2/builds/unix",
"-Iexternal/org_freetype_freetype2/include/freetype/config",
],
includes = ["include"],
visibility = ["//visibility:public"],
deps = [
"@net_zlib_zlib//:zlib",
"@org_libpng_libpng//:libpng",
],
)

View File

@ -0,0 +1,124 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Description:
# GD is a library for the dynamic creation of images.
load("@com_github_antonovvk_bazel_rules//:config.bzl", "cc_fix_config")
licenses(["notice"]) # simple notice-style license
cc_fix_config(
name = "config_h",
cmake = True,
files = {"src/config.h.cmake": "gd_internal/config.h"},
values = {
"HAVE_DIRENT_H": "1",
"HAVE_DLFCN_H": "1",
"HAVE_ERRNO_H": "1",
"HAVE_FT2BUILD_H": "1",
"HAVE_ICONV": "1",
"HAVE_ICONV_H": "1",
"HAVE_ICONV_T_DEF": "1",
"HAVE_INTTYPES_H": "1",
"HAVE_LIBFREETYPE": "1",
"HAVE_LIBJPEG": "1",
"HAVE_LIBM": "1",
"HAVE_LIBPNG": "1",
"HAVE_LIBZ": "1",
"HAVE_LIMITS_H": "1",
"HAVE_MEMORY_H": "1",
"HAVE_PTHREAD": "1",
"HAVE_PTHREAD_PRIO_INHERIT": "1",
"HAVE_STDDEF_H": "1",
"HAVE_STDINT_H": "1",
"HAVE_STDLIB_H": "1",
"HAVE_STRINGS_H": "1",
"HAVE_STRING_H": "1",
"HAVE_SYS_STAT_H": "1",
"HAVE_SYS_TYPES_H": "1",
"HAVE_UNISTD_H": "1",
"HAVE_VISIBILITY": "1",
"ICONV_CONST": "",
"LT_OBJDIR": "\".libs/\"",
"PACKAGE": "libgd",
"PACKAGE_BUGREPORT": "https://bitbucket.org/libgd/gd-libgd/issues",
"PACKAGE_NAME": "GD",
"PACKAGE_STRING": "GD 2.2.4",
"PACKAGE_TARNAME": "libgd",
"PACKAGE_URL": "http://lib.gd",
"PACKAGE_VERSION": "2.2.4",
"STDC_HEADERS": "1",
"VERSION": "2.2.4",
},
)
cc_library(
name = "gd",
srcs = [
"src/gd.c",
"src/gd_color.c",
"src/gd_gd.c",
"src/gd_gd2.c",
"src/gd_gif_in.c",
"src/gd_gif_out.c",
"src/gd_io.c",
"src/gd_io_dp.c",
"src/gd_io_file.c",
"src/gd_io_ss.c",
"src/gd_jpeg.c",
"src/gd_nnquant.c",
"src/gd_png.c",
"src/gd_security.c",
"src/gd_ss.c",
"src/gd_topal.c",
"src/gd_wbmp.c",
"src/gd_xbm.c",
"src/gdcache.c",
"src/gdfontg.c",
"src/gdfontl.c",
"src/gdfontmb.c",
"src/gdfonts.c",
"src/gdfontt.c",
"src/gdft.c",
"src/gdfx.c",
"src/gdhelpers.c",
"src/gdkanji.c",
"src/gdtables.c",
"src/gdxpm.c",
"src/wbmp.c",
"gd_internal/config.h",
] + glob([
"src/*.h",
]),
hdrs = [
"src/gd.h",
"src/gdhelpers.h",
],
copts = [
"-I$(GENDIR)/external/org_libgd_libgd/gd_internal",
"-DFC_CACHEDIR='\"/var/cache/fontconfig\"'",
"-DFONTCONFIG_PATH='\"/etc/fonts\"'",
"-DHAVE_CONFIG_H",
],
includes = ["src"],
linkopts = ["-lm"],
visibility = ["//visibility:public"],
deps = [
"@libjpeg//:jpeg",
"@net_zlib_zlib//:zlib",
"@org_freetype_freetype2//:freetype2",
"@org_libpng_libpng//:libpng",
],
)

View File

@ -0,0 +1,103 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Description:
# The Independent JPEG Group's JPEG runtime library.
licenses(["notice"]) # custom notice-style license, see LICENSE
cc_library(
name = "jpeg",
srcs = [
"cderror.h",
"cdjpeg.h",
"jaricom.c",
"jcapimin.c",
"jcapistd.c",
"jcarith.c",
"jccoefct.c",
"jccolor.c",
"jcdctmgr.c",
"jchuff.c",
"jcinit.c",
"jcmainct.c",
"jcmarker.c",
"jcmaster.c",
"jcomapi.c",
"jconfig.h",
"jcparam.c",
"jcprepct.c",
"jcsample.c",
"jctrans.c",
"jdapimin.c",
"jdapistd.c",
"jdarith.c",
"jdatadst.c",
"jdatasrc.c",
"jdcoefct.c",
"jdcolor.c",
"jdct.h",
"jddctmgr.c",
"jdhuff.c",
"jdinput.c",
"jdmainct.c",
"jdmarker.c",
"jdmaster.c",
"jdmerge.c",
"jdpostct.c",
"jdsample.c",
"jdtrans.c",
"jerror.c",
"jfdctflt.c",
"jfdctfst.c",
"jfdctint.c",
"jidctflt.c",
"jidctfst.c",
"jidctint.c",
"jinclude.h",
"jmemmgr.c",
"jmemnobs.c",
"jmemsys.h",
"jmorecfg.h",
"jquant1.c",
"jquant2.c",
"jutils.c",
"jversion.h",
"transupp.h",
],
hdrs = [
"jerror.h",
"jpegint.h",
"jpeglib.h",
],
includes = ["."],
visibility = ["//visibility:public"],
)
genrule(
name = "configure",
outs = ["jconfig.h"],
cmd = "cat <<EOF >$@\n" +
"#define HAVE_PROTOTYPES 1\n" +
"#define HAVE_UNSIGNED_CHAR 1\n" +
"#define HAVE_UNSIGNED_SHORT 1\n" +
"#define HAVE_STDDEF_H 1\n" +
"#define HAVE_STDLIB_H 1\n" +
"#ifdef WIN32\n" +
"#define INLINE __inline\n" +
"#else\n" +
"#define INLINE __inline__\n" +
"#endif\n" +
"EOF\n",
)

View File

@ -0,0 +1,47 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Description:
# libpng is the official PNG reference library.
licenses(["notice"]) # BSD/MIT-like license
cc_library(
name = "libpng",
srcs = [
"png.c",
"pngerror.c",
"pngget.c",
"pngmem.c",
"pngpread.c",
"pngread.c",
"pngrio.c",
"pngrtran.c",
"pngrutil.c",
"pngset.c",
"pngtrans.c",
"pngwio.c",
"pngwrite.c",
"pngwtran.c",
"pngwutil.c",
],
hdrs = [
"png.h",
"pngconf.h",
],
includes = ["."],
linkopts = ["-lm"],
visibility = ["//visibility:public"],
deps = ["@net_zlib_zlib//:zlib"],
)

View File

@ -0,0 +1,109 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Description:
# Lua language interpreter.
package(
default_visibility = ["//visibility:public"],
)
licenses(["notice"]) # MIT
cc_library(
name = "lua_includes",
hdrs = [
"src/lauxlib.h",
"src/lua.h",
"src/lua.hpp",
"src/luaconf.h",
"src/lualib.h",
],
includes = ["src"],
)
cc_library(
name = "lua",
srcs = [
# Core language
"src/lapi.c",
"src/lapi.h",
"src/lcode.c",
"src/lcode.h",
"src/lctype.c",
"src/lctype.h",
"src/ldebug.c",
"src/ldebug.h",
"src/ldo.c",
"src/ldo.h",
"src/ldump.c",
"src/lfunc.c",
"src/lfunc.h",
"src/lgc.c",
"src/lgc.h",
"src/llex.c",
"src/llex.h",
"src/llimits.h",
"src/lmem.c",
"src/lmem.h",
"src/lobject.c",
"src/lobject.h",
"src/lopcodes.c",
"src/lopcodes.h",
"src/lparser.c",
"src/lparser.h",
"src/lstate.c",
"src/lstate.h",
"src/lstring.c",
"src/lstring.h",
"src/ltable.c",
"src/ltable.h",
"src/ltm.c",
"src/ltm.h",
"src/lundump.c",
"src/lundump.h",
"src/lvm.c",
"src/lvm.h",
"src/lzio.c",
# Standard libraries
"src/lauxlib.c",
"src/lbaselib.c",
"src/lbitlib.c",
"src/lcorolib.c",
"src/ldblib.c",
"src/linit.c",
"src/liolib.c",
"src/lmathlib.c",
"src/loadlib.c",
"src/loslib.c",
"src/lstrlib.c",
"src/ltablib.c",
"src/lzio.h",
],
hdrs = [
"src/lauxlib.h",
"src/lua.h",
"src/lua.hpp",
"src/luaconf.h",
"src/lualib.h",
],
copts = ["-w"],
defines = ["LUA_USE_LINUX"],
includes = ["src"],
linkopts = [
"-lm",
"-ldl",
],
)

View File

@ -0,0 +1,25 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Files required for building Pixman with Bazel.
licenses(["notice"])
exports_files(
[
"pixman.BUILD",
"config.h",
],
visibility = ["//visibility:public"],
)

View File

@ -0,0 +1,193 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Define if building universal (internal helper macro) */
/* #undef AC_APPLE_UNIVERSAL_BUILD */
/* Whether we have alarm() */
#define HAVE_ALARM 1
/* Whether the compiler supports __builtin_clz */
#define HAVE_BUILTIN_CLZ /**/
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Whether we have feenableexcept() */
#define HAVE_FEENABLEEXCEPT 1
/* Define to 1 if we have <fenv.h> */
#define HAVE_FENV_H 1
/* Whether the tool chain supports __float128 */
#define HAVE_FLOAT128 /**/
/* Define to 1 if you have the `getisax' function. */
/* #undef HAVE_GETISAX */
/* Whether we have getpagesize() */
#define HAVE_GETPAGESIZE 1
/* Whether we have gettimeofday() */
#define HAVE_GETTIMEOFDAY 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `pixman-1' library (-lpixman-1). */
/* #undef HAVE_LIBPIXMAN_1 */
/* Whether we have libpng */
#define HAVE_LIBPNG 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Whether we have mmap() */
#define HAVE_MMAP 1
/* Whether we have mprotect() */
#define HAVE_MPROTECT 1
/* Whether we have posix_memalign() */
#define HAVE_POSIX_MEMALIGN 1
/* Whether pthreads is supported */
#define HAVE_PTHREADS /**/
/* Whether we have sigaction() */
#define HAVE_SIGACTION 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if we have <sys/mman.h> */
#define HAVE_SYS_MMAN_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/"
/* Name of package */
#define PACKAGE "pixman"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "pixman@lists.freedesktop.org"
/* Define to the full name of this package. */
#define PACKAGE_NAME "pixman"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "pixman 0.34.0"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "pixman"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "0.34.0"
/* enable TIMER_BEGIN/TIMER_END macros */
/* #undef PIXMAN_TIMERS */
/* The size of `long', as computed by sizeof. */
#define SIZEOF_LONG 8
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* The compiler supported TLS storage class */
#define TLS __thread
/* Whether the tool chain supports __attribute__((constructor)) */
#define TOOLCHAIN_SUPPORTS_ATTRIBUTE_CONSTRUCTOR /**/
/* use ARM IWMMXT compiler intrinsics */
/* #undef USE_ARM_IWMMXT */
/* use ARM NEON assembly optimizations */
/* #undef USE_ARM_NEON */
/* use ARM SIMD assembly optimizations */
/* #undef USE_ARM_SIMD */
/* use GNU-style inline assembler */
#define USE_GCC_INLINE_ASM 1
/* use Loongson Multimedia Instructions */
/* #undef USE_LOONGSON_MMI */
/* use MIPS DSPr2 assembly optimizations */
/* #undef USE_MIPS_DSPR2 */
/* use OpenMP in the test suite */
#define USE_OPENMP 1
/* use SSE2 compiler intrinsics */
/* #undef USE_SSE2 */
/* use SSSE3 compiler intrinsics */
/* #undef USE_SSSE3 */
/* use VMX compiler intrinsics */
/* #undef USE_VMX */
/* use x86 MMX compiler intrinsics */
/* #undef USE_X86_MMX */
/* Version number of package */
#define VERSION "0.34.0"
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
#if defined __BIG_ENDIAN__
#define WORDS_BIGENDIAN 1
#endif
#else
#ifndef WORDS_BIGENDIAN
/* # undef WORDS_BIGENDIAN */
#endif
#endif
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif
/* Define to sqrt if you do not have the `sqrtf' function. */
/* #undef sqrtf */

View File

@ -0,0 +1,87 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Description:
# pixman is a library that provides low-level pixel manipulation features.
licenses(["notice"]) # X11/MIT
genrule(
name = "config_h",
srcs = ["@com_github_googlecartographer_cartographer//bazel/third_party/pixman:config.h"],
outs = ["pixman_internal/config.h"],
cmd = "cp $< $@",
)
COMMON_SRCS = [
"pixman/pixman.c",
"pixman/pixman-access.c",
"pixman/pixman-access-accessors.c",
"pixman/pixman-arm.c",
"pixman/pixman-bits-image.c",
"pixman/pixman-combine-float.c",
"pixman/pixman-combine32.c",
"pixman/pixman-conical-gradient.c",
"pixman/pixman-edge-accessors.c",
"pixman/pixman-edge.c",
"pixman/pixman-fast-path.c",
"pixman/pixman-filter.c",
"pixman/pixman-general.c",
"pixman/pixman-glyph.c",
"pixman/pixman-gradient-walker.c",
"pixman/pixman-image.c",
"pixman/pixman-implementation.c",
"pixman/pixman-linear-gradient.c",
"pixman/pixman-matrix.c",
"pixman/pixman-mips.c",
"pixman/pixman-noop.c",
"pixman/pixman-ppc.c",
"pixman/pixman-radial-gradient.c",
"pixman/pixman-region16.c",
"pixman/pixman-region32.c",
"pixman/pixman-solid-fill.c",
"pixman/pixman-timer.c",
"pixman/pixman-trap.c",
"pixman/pixman-utils.c",
"pixman/pixman-x86.c",
]
# TODO(rodrigoq): use MMX extensions where possible
cc_library(
name = "pixman",
srcs = COMMON_SRCS + [
"pixman/pixman-accessor.h",
"pixman/pixman-combine32.h",
"pixman/pixman-compiler.h",
"pixman/pixman-edge-imp.h",
"pixman/pixman-inlines.h",
"pixman/pixman-private.h",
"pixman/pixman-version.h",
"pixman/pixman.h",
"pixman_internal/config.h",
],
hdrs = [
"pixman/pixman-access.c",
"pixman/pixman-edge.c",
"pixman/pixman-region.c",
],
copts = [
"-Wno-unused-const-variable",
"-Wno-unused-local-typedefs",
"-DHAVE_CONFIG_H",
"-I$(GENDIR)/external/org_cairographics_pixman/pixman_internal",
],
includes = ["pixman"],
visibility = ["//visibility:public"],
)

View File

@ -0,0 +1,58 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
package(default_visibility = ["//visibility:public"])
licenses(["notice"]) # BSD/MIT-like license (for zlib)
cc_library(
name = "zlib",
srcs = [
"adler32.c",
"compress.c",
"crc32.c",
"crc32.h",
"deflate.c",
"deflate.h",
"gzclose.c",
"gzguts.h",
"gzlib.c",
"gzread.c",
"gzwrite.c",
"infback.c",
"inffast.c",
"inffast.h",
"inffixed.h",
"inflate.c",
"inflate.h",
"inftrees.c",
"inftrees.h",
"trees.c",
"trees.h",
"uncompr.c",
"zconf.h",
"zutil.c",
"zutil.h",
],
hdrs = ["zlib.h"],
copts = [
"-Wno-implicit-function-declaration",
],
includes = ["."],
)
alias(
name = "z",
actual = ":zlib",
)

View File

@ -0,0 +1,49 @@
# Copyright 2016 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Usage from an external project:
# In your CMakeLists.txt, add these lines:
#
# find_package(cartographer REQUIRED)
# target_link_libraries(MY_TARGET_NAME PUBLIC cartographer)
@PACKAGE_INIT@
set_and_check(CARTOGRAPHER_CMAKE_DIR "@PACKAGE_CARTOGRAPHER_CMAKE_DIR@")
set(CERES_DIR_HINTS @Ceres_DIR@)
set(CARTOGRAPHER_HAS_GRPC @CARTOGRAPHER_HAS_GRPC@)
if (cartographer_FIND_QUIETLY)
set(QUIET_OR_REQUIRED_OPTION "QUIET")
elseif (cartographer_FIND_REQUIRED)
set(QUIET_OR_REQUIRED_OPTION "REQUIRED")
else ()
set(QUIET_OR_REQUIRED_OPTION "")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CARTOGRAPHER_CMAKE_DIR}/modules)
find_package(Ceres ${QUIET_OR_REQUIRED_OPTION} HINTS ${CERES_DIR_HINTS})
if (WIN32)
find_package(glog REQUIRED)
endif()
find_package(absl ${QUIET_OR_REQUIRED_OPTION})
if(CARTOGRAPHER_HAS_GRPC)
find_package(async_grpc ${QUIET_OR_REQUIRED_OPTION})
endif()
include("${CARTOGRAPHER_CMAKE_DIR}/CartographerTargets.cmake")
unset(QUIET_OR_REQUIRED_OPTION)

View File

@ -0,0 +1,2 @@
BasedOnStyle: Google
DerivePointerAlignment: false

View File

@ -0,0 +1,135 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Top-level proto and C++ targets for Cartographer.
load("@com_github_antonovvk_bazel_rules//:config.bzl", "cc_fix_config")
package(
default_visibility = ["//visibility:public"],
)
licenses(["notice"]) # Apache 2.0
proto_library(
name = "protos",
srcs = glob([
"**/*.proto",
]),
deps = [
"@com_google_protobuf//:empty_proto",
],
)
cc_proto_library(
name = "cc_protos",
deps = [":protos"],
)
cc_fix_config(
name = "common_config_h",
cmake = True,
files = {"common/config.h.cmake": "common/config.h"},
values = {
"CARTOGRAPHER_CONFIGURATION_FILES_DIRECTORY": "configuration_files",
"PROJECT_SOURCE_DIR": "todo_set_project_source_dir_in_cartographer.BUILD",
},
visibility = ["//visibility:private"],
)
TEST_LIBRARY_SRCS = glob([
"**/*test_helpers.cc",
"**/fake_*.cc",
"**/mock_*.cc",
])
TEST_LIBRARY_HDRS = glob([
"**/*test_helpers.h",
"**/fake_*.h",
"**/mock_*.h",
])
cc_library(
name = "cartographer_test_library",
testonly = 1,
srcs = TEST_LIBRARY_SRCS,
hdrs = TEST_LIBRARY_HDRS,
deps = [
":cartographer",
"@com_google_googletest//:gtest",
],
)
cc_library(
name = "cartographer",
srcs = glob(
[
"**/*.cc",
],
exclude = [
"**/*_main.cc",
"**/*_test.cc",
] + TEST_LIBRARY_SRCS,
),
hdrs = [
"common/config.h",
] + glob(
[
"**/*.h",
],
exclude = TEST_LIBRARY_HDRS,
),
copts = ["-Wno-sign-compare"],
includes = ["."],
deps = [
":cc_protos",
"@boost//:iostreams",
"@com_google_absl//absl/base",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/types:optional",
"@com_google_glog//:glog",
"@org_cairographics_cairo//:cairo",
"@org_ceres_solver_ceres_solver//:ceres",
"@org_lua_lua//:lua",
"@org_tuxfamily_eigen//:eigen",
],
)
cc_binary(
name = "cartographer_print_configuration",
srcs = ["common/print_configuration_main.cc"],
deps = [
":cartographer",
"@com_github_gflags_gflags//:gflags",
"@com_google_glog//:glog",
],
)
[cc_test(
name = src.replace("/", "_").replace(".cc", ""),
srcs = [src],
data = ["//:configuration_files"],
deps = [
":cartographer",
":cartographer_test_library",
"@com_google_absl//absl/memory",
"@com_google_googletest//:gtest_main",
],
) for src in glob(
["**/*_test.cc"],
)]

View File

@ -0,0 +1,106 @@
# Copyright 2018 The Cartographer Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Top-level proto and C++ targets for Cartographer's gRPC server.
licenses(["notice"]) # Apache 2.0
package(default_visibility = ["//visibility:public"])
proto_library(
name = "protos",
srcs = glob(
[
"**/*.proto",
],
),
deps = [
"//cartographer:protos",
"@com_google_protobuf//:empty_proto",
],
)
cc_proto_library(
name = "cc_protos",
deps = [":protos"],
)
# TODO(rodrigoq): This special rule name is required by cc_grpc_library. This
# makes :protos look like it was created by
# cc_grpc_library(proto_only=True, ...)
proto_library(
name = "_cc_protos_only",
deps = [
":protos",
"//cartographer:protos",
"@com_google_protobuf//:empty_proto",
],
)
cc_library(
name = "cartographer_grpc",
srcs = glob(
[
"**/*.cc",
],
exclude = [
"**/*_main.cc",
"**/*_test.cc",
],
),
hdrs = glob([
"**/*.h",
]),
copts = ["-Wno-sign-compare"],
defines = ["USE_PROMETHEUS=1"],
includes = ["."],
deps = [
":cc_protos",
"//cartographer",
"@com_github_googlecartographer_async_grpc//async_grpc",
"@com_github_grpc_grpc//:grpc++",
"@com_github_jupp0r_prometheus_cpp//core",
"@com_github_jupp0r_prometheus_cpp//pull",
"@com_google_glog//:glog",
"@com_google_protobuf//:cc_wkt_protos",
],
)
cc_binary(
name = "cartographer_grpc_server",
srcs = ["map_builder_server_main.cc"],
deps = [
":cartographer_grpc",
"@com_github_gflags_gflags//:gflags",
"@com_google_glog//:glog",
],
)
[cc_test(
name = src.replace("/", "_").replace(".cc", ""),
srcs = [src],
data = ["//:configuration_files"],
# TODO(gaschler): Fix UplinkServerRestarting test for Bazel.
args = ["--gtest_filter=-ClientServerTestByGridType/ClientServerTestByGridType.LocalSlam2DUplinkServerRestarting*"],
flaky = True, # :internal_client_server_test sometimes fails.
# Tests cannot run concurrently as some of them open the same port.
tags = ["exclusive"],
deps = [
":cartographer_grpc",
"//cartographer:cartographer_test_library",
"@com_google_googletest//:gtest_main",
],
) for src in glob(
["**/*_test.cc"],
)]

View File

@ -0,0 +1,249 @@
/*
* Copyright 2017 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/client/map_builder_stub.h"
#include "cartographer/cloud/internal/client/pose_graph_stub.h"
#include "cartographer/cloud/internal/client/trajectory_builder_stub.h"
#include "cartographer/cloud/internal/handlers/add_trajectory_handler.h"
#include "cartographer/cloud/internal/handlers/finish_trajectory_handler.h"
#include "cartographer/cloud/internal/handlers/get_submap_handler.h"
#include "cartographer/cloud/internal/handlers/load_state_from_file_handler.h"
#include "cartographer/cloud/internal/handlers/load_state_handler.h"
#include "cartographer/cloud/internal/handlers/write_state_handler.h"
#include "cartographer/cloud/internal/handlers/write_state_to_file_handler.h"
#include "cartographer/cloud/internal/mapping/serialization.h"
#include "cartographer/cloud/internal/sensor/serialization.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "cartographer/io/proto_stream_deserializer.h"
#include "glog/logging.h"
namespace cartographer {
namespace cloud {
namespace {
using absl::make_unique;
constexpr int kChannelTimeoutSeconds = 10;
constexpr int kRetryBaseDelayMilliseconds = 500;
constexpr float kRetryDelayFactor = 2.0;
constexpr int kMaxRetries = 5;
} // namespace
MapBuilderStub::MapBuilderStub(const std::string& server_address,
const std::string& client_id)
: client_channel_(::grpc::CreateChannel(
server_address, ::grpc::InsecureChannelCredentials())),
pose_graph_stub_(make_unique<PoseGraphStub>(client_channel_, client_id)),
client_id_(client_id) {
LOG(INFO) << "Connecting to SLAM process at " << server_address
<< " with client_id " << client_id;
std::chrono::system_clock::time_point deadline(
std::chrono::system_clock::now() +
std::chrono::seconds(kChannelTimeoutSeconds));
if (!client_channel_->WaitForConnected(deadline)) {
LOG(FATAL) << "Failed to connect to " << server_address;
}
}
int MapBuilderStub::AddTrajectoryBuilder(
const std::set<SensorId>& expected_sensor_ids,
const mapping::proto::TrajectoryBuilderOptions& trajectory_options,
LocalSlamResultCallback local_slam_result_callback) {
proto::AddTrajectoryRequest request;
request.set_client_id(client_id_);
*request.mutable_trajectory_builder_options() = trajectory_options;
for (const auto& sensor_id : expected_sensor_ids) {
*request.add_expected_sensor_ids() = cloud::ToProto(sensor_id);
}
async_grpc::Client<handlers::AddTrajectorySignature> client(
client_channel_, common::FromSeconds(kChannelTimeoutSeconds),
async_grpc::CreateLimitedBackoffStrategy(
common::FromMilliseconds(kRetryBaseDelayMilliseconds),
kRetryDelayFactor, kMaxRetries));
CHECK(client.Write(request));
// Construct trajectory builder stub.
trajectory_builder_stubs_.emplace(
std::piecewise_construct,
std::forward_as_tuple(client.response().trajectory_id()),
std::forward_as_tuple(make_unique<TrajectoryBuilderStub>(
client_channel_, client.response().trajectory_id(), client_id_,
local_slam_result_callback)));
return client.response().trajectory_id();
}
int MapBuilderStub::AddTrajectoryForDeserialization(
const mapping::proto::TrajectoryBuilderOptionsWithSensorIds&
options_with_sensor_ids_proto) {
LOG(FATAL) << "Not implemented";
}
mapping::TrajectoryBuilderInterface* MapBuilderStub::GetTrajectoryBuilder(
int trajectory_id) const {
auto it = trajectory_builder_stubs_.find(trajectory_id);
if (it == trajectory_builder_stubs_.end()) {
return nullptr;
}
return it->second.get();
}
void MapBuilderStub::FinishTrajectory(int trajectory_id) {
proto::FinishTrajectoryRequest request;
request.set_client_id(client_id_);
request.set_trajectory_id(trajectory_id);
async_grpc::Client<handlers::FinishTrajectorySignature> client(
client_channel_);
::grpc::Status status;
client.Write(request, &status);
if (!status.ok()) {
LOG(ERROR) << "Failed to finish trajectory " << trajectory_id
<< " for client_id " << client_id_ << ": "
<< status.error_message();
return;
}
trajectory_builder_stubs_.erase(trajectory_id);
}
std::string MapBuilderStub::SubmapToProto(
const mapping::SubmapId& submap_id,
mapping::proto::SubmapQuery::Response* submap_query_response) {
proto::GetSubmapRequest request;
submap_id.ToProto(request.mutable_submap_id());
async_grpc::Client<handlers::GetSubmapSignature> client(client_channel_);
CHECK(client.Write(request));
submap_query_response->CopyFrom(client.response().submap_query_response());
return client.response().error_msg();
}
void MapBuilderStub::SerializeState(bool include_unfinished_submaps,
io::ProtoStreamWriterInterface* writer) {
if (include_unfinished_submaps) {
LOG(WARNING) << "Serializing unfinished submaps is currently unsupported. "
"Proceeding to write the state without them.";
}
google::protobuf::Empty request;
async_grpc::Client<handlers::WriteStateSignature> client(client_channel_);
CHECK(client.Write(request));
proto::WriteStateResponse response;
while (client.StreamRead(&response)) {
switch (response.state_chunk_case()) {
case proto::WriteStateResponse::kHeader:
writer->WriteProto(response.header());
break;
case proto::WriteStateResponse::kSerializedData:
writer->WriteProto(response.serialized_data());
break;
default:
LOG(FATAL) << "Unhandled message type";
}
}
}
bool MapBuilderStub::SerializeStateToFile(bool include_unfinished_submaps,
const std::string& filename) {
if (include_unfinished_submaps) {
LOG(WARNING) << "Serializing unfinished submaps is currently unsupported. "
"Proceeding to write the state without them.";
}
proto::WriteStateToFileRequest request;
request.set_filename(filename);
::grpc::Status status;
async_grpc::Client<handlers::WriteStateToFileSignature> client(
client_channel_);
if (!client.Write(request, &status)) {
LOG(ERROR) << "WriteStateToFileRequest failed - "
<< "code: " << status.error_code()
<< " reason: " << status.error_message();
}
return client.response().success();
}
std::map<int, int> MapBuilderStub::LoadState(
io::ProtoStreamReaderInterface* reader, const bool load_frozen_state) {
async_grpc::Client<handlers::LoadStateSignature> client(client_channel_);
{
proto::LoadStateRequest request;
request.set_client_id(client_id_);
CHECK(client.Write(request));
}
io::ProtoStreamDeserializer deserializer(reader);
// Request with the SerializationHeader proto is sent first.
{
proto::LoadStateRequest request;
*request.mutable_serialization_header() = deserializer.header();
request.set_load_frozen_state(load_frozen_state);
CHECK(client.Write(request));
}
// Request with a PoseGraph proto is sent second.
{
proto::LoadStateRequest request;
*request.mutable_serialized_data()->mutable_pose_graph() =
deserializer.pose_graph();
request.set_load_frozen_state(load_frozen_state);
CHECK(client.Write(request));
}
// Request with an AllTrajectoryBuilderOptions should be third.
{
proto::LoadStateRequest request;
*request.mutable_serialized_data()
->mutable_all_trajectory_builder_options() =
deserializer.all_trajectory_builder_options();
request.set_load_frozen_state(load_frozen_state);
CHECK(client.Write(request));
}
// Multiple requests with SerializedData are sent after.
proto::LoadStateRequest request;
while (
deserializer.ReadNextSerializedData(request.mutable_serialized_data())) {
request.set_load_frozen_state(load_frozen_state);
CHECK(client.Write(request));
}
CHECK(reader->eof());
CHECK(client.StreamWritesDone());
CHECK(client.StreamFinish().ok());
return FromProto(client.response().trajectory_remapping());
}
std::map<int, int> MapBuilderStub::LoadStateFromFile(
const std::string& filename, const bool load_frozen_state) {
proto::LoadStateFromFileRequest request;
request.set_file_path(filename);
request.set_client_id(client_id_);
request.set_load_frozen_state(load_frozen_state);
async_grpc::Client<handlers::LoadStateFromFileSignature> client(
client_channel_);
CHECK(client.Write(request));
return FromProto(client.response().trajectory_remapping());
}
int MapBuilderStub::num_trajectory_builders() const {
return trajectory_builder_stubs_.size();
}
mapping::PoseGraphInterface* MapBuilderStub::pose_graph() {
return pose_graph_stub_.get();
}
const std::vector<mapping::proto::TrajectoryBuilderOptionsWithSensorIds>&
MapBuilderStub::GetAllTrajectoryBuilderOptions() const {
LOG(FATAL) << "Not implemented";
}
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,75 @@
/*
* Copyright 2017 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_CLIENT_MAP_BUILDER_STUB_H_
#define CARTOGRAPHER_CLOUD_CLIENT_MAP_BUILDER_STUB_H_
#include <memory>
#include "cartographer/mapping/map_builder_interface.h"
#include "cartographer/mapping/pose_graph_interface.h"
#include "cartographer/mapping/trajectory_builder_interface.h"
#include "grpc++/grpc++.h"
namespace cartographer {
namespace cloud {
class MapBuilderStub : public mapping::MapBuilderInterface {
public:
MapBuilderStub(const std::string& server_address,
const std::string& client_id);
MapBuilderStub(const MapBuilderStub&) = delete;
MapBuilderStub& operator=(const MapBuilderStub&) = delete;
int AddTrajectoryBuilder(
const std::set<SensorId>& expected_sensor_ids,
const mapping::proto::TrajectoryBuilderOptions& trajectory_options,
LocalSlamResultCallback local_slam_result_callback) override;
int AddTrajectoryForDeserialization(
const mapping::proto::TrajectoryBuilderOptionsWithSensorIds&
options_with_sensor_ids_proto) override;
mapping::TrajectoryBuilderInterface* GetTrajectoryBuilder(
int trajectory_id) const override;
void FinishTrajectory(int trajectory_id) override;
std::string SubmapToProto(
const mapping::SubmapId& submap_id,
mapping::proto::SubmapQuery::Response* response) override;
void SerializeState(bool include_unfinished_submaps,
io::ProtoStreamWriterInterface* writer) override;
bool SerializeStateToFile(bool include_unfinished_submaps,
const std::string& filename) override;
std::map<int, int> LoadState(io::ProtoStreamReaderInterface* reader,
bool load_frozen_state) override;
std::map<int, int> LoadStateFromFile(const std::string& filename,
bool load_frozen_state) override;
int num_trajectory_builders() const override;
mapping::PoseGraphInterface* pose_graph() override;
const std::vector<mapping::proto::TrajectoryBuilderOptionsWithSensorIds>&
GetAllTrajectoryBuilderOptions() const override;
private:
std::shared_ptr<::grpc::Channel> client_channel_;
std::unique_ptr<mapping::PoseGraphInterface> pose_graph_stub_;
std::map<int, std::unique_ptr<mapping::TrajectoryBuilderInterface>>
trajectory_builder_stubs_;
const std::string client_id_;
};
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_CLIENT_MAP_BUILDER_STUB_H_

View File

@ -0,0 +1,223 @@
/*
* Copyright 2017 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/client/pose_graph_stub.h"
#include "async_grpc/client.h"
#include "cartographer/cloud/internal/handlers/delete_trajectory_handler.h"
#include "cartographer/cloud/internal/handlers/get_all_submap_poses.h"
#include "cartographer/cloud/internal/handlers/get_constraints_handler.h"
#include "cartographer/cloud/internal/handlers/get_landmark_poses_handler.h"
#include "cartographer/cloud/internal/handlers/get_local_to_global_transform_handler.h"
#include "cartographer/cloud/internal/handlers/get_trajectory_node_poses_handler.h"
#include "cartographer/cloud/internal/handlers/get_trajectory_states_handler.h"
#include "cartographer/cloud/internal/handlers/is_trajectory_finished_handler.h"
#include "cartographer/cloud/internal/handlers/is_trajectory_frozen_handler.h"
#include "cartographer/cloud/internal/handlers/run_final_optimization_handler.h"
#include "cartographer/cloud/internal/handlers/set_landmark_pose_handler.h"
#include "cartographer/cloud/internal/mapping/serialization.h"
#include "cartographer/mapping/pose_graph.h"
#include "cartographer/transform/transform.h"
#include "glog/logging.h"
namespace cartographer {
namespace cloud {
PoseGraphStub::PoseGraphStub(std::shared_ptr<::grpc::Channel> client_channel,
const std::string& client_id)
: client_channel_(client_channel), client_id_(client_id) {}
void PoseGraphStub::RunFinalOptimization() {
google::protobuf::Empty request;
async_grpc::Client<handlers::RunFinalOptimizationSignature> client(
client_channel_);
CHECK(client.Write(request));
}
mapping::MapById<mapping::SubmapId, mapping::PoseGraphInterface::SubmapData>
PoseGraphStub::GetAllSubmapData() const {
LOG(FATAL) << "Not implemented";
}
mapping::PoseGraphInterface::SubmapData PoseGraphStub::GetSubmapData(
const mapping::SubmapId& submap_id) const {
LOG(FATAL) << "Not implemented";
}
mapping::MapById<mapping::SubmapId, mapping::PoseGraphInterface::SubmapPose>
PoseGraphStub::GetAllSubmapPoses() const {
google::protobuf::Empty request;
async_grpc::Client<handlers::GetAllSubmapPosesSignature> client(
client_channel_);
CHECK(client.Write(request));
mapping::MapById<mapping::SubmapId, mapping::PoseGraphInterface::SubmapPose>
submap_poses;
for (const auto& submap_pose : client.response().submap_poses()) {
submap_poses.Insert(
mapping::SubmapId{submap_pose.submap_id().trajectory_id(),
submap_pose.submap_id().submap_index()},
mapping::PoseGraphInterface::SubmapPose{
submap_pose.submap_version(),
transform::ToRigid3(submap_pose.global_pose())});
}
return submap_poses;
}
transform::Rigid3d PoseGraphStub::GetLocalToGlobalTransform(
int trajectory_id) const {
proto::GetLocalToGlobalTransformRequest request;
request.set_trajectory_id(trajectory_id);
async_grpc::Client<handlers::GetLocalToGlobalTransformSignature> client(
client_channel_);
CHECK(client.Write(request));
return transform::ToRigid3(client.response().local_to_global());
}
mapping::MapById<mapping::NodeId, mapping::TrajectoryNode>
PoseGraphStub::GetTrajectoryNodes() const {
LOG(FATAL) << "Not implemented";
}
mapping::MapById<mapping::NodeId, mapping::TrajectoryNodePose>
PoseGraphStub::GetTrajectoryNodePoses() const {
google::protobuf::Empty request;
async_grpc::Client<handlers::GetTrajectoryNodePosesSignature> client(
client_channel_);
CHECK(client.Write(request));
mapping::MapById<mapping::NodeId, mapping::TrajectoryNodePose> node_poses;
for (const auto& node_pose : client.response().node_poses()) {
absl::optional<mapping::TrajectoryNodePose::ConstantPoseData>
constant_pose_data;
if (node_pose.has_constant_pose_data()) {
constant_pose_data = mapping::TrajectoryNodePose::ConstantPoseData{
common::FromUniversal(node_pose.constant_pose_data().timestamp()),
transform::ToRigid3(node_pose.constant_pose_data().local_pose())};
}
node_poses.Insert(
mapping::NodeId{node_pose.node_id().trajectory_id(),
node_pose.node_id().node_index()},
mapping::TrajectoryNodePose{
transform::ToRigid3(node_pose.global_pose()), constant_pose_data});
}
return node_poses;
}
std::map<int, mapping::PoseGraphInterface::TrajectoryState>
PoseGraphStub::GetTrajectoryStates() const {
google::protobuf::Empty request;
async_grpc::Client<handlers::GetTrajectoryStatesSignature> client(
client_channel_);
CHECK(client.Write(request));
std::map<int, mapping::PoseGraphInterface::TrajectoryState>
trajectories_state;
for (const auto& entry : client.response().trajectories_state()) {
trajectories_state[entry.first] = FromProto(entry.second);
}
return trajectories_state;
}
std::map<std::string, transform::Rigid3d> PoseGraphStub::GetLandmarkPoses()
const {
google::protobuf::Empty request;
async_grpc::Client<handlers::GetLandmarkPosesSignature> client(
client_channel_);
CHECK(client.Write(request));
std::map<std::string, transform::Rigid3d> landmark_poses;
for (const auto& landmark_pose : client.response().landmark_poses()) {
landmark_poses[landmark_pose.landmark_id()] =
transform::ToRigid3(landmark_pose.global_pose());
}
return landmark_poses;
}
void PoseGraphStub::SetLandmarkPose(const std::string& landmark_id,
const transform::Rigid3d& global_pose,
const bool frozen) {
proto::SetLandmarkPoseRequest request;
request.mutable_landmark_pose()->set_landmark_id(landmark_id);
*request.mutable_landmark_pose()->mutable_global_pose() =
transform::ToProto(global_pose);
async_grpc::Client<handlers::SetLandmarkPoseSignature> client(
client_channel_);
CHECK(client.Write(request));
}
void PoseGraphStub::DeleteTrajectory(int trajectory_id) {
proto::DeleteTrajectoryRequest request;
request.set_client_id(client_id_);
request.set_trajectory_id(trajectory_id);
async_grpc::Client<handlers::DeleteTrajectorySignature> client(
client_channel_);
::grpc::Status status;
client.Write(request, &status);
if (!status.ok()) {
LOG(ERROR) << "Failed to delete trajectory " << trajectory_id
<< " for client_id " << client_id_ << ": "
<< status.error_message();
}
}
bool PoseGraphStub::IsTrajectoryFinished(int trajectory_id) const {
proto::IsTrajectoryFinishedRequest request;
request.set_trajectory_id(trajectory_id);
async_grpc::Client<handlers::IsTrajectoryFinishedSignature> client(
client_channel_);
::grpc::Status status;
CHECK(client.Write(request, &status))
<< "Failed to check if trajectory " << trajectory_id
<< " is finished: " << status.error_message();
return client.response().is_finished();
}
bool PoseGraphStub::IsTrajectoryFrozen(int trajectory_id) const {
proto::IsTrajectoryFrozenRequest request;
request.set_trajectory_id(trajectory_id);
async_grpc::Client<handlers::IsTrajectoryFrozenSignature> client(
client_channel_);
::grpc::Status status;
CHECK(client.Write(request, &status))
<< "Failed to check if trajectory " << trajectory_id
<< " is frozen: " << status.error_message();
return client.response().is_frozen();
}
std::map<int, mapping::PoseGraphInterface::TrajectoryData>
PoseGraphStub::GetTrajectoryData() const {
LOG(FATAL) << "Not implemented";
}
std::vector<mapping::PoseGraphInterface::Constraint>
PoseGraphStub::constraints() const {
google::protobuf::Empty request;
async_grpc::Client<handlers::GetConstraintsSignature> client(client_channel_);
::grpc::Status status;
CHECK(client.Write(request, &status))
<< "Failed to get constraints: " << status.error_message();
return mapping::FromProto(client.response().constraints());
}
mapping::proto::PoseGraph PoseGraphStub::ToProto(
bool include_unfinished_submaps) const {
LOG(FATAL) << "Not implemented";
}
void PoseGraphStub::SetGlobalSlamOptimizationCallback(
GlobalSlamOptimizationCallback callback) {
LOG(FATAL) << "Not implemented";
}
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,70 @@
/*
* Copyright 2017 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_CLIENT_POSE_GRAPH_STUB_H_
#define CARTOGRAPHER_CLOUD_INTERNAL_CLIENT_POSE_GRAPH_STUB_H_
#include "cartographer/mapping/pose_graph_interface.h"
#include "grpc++/grpc++.h"
namespace cartographer {
namespace cloud {
class PoseGraphStub : public ::cartographer::mapping::PoseGraphInterface {
public:
PoseGraphStub(std::shared_ptr<::grpc::Channel> client_channel,
const std::string& client_id);
PoseGraphStub(const PoseGraphStub&) = delete;
PoseGraphStub& operator=(const PoseGraphStub&) = delete;
void RunFinalOptimization() override;
mapping::MapById<mapping::SubmapId, SubmapData> GetAllSubmapData()
const override;
SubmapData GetSubmapData(const mapping::SubmapId& submap_id) const override;
mapping::MapById<mapping::SubmapId, SubmapPose> GetAllSubmapPoses()
const override;
transform::Rigid3d GetLocalToGlobalTransform(
int trajectory_id) const override;
mapping::MapById<mapping::NodeId, mapping::TrajectoryNode>
GetTrajectoryNodes() const override;
mapping::MapById<mapping::NodeId, mapping::TrajectoryNodePose>
GetTrajectoryNodePoses() const override;
std::map<int, TrajectoryState> GetTrajectoryStates() const override;
std::map<std::string, transform::Rigid3d> GetLandmarkPoses() const override;
void SetLandmarkPose(const std::string& landmark_id,
const transform::Rigid3d& global_pose,
const bool frozen = false) override;
void DeleteTrajectory(int trajectory_id) override;
bool IsTrajectoryFinished(int trajectory_id) const override;
bool IsTrajectoryFrozen(int trajectory_id) const override;
std::map<int, mapping::PoseGraphInterface::TrajectoryData> GetTrajectoryData()
const override;
std::vector<Constraint> constraints() const override;
mapping::proto::PoseGraph ToProto(
bool include_unfinished_submaps) const override;
void SetGlobalSlamOptimizationCallback(
GlobalSlamOptimizationCallback callback) override;
private:
std::shared_ptr<::grpc::Channel> client_channel_;
const std::string client_id_;
};
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_CLIENT_POSE_GRAPH_STUB_H_

View File

@ -0,0 +1,173 @@
/*
* Copyright 2017 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/client/trajectory_builder_stub.h"
#include "cartographer/cloud/internal/sensor/serialization.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "cartographer/mapping/internal/local_slam_result_data.h"
#include "cartographer/transform/transform.h"
#include "glog/logging.h"
namespace cartographer {
namespace cloud {
TrajectoryBuilderStub::TrajectoryBuilderStub(
std::shared_ptr<::grpc::Channel> client_channel, const int trajectory_id,
const std::string& client_id,
LocalSlamResultCallback local_slam_result_callback)
: client_channel_(client_channel),
trajectory_id_(trajectory_id),
client_id_(client_id),
receive_local_slam_results_client_(client_channel_) {
if (local_slam_result_callback) {
proto::ReceiveLocalSlamResultsRequest request;
request.set_trajectory_id(trajectory_id);
receive_local_slam_results_client_.Write(request);
auto* receive_local_slam_results_client_ptr =
&receive_local_slam_results_client_;
receive_local_slam_results_thread_ = absl::make_unique<std::thread>(
[receive_local_slam_results_client_ptr, local_slam_result_callback]() {
RunLocalSlamResultsReader(receive_local_slam_results_client_ptr,
local_slam_result_callback);
});
}
}
TrajectoryBuilderStub::~TrajectoryBuilderStub() {
if (receive_local_slam_results_thread_) {
receive_local_slam_results_thread_->join();
}
if (add_rangefinder_client_) {
CHECK(add_rangefinder_client_->StreamWritesDone());
CHECK(add_rangefinder_client_->StreamFinish().ok());
}
if (add_imu_client_) {
CHECK(add_imu_client_->StreamWritesDone());
CHECK(add_imu_client_->StreamFinish().ok());
}
if (add_odometry_client_) {
CHECK(add_odometry_client_->StreamWritesDone());
CHECK(add_odometry_client_->StreamFinish().ok());
}
if (add_landmark_client_) {
CHECK(add_landmark_client_->StreamWritesDone());
CHECK(add_landmark_client_->StreamFinish().ok());
}
if (add_fixed_frame_pose_client_) {
CHECK(add_fixed_frame_pose_client_->StreamWritesDone());
CHECK(add_fixed_frame_pose_client_->StreamFinish().ok());
}
}
void TrajectoryBuilderStub::AddSensorData(
const std::string& sensor_id,
const sensor::TimedPointCloudData& timed_point_cloud_data) {
if (!add_rangefinder_client_) {
add_rangefinder_client_ = absl::make_unique<
async_grpc::Client<handlers::AddRangefinderDataSignature>>(
client_channel_);
}
proto::AddRangefinderDataRequest request;
CreateAddRangeFinderDataRequest(sensor_id, trajectory_id_, client_id_,
sensor::ToProto(timed_point_cloud_data),
&request);
add_rangefinder_client_->Write(request);
}
void TrajectoryBuilderStub::AddSensorData(const std::string& sensor_id,
const sensor::ImuData& imu_data) {
if (!add_imu_client_) {
add_imu_client_ =
absl::make_unique<async_grpc::Client<handlers::AddImuDataSignature>>(
client_channel_);
}
proto::AddImuDataRequest request;
CreateAddImuDataRequest(sensor_id, trajectory_id_, client_id_,
sensor::ToProto(imu_data), &request);
add_imu_client_->Write(request);
}
void TrajectoryBuilderStub::AddSensorData(
const std::string& sensor_id, const sensor::OdometryData& odometry_data) {
if (!add_odometry_client_) {
add_odometry_client_ = absl::make_unique<
async_grpc::Client<handlers::AddOdometryDataSignature>>(
client_channel_);
}
proto::AddOdometryDataRequest request;
CreateAddOdometryDataRequest(sensor_id, trajectory_id_, client_id_,
sensor::ToProto(odometry_data), &request);
add_odometry_client_->Write(request);
}
void TrajectoryBuilderStub::AddSensorData(
const std::string& sensor_id,
const sensor::FixedFramePoseData& fixed_frame_pose) {
if (!add_fixed_frame_pose_client_) {
add_fixed_frame_pose_client_ = absl::make_unique<
async_grpc::Client<handlers::AddFixedFramePoseDataSignature>>(
client_channel_);
}
proto::AddFixedFramePoseDataRequest request;
CreateAddFixedFramePoseDataRequest(sensor_id, trajectory_id_, client_id_,
sensor::ToProto(fixed_frame_pose),
&request);
add_fixed_frame_pose_client_->Write(request);
}
void TrajectoryBuilderStub::AddSensorData(
const std::string& sensor_id, const sensor::LandmarkData& landmark_data) {
if (!add_landmark_client_) {
add_landmark_client_ = absl::make_unique<
async_grpc::Client<handlers::AddLandmarkDataSignature>>(
client_channel_);
}
proto::AddLandmarkDataRequest request;
CreateAddLandmarkDataRequest(sensor_id, trajectory_id_, client_id_,
sensor::ToProto(landmark_data), &request);
add_landmark_client_->Write(request);
}
void TrajectoryBuilderStub::AddLocalSlamResultData(
std::unique_ptr<mapping::LocalSlamResultData> local_slam_result_data) {
LOG(FATAL) << "Not implemented";
}
void TrajectoryBuilderStub::RunLocalSlamResultsReader(
async_grpc::Client<handlers::ReceiveLocalSlamResultsSignature>* client,
LocalSlamResultCallback local_slam_result_callback) {
proto::ReceiveLocalSlamResultsResponse response;
while (client->StreamRead(&response)) {
int trajectory_id = response.trajectory_id();
common::Time time = common::FromUniversal(response.timestamp());
transform::Rigid3d local_pose = transform::ToRigid3(response.local_pose());
sensor::RangeData range_data = sensor::FromProto(response.range_data());
auto insertion_result =
response.has_insertion_result()
? absl::make_unique<InsertionResult>(
InsertionResult{mapping::NodeId{
response.insertion_result().node_id().trajectory_id(),
response.insertion_result().node_id().node_index()}})
: nullptr;
local_slam_result_callback(trajectory_id, time, local_pose, range_data,
std::move(insertion_result));
}
client->StreamFinish();
}
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,89 @@
/*
* Copyright 2017 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_CLIENT_TRAJECTORY_BUILDER_STUB_H_
#define CARTOGRAPHER_CLOUD_INTERNAL_CLIENT_TRAJECTORY_BUILDER_STUB_H_
#include <thread>
#include "async_grpc/client.h"
#include "cartographer/cloud/internal/handlers/add_fixed_frame_pose_data_handler.h"
#include "cartographer/cloud/internal/handlers/add_imu_data_handler.h"
#include "cartographer/cloud/internal/handlers/add_landmark_data_handler.h"
#include "cartographer/cloud/internal/handlers/add_odometry_data_handler.h"
#include "cartographer/cloud/internal/handlers/add_rangefinder_data_handler.h"
#include "cartographer/cloud/internal/handlers/receive_local_slam_results_handler.h"
#include "cartographer/mapping/internal/local_slam_result_data.h"
#include "cartographer/mapping/trajectory_builder_interface.h"
#include "grpc++/grpc++.h"
#include "pose_graph_stub.h"
#include "trajectory_builder_stub.h"
namespace cartographer {
namespace cloud {
class TrajectoryBuilderStub : public mapping::TrajectoryBuilderInterface {
public:
TrajectoryBuilderStub(std::shared_ptr<::grpc::Channel> client_channel,
const int trajectory_id, const std::string& client_id,
LocalSlamResultCallback local_slam_result_callback);
~TrajectoryBuilderStub() override;
TrajectoryBuilderStub(const TrajectoryBuilderStub&) = delete;
TrajectoryBuilderStub& operator=(const TrajectoryBuilderStub&) = delete;
void AddSensorData(
const std::string& sensor_id,
const sensor::TimedPointCloudData& timed_point_cloud_data) override;
void AddSensorData(const std::string& sensor_id,
const sensor::ImuData& imu_data) override;
void AddSensorData(const std::string& sensor_id,
const sensor::OdometryData& odometry_data) override;
void AddSensorData(
const std::string& sensor_id,
const sensor::FixedFramePoseData& fixed_frame_pose) override;
void AddSensorData(const std::string& sensor_id,
const sensor::LandmarkData& landmark_data) override;
void AddLocalSlamResultData(std::unique_ptr<mapping::LocalSlamResultData>
local_slam_result_data) override;
private:
static void RunLocalSlamResultsReader(
async_grpc::Client<handlers::ReceiveLocalSlamResultsSignature>*
client_reader,
LocalSlamResultCallback local_slam_result_callback);
std::shared_ptr<::grpc::Channel> client_channel_;
const int trajectory_id_;
const std::string client_id_;
std::unique_ptr<async_grpc::Client<handlers::AddRangefinderDataSignature>>
add_rangefinder_client_;
std::unique_ptr<async_grpc::Client<handlers::AddImuDataSignature>>
add_imu_client_;
std::unique_ptr<async_grpc::Client<handlers::AddOdometryDataSignature>>
add_odometry_client_;
std::unique_ptr<async_grpc::Client<handlers::AddFixedFramePoseDataSignature>>
add_fixed_frame_pose_client_;
std::unique_ptr<async_grpc::Client<handlers::AddLandmarkDataSignature>>
add_landmark_client_;
async_grpc::Client<handlers::ReceiveLocalSlamResultsSignature>
receive_local_slam_results_client_;
std::unique_ptr<std::thread> receive_local_slam_results_thread_;
};
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_CLIENT_TRAJECTORY_BUILDER_STUB_H_

View File

@ -0,0 +1,775 @@
/*
* Copyright 2017 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <condition_variable>
#include <mutex>
#include "cartographer/cloud/client/map_builder_stub.h"
#include "cartographer/cloud/internal/map_builder_server.h"
#include "cartographer/cloud/map_builder_server_options.h"
#include "cartographer/io/internal/in_memory_proto_stream.h"
#include "cartographer/io/internal/testing/test_helpers.h"
#include "cartographer/io/proto_stream.h"
#include "cartographer/io/proto_stream_deserializer.h"
#include "cartographer/mapping/internal/local_slam_result_data.h"
#include "cartographer/mapping/internal/testing/mock_map_builder.h"
#include "cartographer/mapping/internal/testing/mock_pose_graph.h"
#include "cartographer/mapping/internal/testing/mock_trajectory_builder.h"
#include "cartographer/mapping/internal/testing/test_helpers.h"
#include "cartographer/mapping/map_builder.h"
#include "glog/logging.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
using ::cartographer::io::testing::ProtoReaderFromStrings;
using ::cartographer::mapping::CreateMapBuilder;
using ::cartographer::mapping::MapBuilderInterface;
using ::cartographer::mapping::PoseGraphInterface;
using ::cartographer::mapping::TrajectoryBuilderInterface;
using ::cartographer::mapping::testing::MockMapBuilder;
using ::cartographer::mapping::testing::MockPoseGraph;
using ::cartographer::mapping::testing::MockTrajectoryBuilder;
using ::testing::_;
using SensorId = ::cartographer::mapping::TrajectoryBuilderInterface::SensorId;
namespace cartographer {
namespace cloud {
namespace {
constexpr char kClientId[] = "CLIENT_ID";
const SensorId kImuSensorId{SensorId::SensorType::IMU, "imu"};
const SensorId kRangeSensorId{SensorId::SensorType::RANGE, "range"};
constexpr double kDuration = 4.; // Seconds.
constexpr double kTimeStep = 0.1; // Seconds.
constexpr double kTravelDistance = 1.2; // Meters.
constexpr char kSerializationHeaderProtoString[] = "format_version: 2";
constexpr char kPoseGraphProtoString[] = R"(pose_graph {
trajectory: {
trajectory_id: 0
node: {}
submap: {}
}
})";
constexpr char kAllTrajectoryBuilderOptionsProtoString[] =
R"(all_trajectory_builder_options {
options_with_sensor_ids: {}
})";
constexpr char kSubmapProtoString[] = "submap {}";
constexpr char kNodeProtoString[] = "node {}";
constexpr char kTrajectoryDataProtoString[] = "trajectory_data {}";
constexpr char kImuDataProtoString[] = "imu_data {}";
constexpr char kOdometryDataProtoString[] = "odometry_data {}";
constexpr char kFixedFramePoseDataProtoString[] = "fixed_frame_pose_data {}";
constexpr char kLandmarkDataProtoString[] = "landmark_data {}";
template <class T>
class ClientServerTestBase : public T {
protected:
void SetUp() override {
// TODO(cschuet): Due to the hard-coded addresses these tests will become
// flaky when run in parallel.
const std::string kMapBuilderServerLua = R"text(
include "map_builder_server.lua"
MAP_BUILDER.use_trajectory_builder_2d = true
MAP_BUILDER.pose_graph.optimize_every_n_nodes = 0
MAP_BUILDER_SERVER.num_event_threads = 1
MAP_BUILDER_SERVER.num_grpc_threads = 1
MAP_BUILDER_SERVER.uplink_server_address = ""
MAP_BUILDER_SERVER.server_address = "0.0.0.0:50051"
return MAP_BUILDER_SERVER)text";
auto map_builder_server_parameters =
mapping::testing::ResolveLuaParameters(kMapBuilderServerLua);
map_builder_server_options_ =
CreateMapBuilderServerOptions(map_builder_server_parameters.get());
const std::string kUploadingMapBuilderServerLua = R"text(
include "map_builder_server.lua"
MAP_BUILDER.use_trajectory_builder_2d = true
MAP_BUILDER.pose_graph.optimize_every_n_nodes = 0
MAP_BUILDER_SERVER.num_event_threads = 1
MAP_BUILDER_SERVER.num_grpc_threads = 1
MAP_BUILDER_SERVER.uplink_server_address = "localhost:50051"
MAP_BUILDER_SERVER.server_address = "0.0.0.0:50052"
MAP_BUILDER_SERVER.upload_batch_size = 1
return MAP_BUILDER_SERVER)text";
auto uploading_map_builder_server_parameters =
mapping::testing::ResolveLuaParameters(kUploadingMapBuilderServerLua);
uploading_map_builder_server_options_ = CreateMapBuilderServerOptions(
uploading_map_builder_server_parameters.get());
EXPECT_NE(map_builder_server_options_.server_address(),
uploading_map_builder_server_options_.server_address());
const std::string kTrajectoryBuilderLua = R"text(
include "trajectory_builder.lua"
TRAJECTORY_BUILDER.trajectory_builder_2d.use_imu_data = false
TRAJECTORY_BUILDER.trajectory_builder_2d.submaps.num_range_data = 4
return TRAJECTORY_BUILDER)text";
auto trajectory_builder_parameters =
mapping::testing::ResolveLuaParameters(kTrajectoryBuilderLua);
trajectory_builder_options_ = mapping::CreateTrajectoryBuilderOptions(
trajectory_builder_parameters.get());
number_of_insertion_results_ = 0;
local_slam_result_callback_ =
[this](int, common::Time, transform::Rigid3d local_pose,
sensor::RangeData,
std::unique_ptr<
const mapping::TrajectoryBuilderInterface::InsertionResult>
insertion_result) {
std::unique_lock<std::mutex> lock(local_slam_result_mutex_);
if (insertion_result) {
++number_of_insertion_results_;
}
local_slam_result_poses_.push_back(local_pose);
lock.unlock();
local_slam_result_condition_.notify_all();
};
}
void InitializeRealServer() {
auto map_builder =
CreateMapBuilder(map_builder_server_options_.map_builder_options());
server_ = absl::make_unique<MapBuilderServer>(map_builder_server_options_,
std::move(map_builder));
EXPECT_TRUE(server_ != nullptr);
}
void InitializeRealUploadingServer() {
auto map_builder = CreateMapBuilder(
uploading_map_builder_server_options_.map_builder_options());
uploading_server_ = absl::make_unique<MapBuilderServer>(
uploading_map_builder_server_options_, std::move(map_builder));
EXPECT_TRUE(uploading_server_ != nullptr);
}
void InitializeServerWithMockMapBuilder() {
auto mock_map_builder = absl::make_unique<MockMapBuilder>();
mock_map_builder_ = mock_map_builder.get();
mock_pose_graph_ = absl::make_unique<MockPoseGraph>();
EXPECT_CALL(*mock_map_builder_, pose_graph())
.WillOnce(::testing::Return(mock_pose_graph_.get()));
EXPECT_CALL(*mock_pose_graph_, SetGlobalSlamOptimizationCallback(_));
server_ = absl::make_unique<MapBuilderServer>(map_builder_server_options_,
std::move(mock_map_builder));
EXPECT_TRUE(server_ != nullptr);
mock_trajectory_builder_ = absl::make_unique<MockTrajectoryBuilder>();
}
void InitializeStub() {
stub_ = absl::make_unique<MapBuilderStub>(
map_builder_server_options_.server_address(), kClientId);
EXPECT_TRUE(stub_ != nullptr);
}
void InitializeStubForUploadingServer() {
stub_for_uploading_server_ = absl::make_unique<MapBuilderStub>(
uploading_map_builder_server_options_.server_address(), kClientId);
EXPECT_TRUE(stub_for_uploading_server_ != nullptr);
}
void SetOptionsToTSDF2D() {
trajectory_builder_options_.mutable_trajectory_builder_2d_options()
->mutable_submaps_options()
->mutable_range_data_inserter_options()
->set_range_data_inserter_type(
::cartographer::mapping::proto::RangeDataInserterOptions::
TSDF_INSERTER_2D);
trajectory_builder_options_.mutable_trajectory_builder_2d_options()
->mutable_submaps_options()
->mutable_grid_options_2d()
->set_grid_type(::cartographer::mapping::proto::GridOptions2D::TSDF);
trajectory_builder_options_.mutable_trajectory_builder_2d_options()
->mutable_ceres_scan_matcher_options()
->set_occupied_space_weight(10.0);
map_builder_server_options_.mutable_map_builder_options()
->mutable_pose_graph_options()
->mutable_constraint_builder_options()
->mutable_ceres_scan_matcher_options()
->set_occupied_space_weight(50.0);
uploading_map_builder_server_options_.mutable_map_builder_options()
->mutable_pose_graph_options()
->mutable_constraint_builder_options()
->mutable_ceres_scan_matcher_options()
->set_occupied_space_weight(50.0);
}
void WaitForLocalSlamResults(size_t size) {
std::unique_lock<std::mutex> lock(local_slam_result_mutex_);
local_slam_result_condition_.wait(
lock, [&] { return local_slam_result_poses_.size() >= size; });
}
void WaitForLocalSlamResultUploads(size_t size) {
while (stub_->pose_graph()->GetTrajectoryNodePoses().size() < size) {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}
proto::MapBuilderServerOptions map_builder_server_options_;
proto::MapBuilderServerOptions uploading_map_builder_server_options_;
MockMapBuilder* mock_map_builder_;
std::unique_ptr<MockPoseGraph> mock_pose_graph_;
std::unique_ptr<MockTrajectoryBuilder> mock_trajectory_builder_;
::cartographer::mapping::proto::TrajectoryBuilderOptions
trajectory_builder_options_;
std::unique_ptr<MapBuilderServer> server_;
std::unique_ptr<MapBuilderServer> uploading_server_;
std::unique_ptr<MapBuilderStub> stub_;
std::unique_ptr<MapBuilderStub> stub_for_uploading_server_;
TrajectoryBuilderInterface::LocalSlamResultCallback
local_slam_result_callback_;
std::condition_variable local_slam_result_condition_;
std::condition_variable local_slam_result_upload_condition_;
std::mutex local_slam_result_mutex_;
std::mutex local_slam_result_upload_mutex_;
std::vector<transform::Rigid3d> local_slam_result_poses_;
int number_of_insertion_results_;
};
class ClientServerTest : public ClientServerTestBase<::testing::Test> {};
class ClientServerTestByGridType
: public ClientServerTestBase<
::testing::TestWithParam<::cartographer::mapping::GridType>> {};
INSTANTIATE_TEST_CASE_P(
ClientServerTestByGridType, ClientServerTestByGridType,
::testing::Values(::cartographer::mapping::GridType::PROBABILITY_GRID,
::cartographer::mapping::GridType::TSDF));
TEST_F(ClientServerTest, StartAndStopServer) {
InitializeRealServer();
server_->Start();
server_->Shutdown();
}
TEST_P(ClientServerTestByGridType, AddTrajectoryBuilder) {
if (GetParam() == ::cartographer::mapping::GridType::TSDF) {
SetOptionsToTSDF2D();
}
InitializeRealServer();
server_->Start();
InitializeStub();
int trajectory_id = stub_->AddTrajectoryBuilder(
{kImuSensorId}, trajectory_builder_options_, nullptr);
EXPECT_FALSE(stub_->pose_graph()->IsTrajectoryFinished(trajectory_id));
stub_->FinishTrajectory(trajectory_id);
EXPECT_TRUE(stub_->pose_graph()->IsTrajectoryFinished(trajectory_id));
EXPECT_FALSE(stub_->pose_graph()->IsTrajectoryFrozen(trajectory_id));
server_->Shutdown();
}
TEST_P(ClientServerTestByGridType, AddTrajectoryBuilderWithMock) {
if (GetParam() == ::cartographer::mapping::GridType::TSDF) {
SetOptionsToTSDF2D();
}
InitializeServerWithMockMapBuilder();
server_->Start();
InitializeStub();
std::set<SensorId> expected_sensor_ids = {kImuSensorId};
EXPECT_CALL(
*mock_map_builder_,
AddTrajectoryBuilder(::testing::ContainerEq(expected_sensor_ids), _, _))
.WillOnce(::testing::Return(3));
EXPECT_CALL(*mock_map_builder_, GetTrajectoryBuilder(_))
.WillRepeatedly(::testing::Return(nullptr));
int trajectory_id = stub_->AddTrajectoryBuilder(
expected_sensor_ids, trajectory_builder_options_, nullptr);
EXPECT_EQ(trajectory_id, 3);
EXPECT_CALL(*mock_map_builder_, FinishTrajectory(trajectory_id));
stub_->FinishTrajectory(trajectory_id);
server_->Shutdown();
}
TEST_P(ClientServerTestByGridType, AddSensorData) {
if (GetParam() == ::cartographer::mapping::GridType::TSDF) {
SetOptionsToTSDF2D();
}
trajectory_builder_options_.mutable_trajectory_builder_2d_options()
->set_use_imu_data(true);
InitializeRealServer();
server_->Start();
InitializeStub();
int trajectory_id = stub_->AddTrajectoryBuilder(
{kImuSensorId}, trajectory_builder_options_, nullptr);
TrajectoryBuilderInterface* trajectory_stub =
stub_->GetTrajectoryBuilder(trajectory_id);
sensor::ImuData imu_data{common::FromUniversal(42),
Eigen::Vector3d(0., 0., 9.8),
Eigen::Vector3d::Zero()};
trajectory_stub->AddSensorData(kImuSensorId.id, imu_data);
stub_->FinishTrajectory(trajectory_id);
server_->Shutdown();
}
TEST_P(ClientServerTestByGridType, AddSensorDataWithMock) {
if (GetParam() == ::cartographer::mapping::GridType::TSDF) {
SetOptionsToTSDF2D();
}
InitializeServerWithMockMapBuilder();
server_->Start();
InitializeStub();
std::set<SensorId> expected_sensor_ids = {kImuSensorId};
EXPECT_CALL(
*mock_map_builder_,
AddTrajectoryBuilder(::testing::ContainerEq(expected_sensor_ids), _, _))
.WillOnce(::testing::Return(3));
int trajectory_id = stub_->AddTrajectoryBuilder(
expected_sensor_ids, trajectory_builder_options_, nullptr);
EXPECT_EQ(trajectory_id, 3);
EXPECT_CALL(*mock_map_builder_, GetTrajectoryBuilder(_))
.WillRepeatedly(::testing::Return(mock_trajectory_builder_.get()));
mapping::TrajectoryBuilderInterface* trajectory_stub =
stub_->GetTrajectoryBuilder(trajectory_id);
sensor::ImuData imu_data{common::FromUniversal(42),
Eigen::Vector3d(0., 0., 9.8),
Eigen::Vector3d::Zero()};
EXPECT_CALL(*mock_trajectory_builder_,
AddSensorData(::testing::StrEq(kImuSensorId.id),
::testing::Matcher<const sensor::ImuData&>(_)))
.WillOnce(::testing::Return());
trajectory_stub->AddSensorData(kImuSensorId.id, imu_data);
EXPECT_CALL(*mock_map_builder_, FinishTrajectory(trajectory_id));
stub_->FinishTrajectory(trajectory_id);
server_->Shutdown();
}
TEST_P(ClientServerTestByGridType, LocalSlam2D) {
if (GetParam() == ::cartographer::mapping::GridType::TSDF) {
SetOptionsToTSDF2D();
}
InitializeRealServer();
server_->Start();
InitializeStub();
EXPECT_TRUE(stub_->pose_graph()->GetTrajectoryStates().empty());
int trajectory_id =
stub_->AddTrajectoryBuilder({kRangeSensorId}, trajectory_builder_options_,
local_slam_result_callback_);
TrajectoryBuilderInterface* trajectory_stub =
stub_->GetTrajectoryBuilder(trajectory_id);
const auto measurements = mapping::testing::GenerateFakeRangeMeasurements(
kTravelDistance, kDuration, kTimeStep);
for (const auto& measurement : measurements) {
trajectory_stub->AddSensorData(kRangeSensorId.id, measurement);
}
WaitForLocalSlamResults(measurements.size());
EXPECT_EQ(stub_->pose_graph()->GetTrajectoryStates().at(trajectory_id),
PoseGraphInterface::TrajectoryState::ACTIVE);
stub_->FinishTrajectory(trajectory_id);
stub_->pose_graph()->RunFinalOptimization();
EXPECT_EQ(stub_->pose_graph()->GetTrajectoryStates().at(trajectory_id),
PoseGraphInterface::TrajectoryState::FINISHED);
EXPECT_EQ(local_slam_result_poses_.size(), measurements.size());
EXPECT_NEAR(kTravelDistance,
(local_slam_result_poses_.back().translation() -
local_slam_result_poses_.front().translation())
.norm(),
0.1 * kTravelDistance);
server_->Shutdown();
}
TEST_P(ClientServerTestByGridType, LocalSlamAndDelete2D) {
if (GetParam() == ::cartographer::mapping::GridType::TSDF) {
SetOptionsToTSDF2D();
}
InitializeRealServer();
server_->Start();
InitializeStub();
int trajectory_id =
stub_->AddTrajectoryBuilder({kRangeSensorId}, trajectory_builder_options_,
local_slam_result_callback_);
TrajectoryBuilderInterface* trajectory_stub =
stub_->GetTrajectoryBuilder(trajectory_id);
const auto measurements = mapping::testing::GenerateFakeRangeMeasurements(
kTravelDistance, kDuration, kTimeStep);
for (const auto& measurement : measurements) {
trajectory_stub->AddSensorData(kRangeSensorId.id, measurement);
}
WaitForLocalSlamResults(measurements.size());
stub_->pose_graph()->RunFinalOptimization();
EXPECT_EQ(stub_->pose_graph()->GetTrajectoryStates().at(trajectory_id),
PoseGraphInterface::TrajectoryState::ACTIVE);
EXPECT_GT(stub_->pose_graph()->GetAllSubmapPoses().size(), 0);
EXPECT_GT(stub_->pose_graph()->GetTrajectoryNodePoses().size(), 0);
stub_->FinishTrajectory(trajectory_id);
stub_->pose_graph()->DeleteTrajectory(trajectory_id);
stub_->pose_graph()->RunFinalOptimization();
EXPECT_EQ(stub_->pose_graph()->GetTrajectoryStates().at(trajectory_id),
PoseGraphInterface::TrajectoryState::DELETED);
EXPECT_EQ(stub_->pose_graph()->GetAllSubmapPoses().size(), 0);
EXPECT_EQ(stub_->pose_graph()->GetTrajectoryNodePoses().size(), 0);
server_->Shutdown();
}
TEST_F(ClientServerTest, GlobalSlam3D) {
map_builder_server_options_.mutable_map_builder_options()
->set_use_trajectory_builder_2d(false);
map_builder_server_options_.mutable_map_builder_options()
->set_use_trajectory_builder_3d(true);
map_builder_server_options_.mutable_map_builder_options()
->mutable_pose_graph_options()
->set_optimize_every_n_nodes(3);
trajectory_builder_options_.mutable_trajectory_builder_3d_options()
->mutable_motion_filter_options()
->set_max_distance_meters(0);
trajectory_builder_options_.mutable_trajectory_builder_3d_options()
->mutable_motion_filter_options()
->set_max_angle_radians(0);
InitializeRealServer();
server_->Start();
InitializeStub();
int trajectory_id = stub_->AddTrajectoryBuilder(
{kRangeSensorId, kImuSensorId}, trajectory_builder_options_,
local_slam_result_callback_);
TrajectoryBuilderInterface* trajectory_stub =
stub_->GetTrajectoryBuilder(trajectory_id);
const auto measurements = mapping::testing::GenerateFakeRangeMeasurements(
kTravelDistance, kDuration, kTimeStep);
for (const auto& measurement : measurements) {
sensor::ImuData imu_data{
measurement.time - common::FromSeconds(kTimeStep / 2),
Eigen::Vector3d(0., 0., 9.8), Eigen::Vector3d::Zero()};
trajectory_stub->AddSensorData(kImuSensorId.id, imu_data);
trajectory_stub->AddSensorData(kRangeSensorId.id, measurement);
}
// First range data will not call back while initializing PoseExtrapolator, so
// expect one less.
WaitForLocalSlamResults(measurements.size() - 1);
stub_->FinishTrajectory(trajectory_id);
EXPECT_NEAR(kTravelDistance,
(local_slam_result_poses_.back().translation() -
local_slam_result_poses_.front().translation())
.norm(),
0.1 * kTravelDistance);
server_->Shutdown();
}
TEST_P(ClientServerTestByGridType, StartAndStopUploadingServerAndServer) {
if (GetParam() == ::cartographer::mapping::GridType::TSDF) {
SetOptionsToTSDF2D();
}
InitializeRealServer();
server_->Start();
InitializeRealUploadingServer();
uploading_server_->Start();
uploading_server_->Shutdown();
server_->Shutdown();
}
TEST_P(ClientServerTestByGridType, AddTrajectoryBuilderWithUploadingServer) {
if (GetParam() == ::cartographer::mapping::GridType::TSDF) {
SetOptionsToTSDF2D();
}
InitializeRealServer();
server_->Start();
InitializeRealUploadingServer();
uploading_server_->Start();
InitializeStub();
InitializeStubForUploadingServer();
int trajectory_id = stub_for_uploading_server_->AddTrajectoryBuilder(
{kImuSensorId}, trajectory_builder_options_, nullptr);
EXPECT_FALSE(stub_for_uploading_server_->pose_graph()->IsTrajectoryFinished(
trajectory_id));
EXPECT_FALSE(stub_->pose_graph()->IsTrajectoryFinished(trajectory_id));
stub_for_uploading_server_->FinishTrajectory(trajectory_id);
EXPECT_TRUE(stub_for_uploading_server_->pose_graph()->IsTrajectoryFinished(
trajectory_id));
EXPECT_TRUE(stub_->pose_graph()->IsTrajectoryFinished(trajectory_id));
EXPECT_FALSE(stub_for_uploading_server_->pose_graph()->IsTrajectoryFrozen(
trajectory_id));
EXPECT_FALSE(stub_->pose_graph()->IsTrajectoryFrozen(trajectory_id));
uploading_server_->Shutdown();
server_->Shutdown();
}
TEST_P(ClientServerTestByGridType, LocalSlam2DWithUploadingServer) {
if (GetParam() == ::cartographer::mapping::GridType::TSDF) {
SetOptionsToTSDF2D();
}
InitializeRealServer();
server_->Start();
InitializeStub();
InitializeRealUploadingServer();
uploading_server_->Start();
InitializeStubForUploadingServer();
int trajectory_id = stub_for_uploading_server_->AddTrajectoryBuilder(
{kRangeSensorId}, trajectory_builder_options_,
local_slam_result_callback_);
TrajectoryBuilderInterface* trajectory_stub =
stub_for_uploading_server_->GetTrajectoryBuilder(trajectory_id);
const auto measurements = mapping::testing::GenerateFakeRangeMeasurements(
kTravelDistance, kDuration, kTimeStep);
for (const auto& measurement : measurements) {
trajectory_stub->AddSensorData(kRangeSensorId.id, measurement);
}
WaitForLocalSlamResults(measurements.size());
WaitForLocalSlamResultUploads(number_of_insertion_results_);
std::queue<std::unique_ptr<google::protobuf::Message>> chunks;
io::ForwardingProtoStreamWriter writer(
[&chunks](const google::protobuf::Message* proto) -> bool {
if (!proto) {
return true;
}
std::unique_ptr<google::protobuf::Message> p(proto->New());
p->CopyFrom(*proto);
chunks.push(std::move(p));
return true;
});
stub_->SerializeState(false, &writer);
CHECK(writer.Close());
// Ensure it can be read.
io::InMemoryProtoStreamReader reader(std::move(chunks));
io::ProtoStreamDeserializer deserializer(&reader);
EXPECT_EQ(deserializer.pose_graph().trajectory_size(), 1);
stub_for_uploading_server_->FinishTrajectory(trajectory_id);
EXPECT_EQ(local_slam_result_poses_.size(), measurements.size());
EXPECT_NEAR(kTravelDistance,
(local_slam_result_poses_.back().translation() -
local_slam_result_poses_.front().translation())
.norm(),
0.1 * kTravelDistance);
uploading_server_->Shutdown();
server_->Shutdown();
}
TEST_P(ClientServerTestByGridType, LocalSlam2DUplinkServerRestarting) {
if (GetParam() == ::cartographer::mapping::GridType::TSDF) {
SetOptionsToTSDF2D();
}
InitializeRealServer();
server_->Start();
InitializeStub();
InitializeRealUploadingServer();
uploading_server_->Start();
InitializeStubForUploadingServer();
int trajectory_id = stub_for_uploading_server_->AddTrajectoryBuilder(
{kRangeSensorId}, trajectory_builder_options_,
local_slam_result_callback_);
TrajectoryBuilderInterface* trajectory_stub =
stub_for_uploading_server_->GetTrajectoryBuilder(trajectory_id);
const auto measurements = mapping::testing::GenerateFakeRangeMeasurements(
kTravelDistance, kDuration, kTimeStep);
// Insert half of the measurements.
for (unsigned int i = 0; i < measurements.size() / 2; ++i) {
trajectory_stub->AddSensorData(kRangeSensorId.id, measurements.at(i));
}
WaitForLocalSlamResults(measurements.size() / 2);
WaitForLocalSlamResultUploads(number_of_insertion_results_);
// Simulate a cloud server restart.
LOG(INFO) << "Simulating server restart.";
constexpr int kUplinkTrajectoryId = 0;
stub_->FinishTrajectory(kUplinkTrajectoryId);
server_->Shutdown();
server_->WaitForShutdown();
InitializeRealServer();
server_->Start();
InitializeStub();
// Insert the second half of the measurements.
for (unsigned int i = measurements.size() / 2; i < measurements.size(); ++i) {
trajectory_stub->AddSensorData(kRangeSensorId.id, measurements.at(i));
}
WaitForLocalSlamResults(measurements.size() / 2);
WaitForLocalSlamResultUploads(2);
stub_for_uploading_server_->FinishTrajectory(trajectory_id);
uploading_server_->Shutdown();
uploading_server_->WaitForShutdown();
server_->Shutdown();
server_->WaitForShutdown();
}
TEST_F(ClientServerTest, DelayedConnectionToUplinkServer) {
InitializeRealUploadingServer();
uploading_server_->Start();
InitializeStubForUploadingServer();
int trajectory_id = stub_for_uploading_server_->AddTrajectoryBuilder(
{kRangeSensorId}, trajectory_builder_options_,
local_slam_result_callback_);
TrajectoryBuilderInterface* trajectory_stub =
stub_for_uploading_server_->GetTrajectoryBuilder(trajectory_id);
const auto measurements = mapping::testing::GenerateFakeRangeMeasurements(
kTravelDistance, kDuration, kTimeStep);
// Insert the first measurement.
trajectory_stub->AddSensorData(kRangeSensorId.id, measurements.at(0));
WaitForLocalSlamResults(1);
LOG(INFO) << "Delayed start of uplink server.";
InitializeRealServer();
server_->Start();
InitializeStub();
// Insert all other measurements.
for (unsigned int i = 1; i < measurements.size(); ++i) {
trajectory_stub->AddSensorData(kRangeSensorId.id, measurements.at(i));
}
WaitForLocalSlamResults(measurements.size());
WaitForLocalSlamResultUploads(2);
stub_for_uploading_server_->FinishTrajectory(trajectory_id);
uploading_server_->Shutdown();
uploading_server_->WaitForShutdown();
server_->Shutdown();
server_->WaitForShutdown();
}
TEST_P(ClientServerTestByGridType, LoadStateAndDelete) {
if (GetParam() == ::cartographer::mapping::GridType::TSDF) {
SetOptionsToTSDF2D();
}
InitializeRealServer();
server_->Start();
InitializeStub();
// Load text proto into in_memory_reader.
auto reader =
ProtoReaderFromStrings(kSerializationHeaderProtoString,
{
kPoseGraphProtoString,
kAllTrajectoryBuilderOptionsProtoString,
kSubmapProtoString,
kNodeProtoString,
kImuDataProtoString,
kOdometryDataProtoString,
kLandmarkDataProtoString,
});
auto trajectory_remapping = stub_->LoadState(reader.get(), true);
int expected_trajectory_id = 0;
EXPECT_EQ(trajectory_remapping.size(), 1);
EXPECT_EQ(trajectory_remapping.at(0), expected_trajectory_id);
stub_->pose_graph()->RunFinalOptimization();
EXPECT_TRUE(stub_->pose_graph()->IsTrajectoryFrozen(expected_trajectory_id));
EXPECT_FALSE(
stub_->pose_graph()->IsTrajectoryFinished(expected_trajectory_id));
for (const auto& entry : trajectory_remapping) {
int trajectory_id = entry.second;
stub_->pose_graph()->DeleteTrajectory(trajectory_id);
stub_->pose_graph()->RunFinalOptimization();
EXPECT_EQ(stub_->pose_graph()->GetTrajectoryStates().at(trajectory_id),
PoseGraphInterface::TrajectoryState::DELETED);
}
server_->Shutdown();
}
TEST_P(ClientServerTestByGridType, LoadUnfrozenStateAndDelete) {
if (GetParam() == ::cartographer::mapping::GridType::TSDF) {
SetOptionsToTSDF2D();
}
InitializeRealServer();
server_->Start();
InitializeStub();
// Load text proto into in_memory_reader.
auto reader =
ProtoReaderFromStrings(kSerializationHeaderProtoString,
{
kPoseGraphProtoString,
kAllTrajectoryBuilderOptionsProtoString,
kSubmapProtoString,
kNodeProtoString,
kImuDataProtoString,
kOdometryDataProtoString,
kLandmarkDataProtoString,
});
auto trajectory_remapping =
stub_->LoadState(reader.get(), false /* load_frozen_state */);
int expected_trajectory_id = 0;
EXPECT_EQ(trajectory_remapping.size(), 1);
EXPECT_EQ(trajectory_remapping.at(0), expected_trajectory_id);
stub_->pose_graph()->RunFinalOptimization();
EXPECT_FALSE(stub_->pose_graph()->IsTrajectoryFrozen(expected_trajectory_id));
EXPECT_FALSE(
stub_->pose_graph()->IsTrajectoryFinished(expected_trajectory_id));
EXPECT_EQ(
stub_->pose_graph()->GetTrajectoryStates().at(expected_trajectory_id),
PoseGraphInterface::TrajectoryState::ACTIVE);
stub_->FinishTrajectory(expected_trajectory_id);
EXPECT_EQ(
stub_->pose_graph()->GetTrajectoryStates().at(expected_trajectory_id),
PoseGraphInterface::TrajectoryState::FINISHED);
for (const auto& entry : trajectory_remapping) {
int trajectory_id = entry.second;
stub_->pose_graph()->DeleteTrajectory(trajectory_id);
stub_->pose_graph()->RunFinalOptimization();
EXPECT_EQ(stub_->pose_graph()->GetTrajectoryStates().at(trajectory_id),
PoseGraphInterface::TrajectoryState::DELETED);
}
server_->Shutdown();
}
// TODO(gaschler): Test-cover LoadStateFromFile.
TEST_P(ClientServerTestByGridType, LocalSlam2DHandlesInvalidRequests) {
if (GetParam() == ::cartographer::mapping::GridType::TSDF) {
SetOptionsToTSDF2D();
}
InitializeRealServer();
server_->Start();
InitializeStub();
int trajectory_id =
stub_->AddTrajectoryBuilder({kRangeSensorId}, trajectory_builder_options_,
local_slam_result_callback_);
TrajectoryBuilderInterface* trajectory_stub =
stub_->GetTrajectoryBuilder(trajectory_id);
const auto measurements = mapping::testing::GenerateFakeRangeMeasurements(
kTravelDistance, kDuration, kTimeStep);
for (const auto& measurement : measurements) {
trajectory_stub->AddSensorData(kRangeSensorId.id, measurement);
}
WaitForLocalSlamResults(measurements.size());
stub_->pose_graph()->RunFinalOptimization();
const int kInvalidTrajectoryId = 7;
stub_->pose_graph()->DeleteTrajectory(kInvalidTrajectoryId);
EXPECT_FALSE(stub_->pose_graph()->IsTrajectoryFinished(kInvalidTrajectoryId));
EXPECT_FALSE(stub_->pose_graph()->IsTrajectoryFrozen(kInvalidTrajectoryId));
EXPECT_EQ(nullptr, stub_->GetTrajectoryBuilder(kInvalidTrajectoryId));
stub_->FinishTrajectory(kInvalidTrajectoryId);
const mapping::SubmapId kInvalidSubmapId0{kInvalidTrajectoryId, 0},
kInvalidSubmapId1{trajectory_id, 424242};
mapping::proto::SubmapQuery::Response submap_query_response;
// Expect that it returns non-empty error string.
EXPECT_NE("",
stub_->SubmapToProto(kInvalidSubmapId0, &submap_query_response));
EXPECT_NE("",
stub_->SubmapToProto(kInvalidSubmapId1, &submap_query_response));
EXPECT_EQ(stub_->pose_graph()->GetTrajectoryStates().at(trajectory_id),
PoseGraphInterface::TrajectoryState::ACTIVE);
auto submap_poses = stub_->pose_graph()->GetAllSubmapPoses();
EXPECT_GT(submap_poses.size(), 0);
EXPECT_GT(stub_->pose_graph()->GetTrajectoryNodePoses().size(), 0);
stub_->FinishTrajectory(trajectory_id);
stub_->pose_graph()->DeleteTrajectory(trajectory_id);
stub_->pose_graph()->RunFinalOptimization();
mapping::SubmapId deleted_submap_id = submap_poses.begin()->id;
EXPECT_NE("",
stub_->SubmapToProto(deleted_submap_id, &submap_query_response));
EXPECT_EQ(stub_->pose_graph()->GetTrajectoryStates().at(trajectory_id),
PoseGraphInterface::TrajectoryState::DELETED);
// Make sure optimization runs with a deleted trajectory.
stub_->pose_graph()->RunFinalOptimization();
server_->Shutdown();
}
} // namespace
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,60 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/add_fixed_frame_pose_data_handler.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/internal/sensor/serialization.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "cartographer/sensor/fixed_frame_pose_data.h"
#include "cartographer/sensor/internal/dispatchable.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void AddFixedFramePoseDataHandler::OnSensorData(
const proto::AddFixedFramePoseDataRequest& request) {
// The 'BlockingQueue' returned by 'sensor_data_queue()' is already
// thread-safe. Therefore it suffices to get an unsynchronized reference to
// the 'MapBuilderContext'.
GetUnsynchronizedContext<MapBuilderContextInterface>()->EnqueueSensorData(
request.sensor_metadata().trajectory_id(),
sensor::MakeDispatchable(
request.sensor_metadata().sensor_id(),
sensor::FromProto(request.fixed_frame_pose_data())));
// The 'BlockingQueue' in 'LocalTrajectoryUploader' is thread-safe.
// Therefore it suffices to get an unsynchronized reference to the
// 'MapBuilderContext'.
if (GetUnsynchronizedContext<MapBuilderContextInterface>()
->local_trajectory_uploader()) {
auto sensor_data = absl::make_unique<proto::SensorData>();
*sensor_data->mutable_sensor_metadata() = request.sensor_metadata();
*sensor_data->mutable_fixed_frame_pose_data() =
request.fixed_frame_pose_data();
GetUnsynchronizedContext<MapBuilderContextInterface>()
->local_trajectory_uploader()
->EnqueueSensorData(std::move(sensor_data));
}
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,46 @@
/*
* Copyright 2017 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_FIXED_FRAME_POSE_DATA_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_FIXED_FRAME_POSE_DATA_HANDLER_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/handlers/add_sensor_data_handler_base.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
AddFixedFramePoseDataSignature,
async_grpc::Stream<proto::AddFixedFramePoseDataRequest>,
google::protobuf::Empty,
"/cartographer.cloud.proto.MapBuilderService/AddFixedFramePoseData")
class AddFixedFramePoseDataHandler
: public AddSensorDataHandlerBase<AddFixedFramePoseDataSignature> {
public:
void OnSensorData(
const proto::AddFixedFramePoseDataRequest& request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_FIXED_FRAME_POSE_DATA_HANDLER_H

View File

@ -0,0 +1,103 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/add_fixed_frame_pose_data_handler.h"
#include "cartographer/cloud/internal/testing/handler_test.h"
#include "cartographer/cloud/internal/testing/test_helpers.h"
#include "google/protobuf/text_format.h"
#include "gtest/gtest.h"
namespace cartographer {
namespace cloud {
namespace handlers {
namespace {
using ::testing::_;
using ::testing::Eq;
using ::testing::Pointee;
using ::testing::Truly;
const std::string kMessage = R"(
sensor_metadata {
trajectory_id: 1
sensor_id: "sensor_id"
}
fixed_frame_pose_data {
timestamp: 2
pose {
translation {
x: 3 y: 4 z: 5
}
rotation {
w: 6 x: 7 y: 8 z: 9
}
}
})";
using AddFixedFramePoseDataHandlerTest =
testing::HandlerTest<AddFixedFramePoseDataSignature,
AddFixedFramePoseDataHandler>;
TEST_F(AddFixedFramePoseDataHandlerTest, NoLocalSlamUploader) {
proto::AddFixedFramePoseDataRequest request;
EXPECT_TRUE(
google::protobuf::TextFormat::ParseFromString(kMessage, &request));
SetNoLocalTrajectoryUploader();
EXPECT_CALL(
*mock_map_builder_context_,
CheckClientIdForTrajectory(Eq(request.sensor_metadata().client_id()),
Eq(request.sensor_metadata().trajectory_id())))
.WillOnce(::testing::Return(true));
EXPECT_CALL(*mock_map_builder_context_,
DoEnqueueSensorData(
Eq(request.sensor_metadata().trajectory_id()),
Pointee(Truly(testing::BuildDataPredicateEquals(request)))));
test_server_->SendWrite(request);
test_server_->SendWritesDone();
test_server_->SendFinish();
}
TEST_F(AddFixedFramePoseDataHandlerTest, WithMockLocalSlamUploader) {
proto::AddFixedFramePoseDataRequest request;
EXPECT_TRUE(
google::protobuf::TextFormat::ParseFromString(kMessage, &request));
SetMockLocalTrajectoryUploader();
EXPECT_CALL(
*mock_map_builder_context_,
CheckClientIdForTrajectory(Eq(request.sensor_metadata().client_id()),
Eq(request.sensor_metadata().trajectory_id())))
.WillOnce(::testing::Return(true));
EXPECT_CALL(*mock_map_builder_context_,
DoEnqueueSensorData(
Eq(request.sensor_metadata().trajectory_id()),
Pointee(Truly(testing::BuildDataPredicateEquals(request)))));
proto::SensorData sensor_data;
*sensor_data.mutable_sensor_metadata() = request.sensor_metadata();
*sensor_data.mutable_fixed_frame_pose_data() =
request.fixed_frame_pose_data();
EXPECT_CALL(*mock_local_trajectory_uploader_,
DoEnqueueSensorData(Pointee(
Truly(testing::BuildProtoPredicateEquals(&sensor_data)))));
test_server_->SendWrite(request);
test_server_->SendWritesDone();
test_server_->SendFinish();
}
} // namespace
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,57 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/add_imu_data_handler.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/internal/sensor/serialization.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "cartographer/sensor/imu_data.h"
#include "cartographer/sensor/internal/dispatchable.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void AddImuDataHandler::OnSensorData(const proto::AddImuDataRequest& request) {
// The 'BlockingQueue' returned by 'sensor_data_queue()' is already
// thread-safe. Therefore it suffices to get an unsynchronized reference to
// the 'MapBuilderContext'.
GetUnsynchronizedContext<MapBuilderContextInterface>()->EnqueueSensorData(
request.sensor_metadata().trajectory_id(),
sensor::MakeDispatchable(request.sensor_metadata().sensor_id(),
sensor::FromProto(request.imu_data())));
// The 'BlockingQueue' in 'LocalTrajectoryUploader' is thread-safe.
// Therefore it suffices to get an unsynchronized reference to the
// 'MapBuilderContext'.
if (GetUnsynchronizedContext<MapBuilderContextInterface>()
->local_trajectory_uploader()) {
auto sensor_data = absl::make_unique<proto::SensorData>();
*sensor_data->mutable_sensor_metadata() = request.sensor_metadata();
*sensor_data->mutable_imu_data() = request.imu_data();
GetUnsynchronizedContext<MapBuilderContextInterface>()
->local_trajectory_uploader()
->EnqueueSensorData(std::move(sensor_data));
}
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,43 @@
/*
* Copyright 2017 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_IMU_DATA_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_IMU_DATA_HANDLER_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/handlers/add_sensor_data_handler_base.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
AddImuDataSignature, async_grpc::Stream<proto::AddImuDataRequest>,
google::protobuf::Empty,
"/cartographer.cloud.proto.MapBuilderService/AddImuData")
class AddImuDataHandler : public AddSensorDataHandlerBase<AddImuDataSignature> {
public:
void OnSensorData(const proto::AddImuDataRequest& request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_IMU_DATA_HANDLER_H

View File

@ -0,0 +1,99 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/add_imu_data_handler.h"
#include "cartographer/cloud/internal/testing/handler_test.h"
#include "cartographer/cloud/internal/testing/test_helpers.h"
#include "google/protobuf/text_format.h"
#include "gtest/gtest.h"
namespace cartographer {
namespace cloud {
namespace handlers {
namespace {
using ::testing::_;
using ::testing::Eq;
using ::testing::Pointee;
using ::testing::Truly;
const std::string kMessage = R"(
sensor_metadata {
trajectory_id: 1
sensor_id: "sensor_id"
}
imu_data {
timestamp: 2
linear_acceleration {
x: 3 y: 4 z: 5
}
angular_velocity {
x: 6 y: 7 z: 8
}
})";
using AddImuDataHandlerTest =
testing::HandlerTest<AddImuDataSignature, AddImuDataHandler>;
TEST_F(AddImuDataHandlerTest, NoLocalSlamUploader) {
proto::AddImuDataRequest request;
EXPECT_TRUE(
google::protobuf::TextFormat::ParseFromString(kMessage, &request));
SetNoLocalTrajectoryUploader();
EXPECT_CALL(
*mock_map_builder_context_,
CheckClientIdForTrajectory(Eq(request.sensor_metadata().client_id()),
Eq(request.sensor_metadata().trajectory_id())))
.WillOnce(::testing::Return(true));
EXPECT_CALL(*mock_map_builder_context_,
DoEnqueueSensorData(
Eq(request.sensor_metadata().trajectory_id()),
Pointee(Truly(testing::BuildDataPredicateEquals(request)))));
test_server_->SendWrite(request);
test_server_->SendWritesDone();
test_server_->SendFinish();
}
TEST_F(AddImuDataHandlerTest, WithMockLocalSlamUploader) {
proto::AddImuDataRequest request;
EXPECT_TRUE(
google::protobuf::TextFormat::ParseFromString(kMessage, &request));
SetMockLocalTrajectoryUploader();
EXPECT_CALL(
*mock_map_builder_context_,
CheckClientIdForTrajectory(Eq(request.sensor_metadata().client_id()),
Eq(request.sensor_metadata().trajectory_id())))
.WillOnce(::testing::Return(true));
EXPECT_CALL(*mock_map_builder_context_,
DoEnqueueSensorData(
Eq(request.sensor_metadata().trajectory_id()),
Pointee(Truly(testing::BuildDataPredicateEquals(request)))));
proto::SensorData sensor_data;
*sensor_data.mutable_sensor_metadata() = request.sensor_metadata();
*sensor_data.mutable_imu_data() = request.imu_data();
EXPECT_CALL(*mock_local_trajectory_uploader_,
DoEnqueueSensorData(Pointee(
Truly(testing::BuildProtoPredicateEquals(&sensor_data)))));
test_server_->SendWrite(request);
test_server_->SendWritesDone();
test_server_->SendFinish();
}
} // namespace
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,58 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/add_landmark_data_handler.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/internal/sensor/serialization.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "cartographer/sensor/internal/dispatchable.h"
#include "cartographer/sensor/landmark_data.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void AddLandmarkDataHandler::OnSensorData(
const proto::AddLandmarkDataRequest& request) {
// The 'BlockingQueue' returned by 'sensor_data_queue()' is already
// thread-safe. Therefore it suffices to get an unsynchronized reference to
// the 'MapBuilderContext'.
GetUnsynchronizedContext<MapBuilderContextInterface>()->EnqueueSensorData(
request.sensor_metadata().trajectory_id(),
sensor::MakeDispatchable(request.sensor_metadata().sensor_id(),
sensor::FromProto(request.landmark_data())));
// The 'BlockingQueue' in 'LocalTrajectoryUploader' is thread-safe.
// Therefore it suffices to get an unsynchronized reference to the
// 'MapBuilderContext'.
if (GetUnsynchronizedContext<MapBuilderContextInterface>()
->local_trajectory_uploader()) {
auto sensor_data = absl::make_unique<proto::SensorData>();
*sensor_data->mutable_sensor_metadata() = request.sensor_metadata();
*sensor_data->mutable_landmark_data() = request.landmark_data();
GetUnsynchronizedContext<MapBuilderContextInterface>()
->local_trajectory_uploader()
->EnqueueSensorData(std::move(sensor_data));
}
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,44 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_LANDMARK_DATA_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_LANDMARK_DATA_HANDLER_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/handlers/add_sensor_data_handler_base.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
AddLandmarkDataSignature, async_grpc::Stream<proto::AddLandmarkDataRequest>,
google::protobuf::Empty,
"/cartographer.cloud.proto.MapBuilderService/AddLandmarkData")
class AddLandmarkDataHandler
: public AddSensorDataHandlerBase<AddLandmarkDataSignature> {
public:
void OnSensorData(const proto::AddLandmarkDataRequest& request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_LANDMARK_DATA_HANDLER_H

View File

@ -0,0 +1,106 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/add_landmark_data_handler.h"
#include "cartographer/cloud/internal/testing/handler_test.h"
#include "cartographer/cloud/internal/testing/test_helpers.h"
#include "google/protobuf/text_format.h"
#include "gtest/gtest.h"
namespace cartographer {
namespace cloud {
namespace handlers {
namespace {
using ::testing::_;
using ::testing::Eq;
using ::testing::Pointee;
using ::testing::Truly;
const std::string kMessage = R"(
sensor_metadata {
trajectory_id: 1
sensor_id: "sensor_id"
}
landmark_data {
timestamp: 2
landmark_observations {
id: "3"
landmark_to_tracking_transform {
translation {
x: 4 y: 5 z: 6
}
rotation {
w:7 x: 8 y: 9 z: 10
}
}
translation_weight: 11.0
rotation_weight: 12.0
}
})";
using AddLandmarkDataHandlerTest =
testing::HandlerTest<AddLandmarkDataSignature, AddLandmarkDataHandler>;
TEST_F(AddLandmarkDataHandlerTest, NoLocalSlamUploader) {
proto::AddLandmarkDataRequest request;
EXPECT_TRUE(
google::protobuf::TextFormat::ParseFromString(kMessage, &request));
SetNoLocalTrajectoryUploader();
EXPECT_CALL(
*mock_map_builder_context_,
CheckClientIdForTrajectory(Eq(request.sensor_metadata().client_id()),
Eq(request.sensor_metadata().trajectory_id())))
.WillOnce(::testing::Return(true));
EXPECT_CALL(*mock_map_builder_context_,
DoEnqueueSensorData(
Eq(request.sensor_metadata().trajectory_id()),
Pointee(Truly(testing::BuildDataPredicateEquals(request)))));
test_server_->SendWrite(request);
test_server_->SendWritesDone();
test_server_->SendFinish();
}
TEST_F(AddLandmarkDataHandlerTest, WithMockLocalSlamUploader) {
proto::AddLandmarkDataRequest request;
EXPECT_TRUE(
google::protobuf::TextFormat::ParseFromString(kMessage, &request));
SetMockLocalTrajectoryUploader();
EXPECT_CALL(
*mock_map_builder_context_,
CheckClientIdForTrajectory(Eq(request.sensor_metadata().client_id()),
Eq(request.sensor_metadata().trajectory_id())))
.WillOnce(::testing::Return(true));
EXPECT_CALL(*mock_map_builder_context_,
DoEnqueueSensorData(
Eq(request.sensor_metadata().trajectory_id()),
Pointee(Truly(testing::BuildDataPredicateEquals(request)))));
proto::SensorData sensor_data;
*sensor_data.mutable_sensor_metadata() = request.sensor_metadata();
*sensor_data.mutable_landmark_data() = request.landmark_data();
EXPECT_CALL(*mock_local_trajectory_uploader_,
DoEnqueueSensorData(Pointee(
Truly(testing::BuildProtoPredicateEquals(&sensor_data)))));
test_server_->SendWrite(request);
test_server_->SendWritesDone();
test_server_->SendFinish();
}
} // namespace
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,58 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/add_odometry_data_handler.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/internal/sensor/serialization.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "cartographer/sensor/internal/dispatchable.h"
#include "cartographer/sensor/odometry_data.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void AddOdometryDataHandler::OnSensorData(
const proto::AddOdometryDataRequest& request) {
// The 'BlockingQueue' returned by 'sensor_data_queue()' is already
// thread-safe. Therefore it suffices to get an unsynchronized reference to
// the 'MapBuilderContext'.
GetUnsynchronizedContext<MapBuilderContextInterface>()->EnqueueSensorData(
request.sensor_metadata().trajectory_id(),
sensor::MakeDispatchable(request.sensor_metadata().sensor_id(),
sensor::FromProto(request.odometry_data())));
// The 'BlockingQueue' in 'LocalTrajectoryUploader' is thread-safe.
// Therefore it suffices to get an unsynchronized reference to the
// 'MapBuilderContext'.
if (GetUnsynchronizedContext<MapBuilderContextInterface>()
->local_trajectory_uploader()) {
auto sensor_data = absl::make_unique<proto::SensorData>();
*sensor_data->mutable_sensor_metadata() = request.sensor_metadata();
*sensor_data->mutable_odometry_data() = request.odometry_data();
GetUnsynchronizedContext<MapBuilderContextInterface>()
->local_trajectory_uploader()
->EnqueueSensorData(std::move(sensor_data));
}
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,44 @@
/*
* Copyright 2017 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_ODOMETRY_DATA_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_ODOMETRY_DATA_HANDLER_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/handlers/add_sensor_data_handler_base.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
AddOdometryDataSignature, async_grpc::Stream<proto::AddOdometryDataRequest>,
google::protobuf::Empty,
"/cartographer.cloud.proto.MapBuilderService/AddOdometryData")
class AddOdometryDataHandler
: public AddSensorDataHandlerBase<AddOdometryDataSignature> {
public:
void OnSensorData(const proto::AddOdometryDataRequest& request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_ODOMETRY_DATA_HANDLER_H

View File

@ -0,0 +1,101 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/add_odometry_data_handler.h"
#include "cartographer/cloud/internal/testing/handler_test.h"
#include "cartographer/cloud/internal/testing/test_helpers.h"
#include "google/protobuf/text_format.h"
#include "gtest/gtest.h"
namespace cartographer {
namespace cloud {
namespace handlers {
namespace {
using ::testing::_;
using ::testing::Eq;
using ::testing::Pointee;
using ::testing::Truly;
const std::string kMessage = R"(
sensor_metadata {
trajectory_id: 1
sensor_id: "sensor_id"
}
odometry_data {
timestamp: 2
pose {
translation {
x: 3 y: 4 z: 5
}
rotation {
w: 6 x: 7 y: 8 z: 9
}
}
})";
using AddOdometryDataHandlerTest =
testing::HandlerTest<AddOdometryDataSignature, AddOdometryDataHandler>;
TEST_F(AddOdometryDataHandlerTest, NoLocalSlamUploader) {
proto::AddOdometryDataRequest request;
EXPECT_TRUE(
google::protobuf::TextFormat::ParseFromString(kMessage, &request));
SetNoLocalTrajectoryUploader();
EXPECT_CALL(
*mock_map_builder_context_,
CheckClientIdForTrajectory(Eq(request.sensor_metadata().client_id()),
Eq(request.sensor_metadata().trajectory_id())))
.WillOnce(::testing::Return(true));
EXPECT_CALL(*mock_map_builder_context_,
DoEnqueueSensorData(
Eq(request.sensor_metadata().trajectory_id()),
Pointee(Truly(testing::BuildDataPredicateEquals(request)))));
test_server_->SendWrite(request);
test_server_->SendWritesDone();
test_server_->SendFinish();
}
TEST_F(AddOdometryDataHandlerTest, WithMockLocalSlamUploader) {
proto::AddOdometryDataRequest request;
EXPECT_TRUE(
google::protobuf::TextFormat::ParseFromString(kMessage, &request));
SetMockLocalTrajectoryUploader();
EXPECT_CALL(
*mock_map_builder_context_,
CheckClientIdForTrajectory(Eq(request.sensor_metadata().client_id()),
Eq(request.sensor_metadata().trajectory_id())))
.WillOnce(::testing::Return(true));
EXPECT_CALL(*mock_map_builder_context_,
DoEnqueueSensorData(
Eq(request.sensor_metadata().trajectory_id()),
Pointee(Truly(testing::BuildDataPredicateEquals(request)))));
proto::SensorData sensor_data;
*sensor_data.mutable_sensor_metadata() = request.sensor_metadata();
*sensor_data.mutable_odometry_data() = request.odometry_data();
EXPECT_CALL(*mock_local_trajectory_uploader_,
DoEnqueueSensorData(Pointee(
Truly(testing::BuildProtoPredicateEquals(&sensor_data)))));
test_server_->SendWrite(request);
test_server_->SendWritesDone();
test_server_->SendFinish();
}
} // namespace
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,45 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/add_rangefinder_data_handler.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "cartographer/sensor/internal/dispatchable.h"
#include "cartographer/sensor/timed_point_cloud_data.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void AddRangefinderDataHandler::OnSensorData(
const proto::AddRangefinderDataRequest& request) {
// The 'BlockingQueue' returned by 'sensor_data_queue()' is already
// thread-safe. Therefore it suffices to get an unsynchronized reference to
// the 'MapBuilderContext'.
GetUnsynchronizedContext<MapBuilderContextInterface>()->EnqueueSensorData(
request.sensor_metadata().trajectory_id(),
sensor::MakeDispatchable(
request.sensor_metadata().sensor_id(),
sensor::FromProto(request.timed_point_cloud_data())));
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,45 @@
/*
* Copyright 2017 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_RANGEFINDER_DATA_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_RANGEFINDER_DATA_HANDLER_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/handlers/add_sensor_data_handler_base.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
AddRangefinderDataSignature,
async_grpc::Stream<proto::AddRangefinderDataRequest>,
google::protobuf::Empty,
"/cartographer.cloud.proto.MapBuilderService/AddRangefinderData")
class AddRangefinderDataHandler
: public AddSensorDataHandlerBase<AddRangefinderDataSignature> {
public:
void OnSensorData(const proto::AddRangefinderDataRequest& request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_RANGEFINDER_DATA_HANDLER_H

View File

@ -0,0 +1,77 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/add_rangefinder_data_handler.h"
#include "cartographer/cloud/internal/testing/handler_test.h"
#include "cartographer/cloud/internal/testing/test_helpers.h"
#include "google/protobuf/text_format.h"
#include "gtest/gtest.h"
namespace cartographer {
namespace cloud {
namespace handlers {
namespace {
using ::testing::_;
using ::testing::Eq;
using ::testing::Pointee;
using ::testing::Truly;
const std::string kMessage = R"(
sensor_metadata {
trajectory_id: 1
sensor_id: "sensor_id"
}
timed_point_cloud_data {
timestamp: 2
origin {
x: 3.f y: 4.f z: 5.f
}
point_data {
position {
x: 6.f y: 7.f z: 8.f
}
time: 9.f
}
})";
using AddRangefinderDataHandlerTest =
testing::HandlerTest<AddRangefinderDataSignature,
AddRangefinderDataHandler>;
TEST_F(AddRangefinderDataHandlerTest, NoLocalSlamUploader) {
proto::AddRangefinderDataRequest request;
EXPECT_TRUE(
google::protobuf::TextFormat::ParseFromString(kMessage, &request));
EXPECT_CALL(
*mock_map_builder_context_,
CheckClientIdForTrajectory(Eq(request.sensor_metadata().client_id()),
Eq(request.sensor_metadata().trajectory_id())))
.WillOnce(::testing::Return(true));
EXPECT_CALL(*mock_map_builder_context_,
DoEnqueueSensorData(
Eq(request.sensor_metadata().trajectory_id()),
Pointee(Truly(testing::BuildDataPredicateEquals(request)))));
test_server_->SendWrite(request);
test_server_->SendWritesDone();
test_server_->SendFinish();
}
} // namespace
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,162 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/add_sensor_data_batch_handler.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "cartographer/mapping/internal/local_slam_result_data.h"
#include "cartographer/metrics/counter.h"
#include "cartographer/sensor/internal/dispatchable.h"
#include "cartographer/sensor/timed_point_cloud_data.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
metrics::Family<metrics::Counter>*
AddSensorDataBatchHandler::counter_metrics_family_ =
metrics::Family<metrics::Counter>::Null();
void AddSensorDataBatchHandler::OnRequest(
const proto::AddSensorDataBatchRequest& request) {
for (const proto::SensorData& sensor_data : request.sensor_data()) {
if (!GetContext<MapBuilderContextInterface>()->CheckClientIdForTrajectory(
sensor_data.sensor_metadata().client_id(),
sensor_data.sensor_metadata().trajectory_id())) {
LOG(ERROR) << "Unknown trajectory with ID "
<< sensor_data.sensor_metadata().trajectory_id()
<< " and client_id "
<< sensor_data.sensor_metadata().client_id();
Finish(::grpc::Status(::grpc::NOT_FOUND, "Unknown trajectory"));
return;
}
ClientMetrics* const metrics =
GetOrCreateClientMetrics(sensor_data.sensor_metadata().client_id(),
sensor_data.sensor_metadata().trajectory_id());
switch (sensor_data.sensor_data_case()) {
case proto::SensorData::kOdometryData:
GetUnsynchronizedContext<MapBuilderContextInterface>()
->EnqueueSensorData(
sensor_data.sensor_metadata().trajectory_id(),
sensor::MakeDispatchable(
sensor_data.sensor_metadata().sensor_id(),
sensor::FromProto(sensor_data.odometry_data())));
metrics->odometry_sensor_counter->Increment();
break;
case proto::SensorData::kImuData:
GetUnsynchronizedContext<MapBuilderContextInterface>()
->EnqueueSensorData(sensor_data.sensor_metadata().trajectory_id(),
sensor::MakeDispatchable(
sensor_data.sensor_metadata().sensor_id(),
sensor::FromProto(sensor_data.imu_data())));
metrics->imu_sensor_counter->Increment();
break;
case proto::SensorData::kTimedPointCloudData:
GetUnsynchronizedContext<MapBuilderContextInterface>()
->EnqueueSensorData(
sensor_data.sensor_metadata().trajectory_id(),
sensor::MakeDispatchable(
sensor_data.sensor_metadata().sensor_id(),
sensor::FromProto(sensor_data.timed_point_cloud_data())));
metrics->timed_point_cloud_counter->Increment();
break;
case proto::SensorData::kFixedFramePoseData:
GetUnsynchronizedContext<MapBuilderContextInterface>()
->EnqueueSensorData(
sensor_data.sensor_metadata().trajectory_id(),
sensor::MakeDispatchable(
sensor_data.sensor_metadata().sensor_id(),
sensor::FromProto(sensor_data.fixed_frame_pose_data())));
metrics->fixed_frame_pose_counter->Increment();
break;
case proto::SensorData::kLandmarkData:
GetUnsynchronizedContext<MapBuilderContextInterface>()
->EnqueueSensorData(
sensor_data.sensor_metadata().trajectory_id(),
sensor::MakeDispatchable(
sensor_data.sensor_metadata().sensor_id(),
sensor::FromProto(sensor_data.landmark_data())));
metrics->landmark_counter->Increment();
break;
case proto::SensorData::kLocalSlamResultData:
GetContext<MapBuilderContextInterface>()->EnqueueLocalSlamResultData(
sensor_data.sensor_metadata().trajectory_id(),
sensor_data.sensor_metadata().sensor_id(),
sensor_data.local_slam_result_data());
metrics->local_slam_result_counter->Increment();
break;
default:
LOG(FATAL) << "Unknown sensor data type: "
<< sensor_data.sensor_data_case();
}
}
Send(absl::make_unique<google::protobuf::Empty>());
}
void AddSensorDataBatchHandler::RegisterMetrics(
metrics::FamilyFactory* family_factory) {
counter_metrics_family_ = family_factory->NewCounterFamily(
"cartographer_sensor_data_total", "Sensor data received");
}
AddSensorDataBatchHandler::ClientMetrics*
AddSensorDataBatchHandler::GetOrCreateClientMetrics(
const std::string& client_id, int trajectory_id) {
const std::string map_key = client_id + std::to_string(trajectory_id);
auto client_metric_map_itr = client_metric_map_.find(map_key);
if (client_metric_map_itr != client_metric_map_.end()) {
return client_metric_map_itr->second.get();
}
auto new_metrics = absl::make_unique<ClientMetrics>();
new_metrics->odometry_sensor_counter = counter_metrics_family_->Add(
{{"client_id", client_id},
{"trajectory_id", std::to_string(trajectory_id)},
{"sensor", "odometry"}});
new_metrics->imu_sensor_counter = counter_metrics_family_->Add(
{{"client_id", client_id},
{"trajectory_id", std::to_string(trajectory_id)},
{"sensor", "imu"}});
new_metrics->fixed_frame_pose_counter = counter_metrics_family_->Add(
{{"client_id", client_id},
{"trajectory_id", std::to_string(trajectory_id)},
{"sensor", "fixed_frame_pose"}});
new_metrics->landmark_counter = counter_metrics_family_->Add(
{{"client_id", client_id},
{"trajectory_id", std::to_string(trajectory_id)},
{"sensor", "landmark"}});
new_metrics->local_slam_result_counter = counter_metrics_family_->Add(
{{"client_id", client_id},
{"trajectory_id", std::to_string(trajectory_id)},
{"sensor", "local_slam_result"}});
new_metrics->timed_point_cloud_counter = counter_metrics_family_->Add(
{{"client_id", client_id},
{"trajectory_id", std::to_string(trajectory_id)},
{"sensor", "timed_point_cloud"}});
// Obtain pointer before ownership is transferred.
auto* new_metrics_ptr = new_metrics.get();
client_metric_map_[map_key] = std::move(new_metrics);
return new_metrics_ptr;
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,71 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_SENSOR_DATA_BATCH_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_SENSOR_DATA_BATCH_HANDLER_H
#include <memory>
#include <string>
#include "absl/container/flat_hash_map.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "cartographer/metrics/counter.h"
#include "cartographer/metrics/family_factory.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
AddSensorDataBatchSignature, proto::AddSensorDataBatchRequest,
google::protobuf::Empty,
"/cartographer.cloud.proto.MapBuilderService/AddSensorDataBatch")
class AddSensorDataBatchHandler
: public async_grpc::RpcHandler<AddSensorDataBatchSignature> {
public:
void OnRequest(const proto::AddSensorDataBatchRequest& request) override;
static void RegisterMetrics(metrics::FamilyFactory* family_factory);
private:
struct ClientMetrics {
metrics::Counter* odometry_sensor_counter;
metrics::Counter* imu_sensor_counter;
metrics::Counter* timed_point_cloud_counter;
metrics::Counter* fixed_frame_pose_counter;
metrics::Counter* landmark_counter;
metrics::Counter* local_slam_result_counter;
};
ClientMetrics* GetOrCreateClientMetrics(const std::string& client_id,
int trajectory_id);
static cartographer::metrics::Family<metrics::Counter>*
counter_metrics_family_;
// Holds individual metrics for each client.
absl::flat_hash_map<std::string, std::unique_ptr<ClientMetrics>>
client_metric_map_;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_SENSOR_DATA_BATCH_HANDLER_H

View File

@ -0,0 +1,61 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_SENSOR_DATA_HANDLER_BASE_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_SENSOR_DATA_HANDLER_BASE_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
namespace cartographer {
namespace cloud {
namespace handlers {
template <typename HandlerSignatureType>
class AddSensorDataHandlerBase
: public async_grpc::RpcHandler<HandlerSignatureType> {
public:
using SensorDataType =
async_grpc::StripStream<typename HandlerSignatureType::IncomingType>;
void OnRequest(const SensorDataType& request) override {
if (!this->template GetContext<
cartographer::cloud::MapBuilderContextInterface>()
->CheckClientIdForTrajectory(
request.sensor_metadata().client_id(),
request.sensor_metadata().trajectory_id())) {
LOG(ERROR) << "Unknown trajectory with ID "
<< request.sensor_metadata().trajectory_id()
<< " and client_id " << request.sensor_metadata().client_id();
this->template Finish(
::grpc::Status(::grpc::NOT_FOUND, "Unknown trajectory"));
return;
}
OnSensorData(request);
}
virtual void OnSensorData(const SensorDataType& request) = 0;
void OnReadsDone() override {
this->template Send(absl::make_unique<google::protobuf::Empty>());
}
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_SENSOR_DATA_HANDLER_BASE_H

View File

@ -0,0 +1,81 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/add_trajectory_handler.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/internal/sensor/serialization.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void AddTrajectoryHandler::OnRequest(
const proto::AddTrajectoryRequest& request) {
auto local_slam_result_callback =
GetUnsynchronizedContext<MapBuilderContextInterface>()
->GetLocalSlamResultCallbackForSubscriptions();
std::set<mapping::TrajectoryBuilderInterface::SensorId> expected_sensor_ids;
for (const auto& sensor_id : request.expected_sensor_ids()) {
expected_sensor_ids.insert(FromProto(sensor_id));
}
const int trajectory_id =
GetContext<MapBuilderContextInterface>()
->map_builder()
.AddTrajectoryBuilder(expected_sensor_ids,
request.trajectory_builder_options(),
local_slam_result_callback);
GetContext<MapBuilderContextInterface>()->RegisterClientIdForTrajectory(
request.client_id(), trajectory_id);
if (GetUnsynchronizedContext<MapBuilderContextInterface>()
->local_trajectory_uploader()) {
auto trajectory_builder_options = request.trajectory_builder_options();
// Clear the trajectory builder options to convey to the cloud
// Cartographer instance that does not need to instantiate a
// 'LocalTrajectoryBuilder'.
trajectory_builder_options.clear_trajectory_builder_2d_options();
trajectory_builder_options.clear_trajectory_builder_3d_options();
// Don't instantiate the 'PureLocalizationTrimmer' on the server and don't
// freeze the trajectory on the server.
trajectory_builder_options.clear_pure_localization_trimmer();
// Ignore initial poses in trajectory_builder_options.
trajectory_builder_options.clear_initial_trajectory_pose();
auto status =
GetContext<MapBuilderContextInterface>()
->local_trajectory_uploader()
->AddTrajectory(request.client_id(), trajectory_id,
expected_sensor_ids, trajectory_builder_options);
if (!status.ok()) {
LOG(ERROR) << "Failed to create trajectory_id " << trajectory_id
<< " in uplink. Error: " << status.error_message();
}
}
auto response = absl::make_unique<proto::AddTrajectoryResponse>();
response->set_trajectory_id(trajectory_id);
Send(std::move(response));
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,42 @@
/*
* Copyright 2017 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_TRAJECTORY_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_TRAJECTORY_HANDLER_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
AddTrajectorySignature, proto::AddTrajectoryRequest,
proto::AddTrajectoryResponse,
"/cartographer.cloud.proto.MapBuilderService/AddTrajectory")
class AddTrajectoryHandler
: public async_grpc::RpcHandler<AddTrajectorySignature> {
public:
void OnRequest(const proto::AddTrajectoryRequest& request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_ADD_TRAJECTORY_HANDLER_H

View File

@ -0,0 +1,148 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/add_trajectory_handler.h"
#include "cartographer/cloud/internal/sensor/serialization.h"
#include "cartographer/cloud/internal/testing/handler_test.h"
#include "cartographer/cloud/internal/testing/test_helpers.h"
#include "cartographer/mapping/internal/testing/mock_map_builder.h"
#include "google/protobuf/text_format.h"
#include "gtest/gtest.h"
namespace cartographer {
namespace cloud {
namespace handlers {
namespace {
using ::testing::_;
using ::testing::ContainerEq;
using ::testing::Eq;
using ::testing::Return;
using ::testing::ReturnRef;
using ::testing::Test;
using ::testing::Truly;
const std::string kMessage = R"(
client_id: "CLIENT_ID"
expected_sensor_ids {
id: "range_sensor"
type: RANGE
}
expected_sensor_ids {
id: "imu_sensor"
type: IMU
}
trajectory_builder_options {
trajectory_builder_2d_options {
min_range: 20
max_range: 30
}
pure_localization_trimmer {
max_submaps_to_keep: 3
}
initial_trajectory_pose {
relative_pose {
translation {
x: 1 y: 2 z: 3
}
rotation {
w: 4 x: 5 y: 6 z: 7
}
}
to_trajectory_id: 8
timestamp: 9
}
}
)";
class AddTrajectoryHandlerTest
: public testing::HandlerTest<AddTrajectorySignature,
AddTrajectoryHandler> {
public:
void SetUp() override {
testing::HandlerTest<AddTrajectorySignature, AddTrajectoryHandler>::SetUp();
mock_map_builder_ = absl::make_unique<mapping::testing::MockMapBuilder>();
EXPECT_CALL(*mock_map_builder_context_,
GetLocalSlamResultCallbackForSubscriptions())
.WillOnce(Return(nullptr));
EXPECT_CALL(*mock_map_builder_context_, map_builder())
.WillOnce(ReturnRef(*mock_map_builder_));
}
protected:
std::set<mapping::TrajectoryBuilderInterface::SensorId> ParseSensorIds(
const proto::AddTrajectoryRequest &request) {
std::set<mapping::TrajectoryBuilderInterface::SensorId> expected_sensor_ids;
for (const auto &sensor_id : request.expected_sensor_ids()) {
expected_sensor_ids.insert(cloud::FromProto(sensor_id));
}
return expected_sensor_ids;
}
std::unique_ptr<mapping::testing::MockMapBuilder> mock_map_builder_;
};
TEST_F(AddTrajectoryHandlerTest, NoLocalSlamUploader) {
SetNoLocalTrajectoryUploader();
proto::AddTrajectoryRequest request;
EXPECT_TRUE(
google::protobuf::TextFormat::ParseFromString(kMessage, &request));
EXPECT_CALL(*mock_map_builder_,
AddTrajectoryBuilder(ContainerEq(ParseSensorIds(request)),
Truly(testing::BuildProtoPredicateEquals(
&request.trajectory_builder_options())),
_))
.WillOnce(Return(13));
EXPECT_CALL(*mock_map_builder_context_,
RegisterClientIdForTrajectory(Eq("CLIENT_ID"), Eq(13)));
test_server_->SendWrite(request);
EXPECT_EQ(test_server_->response().trajectory_id(), 13);
}
TEST_F(AddTrajectoryHandlerTest, WithLocalSlamUploader) {
SetMockLocalTrajectoryUploader();
proto::AddTrajectoryRequest request;
EXPECT_TRUE(
google::protobuf::TextFormat::ParseFromString(kMessage, &request));
EXPECT_CALL(*mock_map_builder_,
AddTrajectoryBuilder(ContainerEq(ParseSensorIds(request)),
Truly(testing::BuildProtoPredicateEquals(
&request.trajectory_builder_options())),
_))
.WillOnce(Return(13));
EXPECT_CALL(*mock_map_builder_context_,
RegisterClientIdForTrajectory(Eq("CLIENT_ID"), Eq(13)));
auto upstream_trajectory_builder_options =
request.trajectory_builder_options();
// Reproduce the changes to the request as done by the handler.
upstream_trajectory_builder_options.clear_trajectory_builder_2d_options();
upstream_trajectory_builder_options.clear_trajectory_builder_3d_options();
upstream_trajectory_builder_options.clear_pure_localization_trimmer();
upstream_trajectory_builder_options.clear_initial_trajectory_pose();
EXPECT_CALL(*mock_local_trajectory_uploader_,
AddTrajectory(Eq("CLIENT_ID"), Eq(13), ParseSensorIds(request),
Truly(testing::BuildProtoPredicateEquals(
&upstream_trajectory_builder_options))))
.WillOnce(Return(grpc::Status::OK));
test_server_->SendWrite(request);
EXPECT_EQ(test_server_->response().trajectory_id(), 13);
}
} // namespace
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,48 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/delete_trajectory_handler.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void DeleteTrajectoryHandler::OnRequest(
const proto::DeleteTrajectoryRequest& request) {
if (!GetContext<MapBuilderContextInterface>()->CheckClientIdForTrajectory(
request.client_id(), request.trajectory_id())) {
LOG(ERROR) << "Unknown trajectory with ID " << request.trajectory_id()
<< " and client_id " << request.client_id();
Finish(::grpc::Status(::grpc::NOT_FOUND, "Unknown trajectory"));
return;
}
GetContext<MapBuilderContextInterface>()
->map_builder()
.pose_graph()
->DeleteTrajectory(request.trajectory_id());
// TODO(gaschler): Think if LocalSlamUploader needs to be notified.
Send(absl::make_unique<google::protobuf::Empty>());
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,43 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_DELETE_TRAJECTORY_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_DELETE_TRAJECTORY_HANDLER_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
DeleteTrajectorySignature, proto::DeleteTrajectoryRequest,
google::protobuf::Empty,
"/cartographer.cloud.proto.MapBuilderService/DeleteTrajectory")
class DeleteTrajectoryHandler
: public async_grpc::RpcHandler<DeleteTrajectorySignature> {
public:
void OnRequest(const proto::DeleteTrajectoryRequest& request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_DELETE_TRAJECTORY_HANDLER_H

View File

@ -0,0 +1,58 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/finish_trajectory_handler.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void FinishTrajectoryHandler::OnRequest(
const proto::FinishTrajectoryRequest& request) {
if (!GetContext<MapBuilderContextInterface>()->CheckClientIdForTrajectory(
request.client_id(), request.trajectory_id())) {
LOG(ERROR) << "Unknown trajectory with ID " << request.trajectory_id()
<< " and client_id " << request.client_id();
Finish(::grpc::Status(::grpc::NOT_FOUND, "Unknown trajectory"));
return;
}
GetContext<MapBuilderContextInterface>()->map_builder().FinishTrajectory(
request.trajectory_id());
GetUnsynchronizedContext<MapBuilderContextInterface>()
->NotifyFinishTrajectory(request.trajectory_id());
if (GetUnsynchronizedContext<MapBuilderContextInterface>()
->local_trajectory_uploader()) {
auto status =
GetContext<MapBuilderContextInterface>()
->local_trajectory_uploader()
->FinishTrajectory(request.client_id(), request.trajectory_id());
if (!status.ok()) {
LOG(ERROR) << "Failed to finish trajectory in uplink: "
<< status.error_message();
}
}
Send(absl::make_unique<google::protobuf::Empty>());
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,43 @@
/*
* Copyright 2017 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_FINISH_TRAJECTORY_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_FINISH_TRAJECTORY_HANDLER_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
FinishTrajectorySignature, proto::FinishTrajectoryRequest,
google::protobuf::Empty,
"/cartographer.cloud.proto.MapBuilderService/FinishTrajectory")
class FinishTrajectoryHandler
: public async_grpc::RpcHandler<FinishTrajectorySignature> {
public:
void OnRequest(const proto::FinishTrajectoryRequest& request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_FINISH_TRAJECTORY_HANDLER_H

View File

@ -0,0 +1,49 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/get_all_submap_poses.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "cartographer/transform/transform.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void GetAllSubmapPosesHandler::OnRequest(
const google::protobuf::Empty& request) {
auto submap_poses = GetContext<MapBuilderContextInterface>()
->map_builder()
.pose_graph()
->GetAllSubmapPoses();
auto response = absl::make_unique<proto::GetAllSubmapPosesResponse>();
for (const auto& submap_id_pose : submap_poses) {
auto* submap_pose = response->add_submap_poses();
submap_id_pose.id.ToProto(submap_pose->mutable_submap_id());
submap_pose->set_submap_version(submap_id_pose.data.version);
*submap_pose->mutable_global_pose() =
transform::ToProto(submap_id_pose.data.pose);
}
Send(std::move(response));
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,43 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_ALL_SUBMAP_POSES_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_ALL_SUBMAP_POSES_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
GetAllSubmapPosesSignature, google::protobuf::Empty,
proto::GetAllSubmapPosesResponse,
"/cartographer.cloud.proto.MapBuilderService/GetAllSubmapPoses")
class GetAllSubmapPosesHandler
: public async_grpc::RpcHandler<GetAllSubmapPosesSignature> {
public:
void OnRequest(const google::protobuf::Empty& request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_ALL_SUBMAP_POSES_H

View File

@ -0,0 +1,45 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/get_constraints_handler.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "cartographer/mapping/pose_graph.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void GetConstraintsHandler::OnRequest(const google::protobuf::Empty& request) {
auto constraints = GetContext<MapBuilderContextInterface>()
->map_builder()
.pose_graph()
->constraints();
auto response = absl::make_unique<proto::GetConstraintsResponse>();
response->mutable_constraints()->Reserve(constraints.size());
for (const auto& constraint : constraints) {
*response->add_constraints() = mapping::ToProto(constraint);
}
Send(std::move(response));
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,43 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_CONSTRAINTS_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_CONSTRAINTS_HANDLER_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
GetConstraintsSignature, google::protobuf::Empty,
proto::GetConstraintsResponse,
"/cartographer.cloud.proto.MapBuilderService/GetConstraints")
class GetConstraintsHandler
: public async_grpc::RpcHandler<GetConstraintsSignature> {
public:
void OnRequest(const google::protobuf::Empty& request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_CONSTRAINTS_HANDLER_H

View File

@ -0,0 +1,47 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/get_landmark_poses_handler.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "cartographer/transform/transform.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void GetLandmarkPosesHandler::OnRequest(
const google::protobuf::Empty& request) {
auto landmark_poses = GetContext<MapBuilderContextInterface>()
->map_builder()
.pose_graph()
->GetLandmarkPoses();
auto response = absl::make_unique<proto::GetLandmarkPosesResponse>();
for (const auto& landmark_pose : landmark_poses) {
auto* landmark = response->add_landmark_poses();
landmark->set_landmark_id(landmark_pose.first);
*landmark->mutable_global_pose() = transform::ToProto(landmark_pose.second);
}
Send(std::move(response));
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,43 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_LANDMARK_POSES_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_LANDMARK_POSES_HANDLER_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
GetLandmarkPosesSignature, google::protobuf::Empty,
proto::GetLandmarkPosesResponse,
"/cartographer.cloud.proto.MapBuilderService/GetLandmarkPoses")
class GetLandmarkPosesHandler
: public async_grpc::RpcHandler<GetLandmarkPosesSignature> {
public:
void OnRequest(const google::protobuf::Empty& request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_LANDMARK_POSES_HANDLER_H

View File

@ -0,0 +1,84 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/get_landmark_poses_handler.h"
#include "cartographer/cloud/internal/testing/handler_test.h"
#include "cartographer/cloud/internal/testing/test_helpers.h"
#include "google/protobuf/text_format.h"
#include "gtest/gtest.h"
namespace cartographer {
namespace cloud {
namespace handlers {
namespace {
using ::cartographer::transform::Rigid3d;
using ::testing::_;
using ::testing::Eq;
using ::testing::Pointee;
using ::testing::Truly;
const std::string kMessage = R"(
landmark_poses {
landmark_id: "landmark_1"
global_pose {
translation {
x: 1 y: 2 z: 3
}
rotation {
w: 1 x: 0 y: 0 z: 0
}
}
}
landmark_poses {
landmark_id: "landmark_2"
global_pose {
translation {
x: 3 y: 2 z: 1
}
rotation {
w: 0 x: 1 y: 0 z: 0
}
}
}
)";
using GetLandmarkPosesHandlerTest =
testing::HandlerTest<GetLandmarkPosesSignature, GetLandmarkPosesHandler>;
TEST_F(GetLandmarkPosesHandlerTest, NoLocalSlamUploader) {
std::map<std::string, Rigid3d> landmark_poses{
{"landmark_1", Rigid3d(Eigen::Vector3d(1., 2., 3.),
Eigen::Quaterniond(1., 0., 0., 0.))},
{"landmark_2", Rigid3d(Eigen::Vector3d(3., 2., 1.),
Eigen::Quaterniond(0., 1., 0., 0.))}};
EXPECT_CALL(*mock_pose_graph_, GetLandmarkPoses())
.WillOnce(::testing::Return(landmark_poses));
test_server_->SendWrite(google::protobuf::Empty());
proto::GetLandmarkPosesResponse expected_response;
EXPECT_TRUE(google::protobuf::TextFormat::ParseFromString(
kMessage, &expected_response));
EXPECT_THAT(
test_server_->response(),
::testing::Truly(testing::BuildProtoPredicateEquals(&expected_response)));
}
} // namespace
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,43 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/get_local_to_global_transform_handler.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "cartographer/transform/transform.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void GetLocalToGlobalTransformHandler::OnRequest(
const proto::GetLocalToGlobalTransformRequest& request) {
auto response = absl::make_unique<proto::GetLocalToGlobalTransformResponse>();
auto local_to_global =
GetContext<MapBuilderContextInterface>()
->map_builder()
.pose_graph()
->GetLocalToGlobalTransform(request.trajectory_id());
*response->mutable_local_to_global() = transform::ToProto(local_to_global);
Send(std::move(response));
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,44 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_LOCAL_TO_GLOBAL_TRANSFORM_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_LOCAL_TO_GLOBAL_TRANSFORM_HANDLER_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
GetLocalToGlobalTransformSignature, proto::GetLocalToGlobalTransformRequest,
proto::GetLocalToGlobalTransformResponse,
"/cartographer.cloud.proto.MapBuilderService/GetLocalToGlobalTransform")
class GetLocalToGlobalTransformHandler
: public async_grpc::RpcHandler<GetLocalToGlobalTransformSignature> {
public:
void OnRequest(
const proto::GetLocalToGlobalTransformRequest& request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_LOCAL_TO_GLOBAL_TRANSFORM_HANDLER_H

View File

@ -0,0 +1,41 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/get_submap_handler.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void GetSubmapHandler::OnRequest(const proto::GetSubmapRequest &request) {
auto response = absl::make_unique<proto::GetSubmapResponse>();
response->set_error_msg(
GetContext<MapBuilderContextInterface>()->map_builder().SubmapToProto(
mapping::SubmapId{request.submap_id().trajectory_id(),
request.submap_id().submap_index()},
response->mutable_submap_query_response()));
Send(std::move(response));
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,41 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_SUBMAP_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_SUBMAP_HANDLER_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
GetSubmapSignature, proto::GetSubmapRequest, proto::GetSubmapResponse,
"/cartographer.cloud.proto.MapBuilderService/GetSubmap")
class GetSubmapHandler : public async_grpc::RpcHandler<GetSubmapSignature> {
public:
void OnRequest(const proto::GetSubmapRequest &request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_SUBMAP_HANDLER_H

View File

@ -0,0 +1,56 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/get_trajectory_node_poses_handler.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "cartographer/transform/transform.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void GetTrajectoryNodePosesHandler::OnRequest(
const google::protobuf::Empty& request) {
auto node_poses = GetContext<MapBuilderContextInterface>()
->map_builder()
.pose_graph()
->GetTrajectoryNodePoses();
auto response = absl::make_unique<proto::GetTrajectoryNodePosesResponse>();
for (const auto& node_id_pose : node_poses) {
auto* node_pose = response->add_node_poses();
node_id_pose.id.ToProto(node_pose->mutable_node_id());
*node_pose->mutable_global_pose() =
transform::ToProto(node_id_pose.data.global_pose);
if (node_id_pose.data.constant_pose_data.has_value()) {
node_pose->mutable_constant_pose_data()->set_timestamp(
common::ToUniversal(
node_id_pose.data.constant_pose_data.value().time));
*node_pose->mutable_constant_pose_data()->mutable_local_pose() =
transform::ToProto(
node_id_pose.data.constant_pose_data.value().local_pose);
}
}
Send(std::move(response));
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,43 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_TRAJECTORY_NODE_POSES_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_TRAJECTORY_NODE_POSES_HANDLER_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
GetTrajectoryNodePosesSignature, google::protobuf::Empty,
proto::GetTrajectoryNodePosesResponse,
"/cartographer.cloud.proto.MapBuilderService/GetTrajectoryNodePoses")
class GetTrajectoryNodePosesHandler
: public async_grpc::RpcHandler<GetTrajectoryNodePosesSignature> {
public:
void OnRequest(const google::protobuf::Empty& request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_TRAJECTORY_NODE_POSES_HANDLER_H

View File

@ -0,0 +1,46 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/get_trajectory_states_handler.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/internal/mapping/serialization.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void GetTrajectoryStatesHandler::OnRequest(
const google::protobuf::Empty& request) {
auto trajectories_state = GetContext<MapBuilderContextInterface>()
->map_builder()
.pose_graph()
->GetTrajectoryStates();
auto response = absl::make_unique<proto::GetTrajectoryStatesResponse>();
for (const auto& entry : trajectories_state) {
(*response->mutable_trajectories_state())[entry.first] =
ToProto(entry.second);
}
Send(std::move(response));
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,43 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_TRAJECTORY_STATES_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_TRAJECTORY_STATES_HANDLER_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
#include "google/protobuf/empty.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
GetTrajectoryStatesSignature, google::protobuf::Empty,
proto::GetTrajectoryStatesResponse,
"/cartographer.cloud.proto.MapBuilderService/GetTrajectoryStates")
class GetTrajectoryStatesHandler
: public async_grpc::RpcHandler<GetTrajectoryStatesSignature> {
public:
void OnRequest(const google::protobuf::Empty& request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_GET_TRAJECTORY_STATES_HANDLER_H

View File

@ -0,0 +1,41 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/is_trajectory_finished_handler.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void IsTrajectoryFinishedHandler::OnRequest(
const proto::IsTrajectoryFinishedRequest& request) {
auto response = absl::make_unique<proto::IsTrajectoryFinishedResponse>();
response->set_is_finished(
GetContext<MapBuilderContextInterface>()
->map_builder()
.pose_graph()
->IsTrajectoryFinished(request.trajectory_id()));
Send(std::move(response));
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,42 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_IS_TRAJECTORY_FINISHED_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_IS_TRAJECTORY_FINISHED_HANDLER_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
IsTrajectoryFinishedSignature, proto::IsTrajectoryFinishedRequest,
proto::IsTrajectoryFinishedResponse,
"/cartographer.cloud.proto.MapBuilderService/IsTrajectoryFinished")
class IsTrajectoryFinishedHandler
: public async_grpc::RpcHandler<IsTrajectoryFinishedSignature> {
public:
void OnRequest(const proto::IsTrajectoryFinishedRequest& request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_IS_TRAJECTORY_FINISHED_HANDLER_H

View File

@ -0,0 +1,40 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/is_trajectory_frozen_handler.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void IsTrajectoryFrozenHandler::OnRequest(
const proto::IsTrajectoryFrozenRequest& request) {
auto response = absl::make_unique<proto::IsTrajectoryFrozenResponse>();
response->set_is_frozen(GetContext<MapBuilderContextInterface>()
->map_builder()
.pose_graph()
->IsTrajectoryFrozen(request.trajectory_id()));
Send(std::move(response));
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,42 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_IS_TRAJECTORY_FROZEN_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_IS_TRAJECTORY_FROZEN_HANDLER_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
IsTrajectoryFrozenSignature, proto::IsTrajectoryFrozenRequest,
proto::IsTrajectoryFrozenResponse,
"/cartographer.cloud.proto.MapBuilderService/IsTrajectoryFrozen")
class IsTrajectoryFrozenHandler
: public async_grpc::RpcHandler<IsTrajectoryFrozenSignature> {
public:
void OnRequest(const proto::IsTrajectoryFrozenRequest& request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_IS_TRAJECTORY_FROZEN_HANDLER_H

View File

@ -0,0 +1,47 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "cartographer/cloud/internal/handlers/load_state_from_file_handler.h"
#include "absl/memory/memory.h"
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/internal/map_builder_context_interface.h"
#include "cartographer/cloud/internal/mapping/serialization.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
void LoadStateFromFileHandler::OnRequest(
const proto::LoadStateFromFileRequest& request) {
// TODO(gaschler): This blocks a handler thread, consider working in
// background.
auto trajectory_remapping =
GetContext<MapBuilderContextInterface>()->map_builder().LoadStateFromFile(
request.file_path(), request.load_frozen_state());
for (const auto& entry : trajectory_remapping) {
GetContext<MapBuilderContextInterface>()->RegisterClientIdForTrajectory(
request.client_id(), entry.second);
}
auto response = absl::make_unique<proto::LoadStateFromFileResponse>();
*response->mutable_trajectory_remapping() = ToProto(trajectory_remapping);
Send(std::move(response));
}
} // namespace handlers
} // namespace cloud
} // namespace cartographer

View File

@ -0,0 +1,42 @@
/*
* Copyright 2018 The Cartographer Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_LOAD_STATE_FROM_FILE_HANDLER_H
#define CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_LOAD_STATE_FROM_FILE_HANDLER_H
#include "async_grpc/rpc_handler.h"
#include "cartographer/cloud/proto/map_builder_service.pb.h"
namespace cartographer {
namespace cloud {
namespace handlers {
DEFINE_HANDLER_SIGNATURE(
LoadStateFromFileSignature, proto::LoadStateFromFileRequest,
proto::LoadStateFromFileResponse,
"/cartographer.cloud.proto.MapBuilderService/LoadStateFromFile")
class LoadStateFromFileHandler
: public async_grpc::RpcHandler<LoadStateFromFileSignature> {
public:
void OnRequest(const proto::LoadStateFromFileRequest& request) override;
};
} // namespace handlers
} // namespace cloud
} // namespace cartographer
#endif // CARTOGRAPHER_CLOUD_INTERNAL_HANDLERS_LOAD_STATE_FROM_FILE_HANDLER_H

Some files were not shown because too many files have changed in this diff Show More