40 #include <boost/assign.hpp> 47 nh_private_(nh_private),
50 received_odom_(
false),
53 ROS_INFO(
"Starting LaserScanMatcher");
89 "pose_with_covariance", 5);
95 "pose_with_covariance_stamped", 5);
134 ROS_INFO(
"Destroying LaserScanMatcher");
340 boost::mutex::scoped_lock(
mutex_);
351 boost::mutex::scoped_lock(
mutex_);
362 boost::mutex::scoped_lock(
mutex_);
370 boost::mutex::scoped_lock(
mutex_);
423 processScan(curr_ldp_scan, scan_msg->header.stamp);
455 double pr_ch_x, pr_ch_y, pr_ch_a;
516 geometry_msgs::Pose2D::Ptr pose_msg;
517 pose_msg = boost::make_shared<geometry_msgs::Pose2D>();
526 geometry_msgs::PoseStamped::Ptr pose_stamped_msg;
527 pose_stamped_msg = boost::make_shared<geometry_msgs::PoseStamped>();
529 pose_stamped_msg->header.stamp = time;
539 geometry_msgs::PoseWithCovariance::Ptr pose_with_covariance_msg;
540 pose_with_covariance_msg = boost::make_shared<geometry_msgs::PoseWithCovariance>();
545 pose_with_covariance_msg->covariance = boost::assign::list_of
555 pose_with_covariance_msg->covariance = boost::assign::list_of
569 geometry_msgs::PoseWithCovarianceStamped::Ptr pose_with_covariance_stamped_msg;
570 pose_with_covariance_stamped_msg = boost::make_shared<geometry_msgs::PoseWithCovarianceStamped>();
572 pose_with_covariance_stamped_msg->header.stamp = time;
573 pose_with_covariance_stamped_msg->header.frame_id =
fixed_frame_;
579 pose_with_covariance_stamped_msg->pose.covariance = boost::assign::list_of
589 pose_with_covariance_stamped_msg->pose.covariance = boost::assign::list_of
632 ROS_DEBUG(
"Scan matcher total duration: %.1f ms", dur);
653 cloud_f.points.push_back(cloud->points[0]);
655 for (
unsigned int i = 1; i < cloud->points.size(); ++i)
657 const PointT& pa = cloud_f.points[cloud_f.points.size() - 1];
658 const PointT& pb = cloud->points[i];
660 double dx = pa.x - pb.x;
661 double dy = pa.y - pb.y;
662 double d2 = dx*dx + dy*dy;
666 cloud_f.points.push_back(pb);
670 unsigned int n = cloud_f.points.size();
674 for (
unsigned int i = 0; i < n; i++)
677 if (
is_nan(cloud_f.points[i].x) ||
is_nan(cloud_f.points[i].y))
679 ROS_WARN(
"Laser Scan Matcher: Cloud input contains NaN values. \ 680 Please use a filtered cloud input.");
684 double r = sqrt(cloud_f.points[i].x * cloud_f.points[i].x +
685 cloud_f.points[i].y * cloud_f.points[i].y);
699 ldp->
theta[i] = atan2(cloud_f.points[i].y, cloud_f.points[i].x);
718 unsigned int n = scan_msg->ranges.size();
721 for (
unsigned int i = 0; i < n; i++)
725 double r = scan_msg->ranges[i];
727 if (r > scan_msg->range_min && r < scan_msg->range_max)
740 ldp->
theta[i] = scan_msg->angle_min + i * scan_msg->angle_increment;
762 for (
unsigned int i = 0; i < scan_msg->ranges.size(); ++i)
764 double angle = scan_msg->angle_min + i * scan_msg->angle_increment;
765 a_cos_.push_back(cos(angle));
766 a_sin_.push_back(sin(angle));
787 ROS_WARN(
"Could not get initial transform from base to laser frame, %s", ex.what());
799 double& pr_ch_a,
double dt)
801 boost::mutex::scoped_lock(
mutex_);
815 if (pr_ch_a >=
M_PI) pr_ch_a -= 2.0 *
M_PI;
816 else if (pr_ch_a < -
M_PI) pr_ch_a += 2.0 *
M_PI;
831 if (pr_ch_a >=
M_PI) pr_ch_a -= 2.0 *
M_PI;
832 else if (pr_ch_a < -
M_PI) pr_ch_a += 2.0 *
M_PI;
843 if (pr_ch_a >=
M_PI) pr_ch_a -= 2.0 *
M_PI;
844 else if (pr_ch_a < -
M_PI) pr_ch_a += 2.0 *
M_PI;
855 q.
setRPY(0.0, 0.0, theta);
void sm_icp(struct sm_params *input, struct sm_result *output)
void publish(const boost::shared_ptr< M > &message) const
int outliers_remove_doubles
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
static double getYaw(const Quaternion &bt_q)
double max_angular_correction_deg
int orientation_neighbourhood
TFSIMD_FORCE_INLINE const tfScalar & getY() const
double clustering_threshold
double max_linear_correction
TFSIMD_FORCE_INLINE const tfScalar & y() const
double outliers_adaptive_mult
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
double restart_threshold_mean_error
void fromPCL(const pcl::uint64_t &pcl_stamp, ros::Time &stamp)
double *restrict readings
double max_correspondence_dist
void setRPY(const tfScalar &roll, const tfScalar &pitch, const tfScalar &yaw)
TFSIMD_FORCE_INLINE const tfScalar & x() const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
double do_alpha_test_thresholdDeg
static void poseTFToMsg(const Pose &bt, geometry_msgs::Pose &msg)
bool getParam(const std::string &key, std::string &s) const
TFSIMD_FORCE_INLINE const tfScalar & getX() const
int do_compute_covariance
double outliers_adaptive_order
LDP ld_alloc_new(int nrays)
int use_point_to_line_distance