1 #ifndef VELODYNE_POINTCLOUD_DATACONTAINERBASE_H 2 #define VELODYNE_POINTCLOUD_DATACONTAINERBASE_H 36 #include <velodyne_msgs/VelodyneScan.h> 38 #include <Eigen/Dense> 48 DataContainerBase(
const double max_range,
const double min_range,
const std::string& target_frame,
49 const std::string& fixed_frame,
const unsigned int init_width,
const unsigned int init_height,
50 const bool is_dense,
const unsigned int scans_per_packet,
52 :
config_(max_range, min_range, target_frame, fixed_frame, init_width, init_height, is_dense, scans_per_packet)
57 cloud.fields.reserve(fields);
60 for (
int i = 0; i < fields; ++i)
63 std::string name(va_arg(vl,
char*));
64 int count(va_arg(vl,
int));
65 int datatype(va_arg(vl,
int));
66 offset = addPointField(
cloud, name, count, datatype, offset);
69 cloud.point_step = offset;
70 cloud.row_step = init_width *
cloud.point_step;
89 Config(
double max_range,
double min_range, std::string target_frame, std::string fixed_frame,
90 unsigned int init_width,
unsigned int init_height,
bool is_dense,
unsigned int scans_per_packet)
91 : max_range(max_range)
92 , min_range(min_range)
93 , target_frame(target_frame)
94 , fixed_frame(fixed_frame)
95 , transform(fixed_frame != target_frame)
96 , init_width(init_width)
97 , init_height(init_height)
99 , scans_per_packet(scans_per_packet)
102 <<
"min_range: " << min_range <<
", max_range: " << max_range
103 <<
", target_frame: " << target_frame <<
", fixed_frame: " << fixed_frame
104 <<
", init_width: " << init_width <<
", init_height: " << init_height
105 <<
", is_dense: " << is_dense <<
", scans_per_packet: " << scans_per_packet);
109 virtual void setup(
const velodyne_msgs::VelodyneScan::ConstPtr& scan_msg)
111 cloud.header = scan_msg->header;
118 virtual void addPoint(
float x,
float y,
float z,
const uint16_t ring,
const uint16_t azimuth,
const float distance,
119 const float intensity,
const float time) = 0;
132 <<
" Velodyne points, time: " <<
cloud.header.stamp);
155 eigen_vec(0) = tf_vec[0];
156 eigen_vec(1) = tf_vec[1];
157 eigen_vec(2) = tf_vec[2];
179 Eigen::Quaternionf rotation(quaternion.w(), quaternion.x(), quaternion.y(), quaternion.z());
181 Eigen::Vector3f eigen_origin;
183 Eigen::Translation3f translation(eigen_origin);
207 #endif // VELODYNE_POINTCLOUD_DATACONTAINERBASE_H
const sensor_msgs::PointCloud2 & finishCloud()
double min_range
minimum range to publish
virtual void addPoint(float x, float y, float z, const uint16_t ring, const uint16_t azimuth, const float distance, const float intensity, const float time)=0
TFSIMD_FORCE_INLINE tfScalar distance(const Vector3 &v) const
double max_range
maximum range to publish
TFSIMD_FORCE_INLINE const tfScalar & y() const
unsigned int scans_per_packet
bool computeTransformation(const ros::Time &time)
void vectorTfToEigen(tf::Vector3 &tf_vec, Eigen::Vector3f &eigen_vec)
std::string fixed_frame
fixed frame used for transform
boost::shared_ptr< tf::TransformListener > tf_ptr
transform listener
Eigen::Affine3f transformation
bool pointInRange(float range)
TFSIMD_FORCE_INLINE const tfScalar & x() const
void transformPoint(float &x, float &y, float &z)
#define ROS_DEBUG_STREAM(args)
TFSIMD_FORCE_INLINE const tfScalar & z() const
bool transform
enable / disable transform points
#define ROS_INFO_STREAM(args)
DataContainerBase(const double max_range, const double min_range, const std::string &target_frame, const std::string &fixed_frame, const unsigned int init_width, const unsigned int init_height, const bool is_dense, const unsigned int scans_per_packet, boost::shared_ptr< tf::TransformListener > &tf_ptr, int fields,...)
Config(double max_range, double min_range, std::string target_frame, std::string fixed_frame, unsigned int init_width, unsigned int init_height, bool is_dense, unsigned int scans_per_packet)
void configure(const double max_range, const double min_range, const std::string fixed_frame, const std::string target_frame)
std::string target_frame
target frame to transform a point
virtual void setup(const velodyne_msgs::VelodyneScan::ConstPtr &scan_msg)
sensor_msgs::PointCloud2 cloud