7 const auto buffer_size =
int{100};
10 int pcd_save_interval{0};
14 private_nh.
param<
int>(
"pcd_save_interval", pcd_save_interval, 0);
15 ROS_INFO(
"Reading scans from \"%s\"", scans_topic_.c_str());
16 ROS_INFO(
"target_frame: \"%s\"", target_frame_.c_str());
17 ROS_INFO(
"lifetime_normals_vis: %f", lifetime_normals_vis_);
18 ROS_INFO(
"pcd_save_interval: %f", pcd_save_interval);
26 if (lifetime_normals_vis_ != 0.0)
29 nh.
advertise<visualization_msgs::Marker>(kPointCloudTopic +
"_normals", buffer_size);
34 if (pcd_save_interval > 0)
55 XYZINCloud::Ptr transformed_cloud(
new XYZINCloud);
58 transformed_cloud->height = 1;
60 geometry_msgs::TransformStamped transform;
67 for (
auto it = msg->points.begin(); it != msg->points.end(); ++it)
69 if (it->intensity <= 0)
74 toposens_msgs::TsPoint msg_point = *it;
75 pcl::PointXYZINormal pcl_point =
pointTransform_->convertToXYZINormal(msg_point);
77 transformed_cloud->points.push_back(pcl_point);
86 transformed_cloud->width = transformed_cloud->points.size();
96 pcl::PointXYZINormal &pcl_point, std_msgs::Header header)
105 Vector3f translation;
106 translation[0] = transform.transform.translation.x;
107 translation[1] = transform.transform.translation.y;
108 translation[2] = transform.transform.translation.z;
111 quaternion[0] = transform.transform.rotation.x;
112 quaternion[1] = transform.transform.rotation.y;
113 quaternion[2] = transform.transform.rotation.z;
114 quaternion[3] = transform.transform.rotation.w;
123 ROS_ERROR(
"Point or normal transformation failed: %s", ex.what());
130 marker.type = visualization_msgs::Marker::ARROW;
133 marker.action = visualization_msgs::Marker::ADD;
135 marker.pose.orientation.x = 0.0;
136 marker.pose.orientation.y = 0.0;
137 marker.pose.orientation.z = 0.0;
138 marker.pose.orientation.w = 1.0;
147 for (
const auto &cloud_point : transformed_cloud->points)
152 geometry_msgs::Point point_msg;
154 point_msg.x = cloud_point.x;
155 point_msg.y = cloud_point.y;
156 point_msg.z = cloud_point.z;
158 marker.points.push_back(point_msg);
160 point_msg.x += cloud_point.normal_x * .1f;
161 point_msg.y += cloud_point.normal_y * .1f;
162 point_msg.z += cloud_point.normal_z * .1f;
164 marker.points.push_back(point_msg);
visualization_msgs::Marker marker
void doTransform(geometry_msgs::TransformStamped transform, pcl::PointXYZINormal &pt, std_msgs::Header h)
ros::Publisher marker_pub_
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ros::Publisher cloud_pub_
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
virtual geometry_msgs::TransformStamped lookupTransform(const std::string &target_frame, const std::string &source_frame, const ros::Time &time, const ros::Duration timeout) const
void publish(const boost::shared_ptr< M > &message) const
tf2_ros::Buffer tf2_buffer_
tf2_ros::TransformListener * tf2_listener_
void publishNormals(XYZINCloud::ConstPtr tc)
pcl::PointCloud< pcl::PointXYZINormal > XYZINCloud
void toPCL(const ros::Time &stamp, std::uint64_t &pcl_stamp)
static void logPointcloud()
std::unique_ptr< Mapping > pointTransform_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
float lifetime_normals_vis_
static const std::string kPointCloudTopic
void cloudCallback(const toposens_msgs::TsScan::ConstPtr &msg)
#define ROS_INFO_STREAM(args)
std::string target_frame_
TSPointCloudROS(ros::NodeHandle nh, ros::NodeHandle private_nh)
ros::Subscriber scans_sub_
void fromPCL(const std::uint64_t &pcl_stamp, ros::Time &stamp)
boost::thread * log_thread_