|
@@ -2,7 +2,7 @@
|
|
|
* @Description: match scan with grid map
|
|
|
* @Author: yct
|
|
|
* @Date: 2020-04-03 13:10:37
|
|
|
- * @LastEditTime: 2020-05-17 23:11:23
|
|
|
+ * @LastEditTime: 2020-05-21 14:52:11
|
|
|
* @LastEditors: yct
|
|
|
*/
|
|
|
|
|
@@ -53,7 +53,7 @@ Scan_match::Scan_match(std::string filename)
|
|
|
m_initial_pose_subscriber = m_nh.subscribe("/initialpose", 1, &Scan_match::initial_pose_callback, this);
|
|
|
m_cloud_publisher = m_nh.advertise<sensor_msgs::PointCloud2>("match_cloud", 10);
|
|
|
m_cloud = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>);
|
|
|
- read_pointcloud("/home/youchen/Documents/git_ws/src/map_scan_match/my1.txt", m_cloud);
|
|
|
+ //read_pointcloud("/home/youchen/Documents/git_ws/src/map_scan_match/my1.txt", m_cloud);
|
|
|
m_trans << 0.0, 0.0, 0.0;
|
|
|
if (read_map(filename))
|
|
|
{
|
|
@@ -97,7 +97,7 @@ bool Scan_match::Solve(Eigen::Vector3d &trans, pcl::PointCloud<pcl::PointXYZ>::P
|
|
|
ceres::Problem problem;
|
|
|
problem.AddResidualBlock(
|
|
|
new ceres::AutoDiffCostFunction<BicubicInterpolationCost, ceres::DYNAMIC, 3>(
|
|
|
- new BicubicInterpolationCost(m_probability_array, cloud, m_resolution, m_map_origin, 10.0 / sqrt(static_cast<double>(cloud->size()))), cloud->size()),
|
|
|
+ new BicubicInterpolationCost(m_probability_array, cloud, m_resolution, m_map_origin, 50.0 / sqrt(static_cast<double>(cloud->size()))), cloud->size()),
|
|
|
nullptr,
|
|
|
trans.data());
|
|
|
|
|
@@ -109,7 +109,7 @@ bool Scan_match::Solve(Eigen::Vector3d &trans, pcl::PointCloud<pcl::PointXYZ>::P
|
|
|
|
|
|
problem.AddResidualBlock(
|
|
|
new ceres::AutoDiffCostFunction<RotationCost, 1, 3>(
|
|
|
- new RotationCost(trans[2], 40.0)),
|
|
|
+ new RotationCost(trans[2], 10.0)),
|
|
|
nullptr,
|
|
|
trans.data());
|
|
|
|
|
@@ -141,6 +141,13 @@ bool Scan_match::Solve(Eigen::Vector3d &trans, pcl::PointCloud<pcl::PointXYZ>::P
|
|
|
pcl::toROSMsg(*temp_cloud, output_origin);
|
|
|
output_origin.header.frame_id = "map";
|
|
|
m_cloud_publisher.publish(output_origin);
|
|
|
+
|
|
|
+ tf::TransformBroadcaster tf_broadcaster_;
|
|
|
+ tf::Transform transform;
|
|
|
+ transform.setOrigin(tf::Vector3(trans[0], trans[1], 0.0));
|
|
|
+ transform.setRotation(tf::Quaternion(0, 0, sin(trans[2]/2.0), cos(trans[2]/2.0)));
|
|
|
+ tf::StampedTransform transform_msg(transform, ros::Time::now(), "map", "base_link");
|
|
|
+ tf_broadcaster_.sendTransform(transform_msg);
|
|
|
}
|
|
|
|
|
|
bool Scan_match::Solve()
|