Christoph Schütte 2017-12-11 19:09:52 +01:00 committed by Wally B. Feed
parent c5ec086968
commit e596b75113
4 changed files with 93 additions and 1 deletions

View File

@ -154,6 +154,13 @@ google_binary(cartographer_compute_relations_metrics
cartographer/ground_truth/compute_relations_metrics_main.cc cartographer/ground_truth/compute_relations_metrics_main.cc
) )
if(${BUILD_GRPC})
google_binary(cartographer_grpc_server
SRCS
cartographer_grpc/map_builder_server_main.cc
)
endif()
foreach(ABS_FIL ${ALL_TESTS}) foreach(ABS_FIL ${ALL_TESTS})
file(RELATIVE_PATH REL_FIL ${PROJECT_SOURCE_DIR} ${ABS_FIL}) file(RELATIVE_PATH REL_FIL ${PROJECT_SOURCE_DIR} ${ABS_FIL})
get_filename_component(DIR ${REL_FIL} DIRECTORY) get_filename_component(DIR ${REL_FIL} DIRECTORY)
@ -195,6 +202,9 @@ target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
# TODO(hrapp): This should not explicitly list pthread and use # TODO(hrapp): This should not explicitly list pthread and use
# PROTOBUF_LIBRARIES, but that failed on first try. # PROTOBUF_LIBRARIES, but that failed on first try.
target_link_libraries(${PROJECT_NAME} PUBLIC ${PROTOBUF_LIBRARY} pthread) target_link_libraries(${PROJECT_NAME} PUBLIC ${PROTOBUF_LIBRARY} pthread)
if(${BUILD_GRPC})
target_link_libraries(${PROJECT_NAME} PUBLIC grpc++)
endif()
# Add the binary directory first, so that port.h is included after it has # Add the binary directory first, so that port.h is included after it has
# been generated. # been generated.

View File

@ -0,0 +1,58 @@
/*
* 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_grpc/map_builder_server.h"
#include "cartographer_grpc/map_builder_server_options.h"
#include "gflags/gflags.h"
#include "glog/logging.h"
DEFINE_string(configuration_directory, "",
"First directory in which configuration files are searched, "
"second is always the Cartographer installation to allow "
"including files from there.");
DEFINE_string(configuration_basename, "",
"Basename, i.e. not containing any directory prefix, of the "
"configuration file.");
namespace cartographer_grpc {
void Run(const std::string& configuration_directory,
const std::string& configuration_basename) {
proto::MapBuilderServerOptions map_builder_server_options =
LoadMapBuilderServerOptions(configuration_directory,
configuration_basename);
MapBuilderServer map_builder_server(map_builder_server_options);
map_builder_server.Start();
map_builder_server.WaitForShutdown();
}
} // namespace cartographer_grpc
int main(int argc, char** argv) {
google::InitGoogleLogging(argv[0]);
FLAGS_logtostderr = true;
google::SetUsageMessage(
"\n\n"
"This program offers a MapBuilder service via a gRPC interface.\n");
google::ParseCommandLineFlags(&argc, &argv, true);
if (FLAGS_configuration_directory.empty() ||
FLAGS_configuration_basename.empty()) {
google::ShowUsageWithFlagsRestrict(argv[0], "cartographer_grpc_server");
return EXIT_FAILURE;
}
cartographer_grpc::Run(FLAGS_configuration_directory,
FLAGS_configuration_basename);
}

View File

@ -30,7 +30,8 @@ proto::MapBuilderServerOptions CreateMapBuilderServerOptions(
map_builder_server_options.set_num_grpc_threads( map_builder_server_options.set_num_grpc_threads(
lua_parameter_dictionary->GetInt("num_grpc_threads")); lua_parameter_dictionary->GetInt("num_grpc_threads"));
*map_builder_server_options.mutable_map_builder_options() = *map_builder_server_options.mutable_map_builder_options() =
cartographer::mapping::CreateMapBuilderOptions(lua_parameter_dictionary); cartographer::mapping::CreateMapBuilderOptions(
lua_parameter_dictionary->GetDictionary("map_builder").get());
return map_builder_server_options; return map_builder_server_options;
} }

View File

@ -0,0 +1,23 @@
-- 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 "map_builder.lua"
options = {
server_address = "0.0.0.0:50051",
num_grpc_threads = 4,
map_builder = MAP_BUILDER,
}
return options