0、整体架构
1、cartographer_ros
我们先看cartographer_ros 是怎样接入 cartographer的? cartographer_ros 在node_main中调用了cartographer::mapping::CreateMapBuilder(),Node对象构建;然后从cartographer中引进cartographer::mapping::MapBuilderInterface,构建了MapBuilderBridge类,所有方法由MapBuilderBridge转进Ros;如下图
LaunchSubscribers()通过SensorBridge将imu scan等topic数据转换后,传进map_builder_bridge_进行处理。
int Node::AddTrajectory(const TrajectoryOptions& options) { const std::set<cartographer::mapping::TrajectoryBuilderInterface::SensorId> expected_sensor_ids = ComputeExpectedSensorIds(options); const int trajectory_id = map_builder_bridge_.AddTrajectory(expected_sensor_ids, options); AddExtrapolator(trajectory_id, options); AddSensorSamplers(trajectory_id, options); LaunchSubscribers(options, trajectory_id); wall_timers_.push_back(node_handle_.createWallTimer( ::ros::WallDuration(kTopicMismatchCheckDelaySec), &Node::MaybeWarnAboutTopicMismatch, this, /*oneshot=*/true)); for (const auto& sensor_id : expected_sensor_ids) { subscribed_topics_.insert(sensor_id.id); } return trajectory_id; }