New Cartographer API. (#178)
parent
797ee08c5b
commit
d09c33e8f8
|
@ -229,24 +229,6 @@ sensor_msgs::PointCloud2 ToPointCloud2Message(
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
|
|
||||||
::cartographer::sensor::proto::LaserFan ToCartographer(
|
|
||||||
const pcl::PointCloud<pcl::PointXYZ>& pcl_points) {
|
|
||||||
::cartographer::sensor::proto::LaserFan proto;
|
|
||||||
|
|
||||||
auto* origin = proto.mutable_origin();
|
|
||||||
origin->set_x(0.);
|
|
||||||
origin->set_y(0.);
|
|
||||||
origin->set_z(0.);
|
|
||||||
|
|
||||||
auto* point_cloud = proto.mutable_point_cloud();
|
|
||||||
for (const auto& point : pcl_points) {
|
|
||||||
point_cloud->add_x(point.x);
|
|
||||||
point_cloud->add_y(point.y);
|
|
||||||
point_cloud->add_z(point.z);
|
|
||||||
}
|
|
||||||
return proto;
|
|
||||||
}
|
|
||||||
|
|
||||||
Rigid3d ToRigid3d(const geometry_msgs::TransformStamped& transform) {
|
Rigid3d ToRigid3d(const geometry_msgs::TransformStamped& transform) {
|
||||||
return Rigid3d(ToEigen(transform.transform.translation),
|
return Rigid3d(ToEigen(transform.transform.translation),
|
||||||
ToEigen(transform.transform.rotation));
|
ToEigen(transform.transform.rotation));
|
||||||
|
|
|
@ -64,9 +64,6 @@ geometry_msgs::Pose ToGeometryMsgPose(
|
||||||
::cartographer::sensor::proto::LaserScan ToCartographer(
|
::cartographer::sensor::proto::LaserScan ToCartographer(
|
||||||
const sensor_msgs::MultiEchoLaserScan& msg);
|
const sensor_msgs::MultiEchoLaserScan& msg);
|
||||||
|
|
||||||
::cartographer::sensor::proto::LaserFan ToCartographer(
|
|
||||||
const pcl::PointCloud<pcl::PointXYZ>& pcl_points);
|
|
||||||
|
|
||||||
::cartographer::transform::Rigid3d ToRigid3d(
|
::cartographer::transform::Rigid3d ToRigid3d(
|
||||||
const geometry_msgs::TransformStamped& transform);
|
const geometry_msgs::TransformStamped& transform);
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ void SensorBridge::HandleOdometryMessage(
|
||||||
const auto sensor_to_tracking = tf_bridge_->LookupToTracking(
|
const auto sensor_to_tracking = tf_bridge_->LookupToTracking(
|
||||||
time, CheckNoLeadingSlash(msg->child_frame_id));
|
time, CheckNoLeadingSlash(msg->child_frame_id));
|
||||||
if (sensor_to_tracking != nullptr) {
|
if (sensor_to_tracking != nullptr) {
|
||||||
trajectory_builder_->AddOdometerPose(
|
trajectory_builder_->AddOdometerData(
|
||||||
topic, time, ToRigid3d(msg->pose.pose) * sensor_to_tracking->inverse(),
|
topic, time, ToRigid3d(msg->pose.pose) * sensor_to_tracking->inverse(),
|
||||||
covariance);
|
covariance);
|
||||||
}
|
}
|
||||||
|
@ -101,46 +101,39 @@ void SensorBridge::HandleImuMessage(const string& topic,
|
||||||
|
|
||||||
void SensorBridge::HandleLaserScanMessage(
|
void SensorBridge::HandleLaserScanMessage(
|
||||||
const string& topic, const sensor_msgs::LaserScan::ConstPtr& msg) {
|
const string& topic, const sensor_msgs::LaserScan::ConstPtr& msg) {
|
||||||
HandleLaserScanProto(topic, FromRos(msg->header.stamp), msg->header.frame_id,
|
HandleRangefinder(topic, FromRos(msg->header.stamp), msg->header.frame_id,
|
||||||
ToCartographer(*msg));
|
carto::sensor::ToPointCloud(ToCartographer(*msg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SensorBridge::HandleMultiEchoLaserScanMessage(
|
void SensorBridge::HandleMultiEchoLaserScanMessage(
|
||||||
const string& topic, const sensor_msgs::MultiEchoLaserScan::ConstPtr& msg) {
|
const string& topic, const sensor_msgs::MultiEchoLaserScan::ConstPtr& msg) {
|
||||||
HandleLaserScanProto(topic, FromRos(msg->header.stamp), msg->header.frame_id,
|
HandleRangefinder(topic, FromRos(msg->header.stamp), msg->header.frame_id,
|
||||||
ToCartographer(*msg));
|
carto::sensor::ToPointCloud(ToCartographer(*msg)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SensorBridge::HandlePointCloud2Message(
|
void SensorBridge::HandlePointCloud2Message(
|
||||||
const string& topic, const sensor_msgs::PointCloud2::ConstPtr& msg) {
|
const string& topic, const sensor_msgs::PointCloud2::ConstPtr& msg) {
|
||||||
pcl::PointCloud<pcl::PointXYZ> pcl_point_cloud;
|
pcl::PointCloud<pcl::PointXYZ> pcl_point_cloud;
|
||||||
pcl::fromROSMsg(*msg, pcl_point_cloud);
|
pcl::fromROSMsg(*msg, pcl_point_cloud);
|
||||||
const carto::common::Time time = FromRos(msg->header.stamp);
|
carto::sensor::PointCloud point_cloud;
|
||||||
const auto sensor_to_tracking = tf_bridge_->LookupToTracking(
|
for (const auto& point : pcl_point_cloud) {
|
||||||
time, CheckNoLeadingSlash(msg->header.frame_id));
|
point_cloud.emplace_back(point.x, point.y, point.z);
|
||||||
if (sensor_to_tracking != nullptr) {
|
|
||||||
trajectory_builder_->AddLaserFan(
|
|
||||||
topic, time,
|
|
||||||
carto::sensor::TransformLaserFan(
|
|
||||||
carto::sensor::FromProto(ToCartographer(pcl_point_cloud)),
|
|
||||||
sensor_to_tracking->cast<float>()));
|
|
||||||
}
|
}
|
||||||
|
HandleRangefinder(topic, FromRos(msg->header.stamp), msg->header.frame_id,
|
||||||
|
point_cloud);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SensorBridge::HandleLaserScanProto(
|
void SensorBridge::HandleRangefinder(const string& topic,
|
||||||
const string& topic, const carto::common::Time time, const string& frame_id,
|
const carto::common::Time time,
|
||||||
const carto::sensor::proto::LaserScan& laser_scan) {
|
const string& frame_id,
|
||||||
const carto::sensor::LaserFan laser_fan = {
|
const carto::sensor::PointCloud& ranges) {
|
||||||
Eigen::Vector3f::Zero(),
|
|
||||||
carto::sensor::ToPointCloud(laser_scan),
|
|
||||||
{},
|
|
||||||
{}};
|
|
||||||
const auto sensor_to_tracking =
|
const auto sensor_to_tracking =
|
||||||
tf_bridge_->LookupToTracking(time, CheckNoLeadingSlash(frame_id));
|
tf_bridge_->LookupToTracking(time, CheckNoLeadingSlash(frame_id));
|
||||||
if (sensor_to_tracking != nullptr) {
|
if (sensor_to_tracking != nullptr) {
|
||||||
trajectory_builder_->AddLaserFan(
|
trajectory_builder_->AddRangefinderData(
|
||||||
topic, time, carto::sensor::TransformLaserFan(
|
topic, time, sensor_to_tracking->translation().cast<float>(),
|
||||||
laser_fan, sensor_to_tracking->cast<float>()));
|
carto::sensor::TransformPointCloud(ranges,
|
||||||
|
sensor_to_tracking->cast<float>()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,10 +63,10 @@ class SensorBridge {
|
||||||
const sensor_msgs::PointCloud2::ConstPtr& msg);
|
const sensor_msgs::PointCloud2::ConstPtr& msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void HandleLaserScanProto(
|
void HandleRangefinder(const string& topic,
|
||||||
const string& topic, const ::cartographer::common::Time time,
|
const ::cartographer::common::Time time,
|
||||||
const string& frame_id,
|
const string& frame_id,
|
||||||
const ::cartographer::sensor::proto::LaserScan& laser_scan);
|
const ::cartographer::sensor::PointCloud& ranges);
|
||||||
|
|
||||||
const SensorBridgeOptions options_;
|
const SensorBridgeOptions options_;
|
||||||
const TfBridge* const tf_bridge_;
|
const TfBridge* const tf_bridge_;
|
||||||
|
|
Loading…
Reference in New Issue