Remove implementation from TrajectoryBuilder. (#728)

To simplify the implementation of a gRPC-based trajectory builder,
this moves the existing implementation to CollatedTrajectoryBuilder
and organizes the interface by sensor type.
master
gaschler 2017-12-05 11:05:05 +01:00 committed by GitHub
parent ee9c61a736
commit b77a1f2178
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 29 deletions

View File

@ -49,10 +49,39 @@ class CollatedTrajectoryBuilder : public TrajectoryBuilder {
CollatedTrajectoryBuilder& operator=(const CollatedTrajectoryBuilder&) = CollatedTrajectoryBuilder& operator=(const CollatedTrajectoryBuilder&) =
delete; delete;
void AddSensorData(const std::string& sensor_id, void AddRangefinderData(const std::string& sensor_id, common::Time time,
std::unique_ptr<sensor::Data> data) override; const Eigen::Vector3f& origin,
const sensor::TimedPointCloud& ranges) override {
AddSensorData(sensor_id,
common::make_unique<sensor::DispatchableRangefinderData>(
time, origin, ranges));
}
void AddImuData(const std::string& sensor_id, common::Time time,
const Eigen::Vector3d& linear_acceleration,
const Eigen::Vector3d& angular_velocity) override {
AddSensorData(sensor_id, sensor::MakeDispatchable(sensor::ImuData{
time, linear_acceleration, angular_velocity}));
}
void AddOdometerData(const std::string& sensor_id, common::Time time,
const transform::Rigid3d& odometer_pose) override {
AddSensorData(sensor_id, sensor::MakeDispatchable(
sensor::OdometryData{time, odometer_pose}));
}
void AddFixedFramePoseData(
const std::string& sensor_id, common::Time time,
const transform::Rigid3d& fixed_frame_pose) override {
AddSensorData(sensor_id,
sensor::MakeDispatchable(
sensor::FixedFramePoseData{time, fixed_frame_pose}));
}
private: private:
void AddSensorData(const std::string& sensor_id,
std::unique_ptr<sensor::Data> data);
void HandleCollatedSensorData(const std::string& sensor_id, void HandleCollatedSensorData(const std::string& sensor_id,
std::unique_ptr<sensor::Data> data); std::unique_ptr<sensor::Data> data);

View File

@ -46,36 +46,21 @@ class TrajectoryBuilder {
TrajectoryBuilder(const TrajectoryBuilder&) = delete; TrajectoryBuilder(const TrajectoryBuilder&) = delete;
TrajectoryBuilder& operator=(const TrajectoryBuilder&) = delete; TrajectoryBuilder& operator=(const TrajectoryBuilder&) = delete;
virtual void AddSensorData(const std::string& sensor_id, virtual void AddRangefinderData(const std::string& sensor_id,
std::unique_ptr<sensor::Data> data) = 0; common::Time time,
void AddRangefinderData(const std::string& sensor_id, common::Time time,
const Eigen::Vector3f& origin, const Eigen::Vector3f& origin,
const sensor::TimedPointCloud& ranges) { const sensor::TimedPointCloud& ranges) = 0;
AddSensorData(sensor_id,
common::make_unique<sensor::DispatchableRangefinderData>(
time, origin, ranges));
}
void AddImuData(const std::string& sensor_id, common::Time time, virtual void AddImuData(const std::string& sensor_id, common::Time time,
const Eigen::Vector3d& linear_acceleration, const Eigen::Vector3d& linear_acceleration,
const Eigen::Vector3d& angular_velocity) { const Eigen::Vector3d& angular_velocity) = 0;
AddSensorData(sensor_id, sensor::MakeDispatchable(sensor::ImuData{
time, linear_acceleration, angular_velocity}));
}
void AddOdometerData(const std::string& sensor_id, common::Time time, virtual void AddOdometerData(const std::string& sensor_id, common::Time time,
const transform::Rigid3d& odometer_pose) { const transform::Rigid3d& odometer_pose) = 0;
AddSensorData(sensor_id, sensor::MakeDispatchable(
sensor::OdometryData{time, odometer_pose}));
}
void AddFixedFramePoseData(const std::string& sensor_id, common::Time time, virtual void AddFixedFramePoseData(
const transform::Rigid3d& fixed_frame_pose) { const std::string& sensor_id, common::Time time,
AddSensorData(sensor_id, const transform::Rigid3d& fixed_frame_pose) = 0;
sensor::MakeDispatchable(
sensor::FixedFramePoseData{time, fixed_frame_pose}));
}
}; };
} // namespace mapping } // namespace mapping