Skip to content

Commit

Permalink
Follow the Absl update. (cartographer-project#955)
Browse files Browse the repository at this point in the history
  • Loading branch information
pifon2a authored Jul 28, 2018
1 parent 15dece6 commit 2910529
Show file tree
Hide file tree
Showing 23 changed files with 79 additions and 96 deletions.
1 change: 1 addition & 0 deletions cartographer_ros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ find_package(catkin REQUIRED COMPONENTS ${PACKAGE_DEPENDENCIES})

include(FindPkgConfig)

find_package(Abseil REQUIRED)
find_package(LuaGoogle REQUIRED)
find_package(PCL REQUIRED COMPONENTS common)
find_package(Eigen3 REQUIRED)
Expand Down
14 changes: 6 additions & 8 deletions cartographer_ros/cartographer_ros/assets_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <fstream>
#include <iostream>

#include "absl/memory/memory.h"
#include "cartographer/common/configuration_file_resolver.h"
#include "cartographer/common/make_unique.h"
#include "cartographer/common/math.h"
#include "cartographer/io/file_writer.h"
#include "cartographer/io/points_processor.h"
Expand Down Expand Up @@ -61,8 +61,7 @@ CreatePipelineBuilder(
const std::string file_prefix) {
const auto file_writer_factory =
AssetsWriter::CreateFileWriterFactory(file_prefix);
auto builder =
carto::common::make_unique<carto::io::PointsProcessorPipelineBuilder>();
auto builder = absl::make_unique<carto::io::PointsProcessorPipelineBuilder>();
carto::io::RegisterBuiltInPointsProcessors(trajectories, file_writer_factory,
builder.get());
builder->Register(RosMapWritingPointsProcessor::kConfigurationFileActionName,
Expand All @@ -80,13 +79,13 @@ std::unique_ptr<carto::common::LuaParameterDictionary> LoadLuaDictionary(
const std::string& configuration_directory,
const std::string& configuration_basename) {
auto file_resolver =
carto::common::make_unique<carto::common::ConfigurationFileResolver>(
absl::make_unique<carto::common::ConfigurationFileResolver>(
std::vector<std::string>{configuration_directory});

const std::string code =
file_resolver->GetFileContentOrDie(configuration_basename);
auto lua_parameter_dictionary =
carto::common::make_unique<carto::common::LuaParameterDictionary>(
absl::make_unique<carto::common::LuaParameterDictionary>(
code, std::move(file_resolver));
return lua_parameter_dictionary;
}
Expand All @@ -99,7 +98,7 @@ std::unique_ptr<carto::io::PointsBatch> HandleMessage(
transform_interpolation_buffer) {
const carto::common::Time start_time = FromRos(message.header.stamp);

auto points_batch = carto::common::make_unique<carto::io::PointsBatch>();
auto points_batch = absl::make_unique<carto::io::PointsBatch>();
points_batch->start_time = start_time;
points_batch->frame_id = message.header.frame_id;

Expand Down Expand Up @@ -264,8 +263,7 @@ void AssetsWriter::Run(const std::string& configuration_directory,
::cartographer::io::FileWriterFactory AssetsWriter::CreateFileWriterFactory(
const std::string& file_path) {
const auto file_writer_factory = [file_path](const std::string& filename) {
return carto::common::make_unique<carto::io::StreamFileWriter>(file_path +
filename);
return absl::make_unique<carto::io::StreamFileWriter>(file_path + filename);
};
return file_writer_factory;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

#include "absl/memory/memory.h"
#include "cartographer/cloud/client/map_builder_stub.h"
#include "cartographer/common/make_unique.h"
#include "cartographer_ros/node.h"
#include "cartographer_ros/node_options.h"
#include "cartographer_ros/ros_log_sink.h"
Expand Down Expand Up @@ -59,9 +59,8 @@ void Run() {
std::tie(node_options, trajectory_options) =
LoadOptions(FLAGS_configuration_directory, FLAGS_configuration_basename);

auto map_builder =
cartographer::common::make_unique<::cartographer::cloud::MapBuilderStub>(
FLAGS_server_address, FLAGS_client_id);
auto map_builder = absl::make_unique<::cartographer::cloud::MapBuilderStub>(
FLAGS_server_address, FLAGS_client_id);
Node node(node_options, std::move(map_builder), &tf_buffer,
FLAGS_collect_metrics);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ int main(int argc, char** argv) {

const cartographer_ros::MapBuilderFactory map_builder_factory =
[](const ::cartographer::mapping::proto::MapBuilderOptions&) {
return ::cartographer::common::make_unique<
::cartographer::cloud::MapBuilderStub>(FLAGS_server_address,
FLAGS_client_id);
return absl::make_unique< ::cartographer::cloud::MapBuilderStub>(
FLAGS_server_address, FLAGS_client_id);
};

cartographer_ros::RunOfflineNode(map_builder_factory);
Expand Down
13 changes: 6 additions & 7 deletions cartographer_ros/cartographer_ros/map_builder_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "cartographer_ros/map_builder_bridge.h"

#include "cartographer/common/make_unique.h"
#include "absl/memory/memory.h"
#include "cartographer/io/color.h"
#include "cartographer/io/proto_stream.h"
#include "cartographer/mapping/pose_graph.h"
Expand Down Expand Up @@ -135,12 +135,11 @@ int MapBuilderBridge::AddTrajectory(

// Make sure there is no trajectory with 'trajectory_id' yet.
CHECK_EQ(sensor_bridges_.count(trajectory_id), 0);
sensor_bridges_[trajectory_id] =
cartographer::common::make_unique<SensorBridge>(
trajectory_options.num_subdivisions_per_laser_scan,
trajectory_options.tracking_frame,
node_options_.lookup_transform_timeout_sec, tf_buffer_,
map_builder_->GetTrajectoryBuilder(trajectory_id));
sensor_bridges_[trajectory_id] = absl::make_unique<SensorBridge>(
trajectory_options.num_subdivisions_per_laser_scan,
trajectory_options.tracking_frame,
node_options_.lookup_transform_timeout_sec, tf_buffer_,
map_builder_->GetTrajectoryBuilder(trajectory_id));
auto emplace_result =
trajectory_options_.emplace(trajectory_id, trajectory_options);
CHECK(emplace_result.second == true);
Expand Down
12 changes: 5 additions & 7 deletions cartographer_ros/cartographer_ros/metrics/family_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "cartographer_ros/metrics/family_factory.h"

#include "cartographer/common/make_unique.h"
#include "absl/memory/memory.h"

namespace cartographer_ros {
namespace metrics {
Expand All @@ -26,8 +26,7 @@ using BucketBoundaries = ::cartographer::metrics::Histogram::BucketBoundaries;
::cartographer::metrics::Family<::cartographer::metrics::Counter>*
FamilyFactory::NewCounterFamily(const std::string& name,
const std::string& description) {
auto wrapper =
::cartographer::common::make_unique<CounterFamily>(name, description);
auto wrapper = absl::make_unique<CounterFamily>(name, description);
auto* ptr = wrapper.get();
counter_families_.emplace_back(std::move(wrapper));
return ptr;
Expand All @@ -36,8 +35,7 @@ FamilyFactory::NewCounterFamily(const std::string& name,
::cartographer::metrics::Family<::cartographer::metrics::Gauge>*
FamilyFactory::NewGaugeFamily(const std::string& name,
const std::string& description) {
auto wrapper =
::cartographer::common::make_unique<GaugeFamily>(name, description);
auto wrapper = absl::make_unique<GaugeFamily>(name, description);
auto* ptr = wrapper.get();
gauge_families_.emplace_back(std::move(wrapper));
return ptr;
Expand All @@ -47,8 +45,8 @@ ::cartographer::metrics::Family<::cartographer::metrics::Histogram>*
FamilyFactory::NewHistogramFamily(const std::string& name,
const std::string& description,
const BucketBoundaries& boundaries) {
auto wrapper = ::cartographer::common::make_unique<HistogramFamily>(
name, description, boundaries);
auto wrapper =
absl::make_unique<HistogramFamily>(name, description, boundaries);
auto* ptr = wrapper.get();
histogram_families_.emplace_back(std::move(wrapper));
return ptr;
Expand Down
9 changes: 4 additions & 5 deletions cartographer_ros/cartographer_ros/metrics/internal/family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "cartographer_ros/metrics/internal/family.h"

#include "cartographer/common/make_unique.h"
#include "absl/memory/memory.h"
#include "cartographer_ros/metrics/internal/counter.h"
#include "cartographer_ros/metrics/internal/gauge.h"
#include "cartographer_ros/metrics/internal/histogram.h"
Expand All @@ -27,7 +27,7 @@ namespace metrics {
using BucketBoundaries = ::cartographer::metrics::Histogram::BucketBoundaries;

Counter* CounterFamily::Add(const std::map<std::string, std::string>& labels) {
auto wrapper = ::cartographer::common::make_unique<Counter>(labels);
auto wrapper = absl::make_unique<Counter>(labels);
auto* ptr = wrapper.get();
wrappers_.emplace_back(std::move(wrapper));
return ptr;
Expand All @@ -44,7 +44,7 @@ cartographer_ros_msgs::MetricFamily CounterFamily::ToRosMessage() {
}

Gauge* GaugeFamily::Add(const std::map<std::string, std::string>& labels) {
auto wrapper = ::cartographer::common::make_unique<Gauge>(labels);
auto wrapper = absl::make_unique<Gauge>(labels);
auto* ptr = wrapper.get();
wrappers_.emplace_back(std::move(wrapper));
return ptr;
Expand All @@ -62,8 +62,7 @@ cartographer_ros_msgs::MetricFamily GaugeFamily::ToRosMessage() {

Histogram* HistogramFamily::Add(
const std::map<std::string, std::string>& labels) {
auto wrapper =
::cartographer::common::make_unique<Histogram>(labels, boundaries_);
auto wrapper = absl::make_unique<Histogram>(labels, boundaries_);
auto* ptr = wrapper.get();
wrappers_.emplace_back(std::move(wrapper));
return ptr;
Expand Down
3 changes: 1 addition & 2 deletions cartographer_ros/cartographer_ros/msg_conversion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,7 @@ std::unique_ptr<nav_msgs::OccupancyGrid> CreateOccupancyGridMsg(
const cartographer::io::PaintSubmapSlicesResult& painted_slices,
const double resolution, const std::string& frame_id,
const ros::Time& time) {
auto occupancy_grid =
::cartographer::common::make_unique<nav_msgs::OccupancyGrid>();
auto occupancy_grid = absl::make_unique<nav_msgs::OccupancyGrid>();

const int width = cairo_image_surface_get_width(painted_slices.surface.get());
const int height =
Expand Down
4 changes: 2 additions & 2 deletions cartographer_ros/cartographer_ros/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#include <vector>

#include "Eigen/Core"
#include "absl/memory/memory.h"
#include "cartographer/common/configuration_file_resolver.h"
#include "cartographer/common/lua_parameter_dictionary.h"
#include "cartographer/common/make_unique.h"
#include "cartographer/common/port.h"
#include "cartographer/common/time.h"
#include "cartographer/mapping/pose_graph_interface.h"
Expand Down Expand Up @@ -95,7 +95,7 @@ Node::Node(
map_builder_bridge_(node_options_, std::move(map_builder), tf_buffer) {
carto::common::MutexLocker lock(&mutex_);
if (collect_metrics) {
metrics_registry_ = carto::common::make_unique<metrics::FamilyFactory>();
metrics_registry_ = absl::make_unique<metrics::FamilyFactory>();
carto::metrics::RegisterAllMetrics(metrics_registry_.get());
}

Expand Down
7 changes: 3 additions & 4 deletions cartographer_ros/cartographer_ros/node_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#include "cartographer/common/make_unique.h"
#include "absl/memory/memory.h"
#include "cartographer/mapping/map_builder.h"
#include "cartographer_ros/node.h"
#include "cartographer_ros/node_options.h"
Expand Down Expand Up @@ -56,9 +56,8 @@ void Run() {
std::tie(node_options, trajectory_options) =
LoadOptions(FLAGS_configuration_directory, FLAGS_configuration_basename);

auto map_builder =
::cartographer::common::make_unique<cartographer::mapping::MapBuilder>(
node_options.map_builder_options);
auto map_builder = absl::make_unique<cartographer::mapping::MapBuilder>(
node_options.map_builder_options);
Node node(node_options, std::move(map_builder), &tf_buffer,
FLAGS_collect_metrics);
if (!FLAGS_load_state_filename.empty()) {
Expand Down
6 changes: 3 additions & 3 deletions cartographer_ros/cartographer_ros/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ NodeOptions CreateNodeOptions(
std::tuple<NodeOptions, TrajectoryOptions> LoadOptions(
const std::string& configuration_directory,
const std::string& configuration_basename) {
auto file_resolver = cartographer::common::make_unique<
cartographer::common::ConfigurationFileResolver>(
std::vector<std::string>{configuration_directory});
auto file_resolver =
absl::make_unique<cartographer::common::ConfigurationFileResolver>(
std::vector<std::string>{configuration_directory});
const std::string code =
file_resolver->GetFileContentOrDie(configuration_basename);
cartographer::common::LuaParameterDictionary lua_parameter_dictionary(
Expand Down
4 changes: 2 additions & 2 deletions cartographer_ros/cartographer_ros/offline_node_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ int main(int argc, char** argv) {
const cartographer_ros::MapBuilderFactory map_builder_factory =
[](const ::cartographer::mapping::proto::MapBuilderOptions&
map_builder_options) {
return ::cartographer::common::make_unique<
::cartographer::mapping::MapBuilder>(map_builder_options);
return absl::make_unique< ::cartographer::mapping::MapBuilder>(
map_builder_options);
};

cartographer_ros::RunOfflineNode(map_builder_factory);
Expand Down
8 changes: 3 additions & 5 deletions cartographer_ros/cartographer_ros/playable_bag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "cartographer_ros/playable_bag.h"

#include "cartographer/common/make_unique.h"
#include "absl/memory/memory.h"
#include "cartographer_ros/node_constants.h"
#include "glog/logging.h"
#include "tf2_msgs/TFMessage.h"
Expand All @@ -28,10 +28,8 @@ PlayableBag::PlayableBag(
const ros::Time start_time, const ros::Time end_time,
const ros::Duration buffer_delay,
FilteringEarlyMessageHandler filtering_early_message_handler)
: bag_(cartographer::common::make_unique<rosbag::Bag>(
bag_filename, rosbag::bagmode::Read)),
view_(cartographer::common::make_unique<rosbag::View>(*bag_, start_time,
end_time)),
: bag_(absl::make_unique<rosbag::Bag>(bag_filename, rosbag::bagmode::Read)),
view_(absl::make_unique<rosbag::View>(*bag_, start_time, end_time)),
view_iterator_(view_->begin()),
finished_(false),
bag_id_(bag_id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "cartographer_ros/ros_map_writing_points_processor.h"

#include "cartographer/common/make_unique.h"
#include "absl/memory/memory.h"
#include "cartographer/io/image.h"
#include "cartographer/io/probability_grid_points_processor.h"
#include "cartographer_ros/ros_map.h"
Expand All @@ -42,7 +42,7 @@ RosMapWritingPointsProcessor::FromDictionary(
::cartographer::io::FileWriterFactory file_writer_factory,
::cartographer::common::LuaParameterDictionary* const dictionary,
::cartographer::io::PointsProcessor* const next) {
return ::cartographer::common::make_unique<RosMapWritingPointsProcessor>(
return absl::make_unique<RosMapWritingPointsProcessor>(
dictionary->GetDouble("resolution"),
::cartographer::mapping::CreateProbabilityGridRangeDataInserterOptions2D(
dictionary->GetDictionary("range_data_inserter").get()),
Expand Down
4 changes: 2 additions & 2 deletions cartographer_ros/cartographer_ros/rosbag_validate_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include <set>
#include <string>

#include "absl/memory/memory.h"
#include "cartographer/common/histogram.h"
#include "cartographer/common/make_unique.h"
#include "cartographer_ros/msg_conversion.h"
#include "gflags/gflags.h"
#include "glog/logging.h"
Expand Down Expand Up @@ -72,7 +72,7 @@ const std::set<std::string> kPointDataTypes = {
ros::message_traits::DataType<sensor_msgs::LaserScan>::value())};

std::unique_ptr<std::ofstream> CreateTimingFile(const std::string& frame_id) {
auto timing_file = ::cartographer::common::make_unique<std::ofstream>(
auto timing_file = absl::make_unique<std::ofstream>(
std::string("timing_") + frame_id + ".csv", std::ios_base::out);

(*timing_file)
Expand Down
27 changes: 12 additions & 15 deletions cartographer_ros/cartographer_ros/sensor_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "cartographer_ros/sensor_bridge.h"

#include "cartographer/common/make_unique.h"
#include "absl/memory/memory.h"
#include "cartographer_ros/msg_conversion.h"
#include "cartographer_ros/time_conversion.h"

Expand Down Expand Up @@ -56,7 +56,7 @@ std::unique_ptr<carto::sensor::OdometryData> SensorBridge::ToOdometryData(
if (sensor_to_tracking == nullptr) {
return nullptr;
}
return carto::common::make_unique<carto::sensor::OdometryData>(
return absl::make_unique<carto::sensor::OdometryData>(
carto::sensor::OdometryData{
time, ToRigid3d(msg->pose.pose) * sensor_to_tracking->inverse()});
}
Expand All @@ -77,8 +77,8 @@ void SensorBridge::HandleNavSatFixMessage(
const carto::common::Time time = FromRos(msg->header.stamp);
if (msg->status.status == sensor_msgs::NavSatStatus::STATUS_NO_FIX) {
trajectory_builder_->AddSensorData(
sensor_id, carto::sensor::FixedFramePoseData{
time, carto::common::optional<Rigid3d>()});
sensor_id,
carto::sensor::FixedFramePoseData{time, absl::optional<Rigid3d>()});
return;
}

Expand All @@ -90,12 +90,11 @@ void SensorBridge::HandleNavSatFixMessage(
}

trajectory_builder_->AddSensorData(
sensor_id,
carto::sensor::FixedFramePoseData{
time, carto::common::optional<Rigid3d>(Rigid3d::Translation(
ecef_to_local_frame_.value() *
LatLongAltToEcef(msg->latitude, msg->longitude,
msg->altitude)))});
sensor_id, carto::sensor::FixedFramePoseData{
time, absl::optional<Rigid3d>(Rigid3d::Translation(
ecef_to_local_frame_.value() *
LatLongAltToEcef(msg->latitude, msg->longitude,
msg->altitude)))});
}

void SensorBridge::HandleLandmarkMessage(
Expand Down Expand Up @@ -127,11 +126,9 @@ std::unique_ptr<carto::sensor::ImuData> SensorBridge::ToImuData(
<< "The IMU frame must be colocated with the tracking frame. "
"Transforming linear acceleration into the tracking frame will "
"otherwise be imprecise.";
return carto::common::make_unique<carto::sensor::ImuData>(
carto::sensor::ImuData{
time,
sensor_to_tracking->rotation() * ToEigen(msg->linear_acceleration),
sensor_to_tracking->rotation() * ToEigen(msg->angular_velocity)});
return absl::make_unique<carto::sensor::ImuData>(carto::sensor::ImuData{
time, sensor_to_tracking->rotation() * ToEigen(msg->linear_acceleration),
sensor_to_tracking->rotation() * ToEigen(msg->angular_velocity)});
}

void SensorBridge::HandleImuMessage(const std::string& sensor_id,
Expand Down
Loading

0 comments on commit 2910529

Please sign in to comment.