local_trajectory_uploader_test.cc
Go to the documentation of this file.
00001 /*
00002  * Copyright 2018 The Cartographer Authors
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #include "cartographer/cloud/internal/local_trajectory_uploader.h"
00018 
00019 #include "glog/logging.h"
00020 #include "gmock/gmock.h"
00021 #include "gtest/gtest.h"
00022 
00023 using SensorId = ::cartographer::mapping::TrajectoryBuilderInterface::SensorId;
00024 
00025 namespace cartographer {
00026 namespace cloud {
00027 namespace {
00028 
00029 constexpr char kClientId[] = "CLIENT_ID";
00030 const SensorId kImuSensorId{SensorId::SensorType::IMU, "imu"};
00031 const SensorId kRangeSensorId{SensorId::SensorType::RANGE, "range"};
00032 const int kLocalTrajectoryId = 3;
00033 
00034 TEST(LocalTrajectoryUploaderTest, HandlesInvalidUplink) {
00035   auto uploader = CreateLocalTrajectoryUploader("invalid-uplink-address:50051",
00036                                                 /*batch_size=*/1, false, false);
00037   uploader->Start();
00038   mapping::proto::TrajectoryBuilderOptions options;
00039   auto status = uploader->AddTrajectory(
00040       kClientId, kLocalTrajectoryId, {kRangeSensorId, kImuSensorId}, options);
00041   EXPECT_FALSE(status.ok());
00042   auto sensor_data = absl::make_unique<proto::SensorData>();
00043   sensor_data->mutable_sensor_metadata()->set_client_id(kClientId);
00044   sensor_data->mutable_sensor_metadata()->set_sensor_id(kImuSensorId.id);
00045   sensor_data->mutable_sensor_metadata()->set_trajectory_id(kLocalTrajectoryId);
00046   sensor_data->mutable_imu_data()->set_timestamp(1);
00047   uploader->EnqueueSensorData(std::move(sensor_data));
00048   auto sensor_id = uploader->GetLocalSlamResultSensorId(kLocalTrajectoryId);
00049   EXPECT_THAT(sensor_id.id, ::testing::Not(::testing::IsEmpty()));
00050   status = uploader->FinishTrajectory(kClientId, kLocalTrajectoryId);
00051   EXPECT_FALSE(status.ok());
00052   uploader->Shutdown();
00053 }
00054 
00055 }  // namespace
00056 }  // namespace cloud
00057 }  // namespace cartographer


cartographer
Author(s): The Cartographer Authors
autogenerated on Thu May 9 2019 02:27:35