43 const uint32_t laser_cloud_step = 16;
67 const sensor_msgs::Image::ConstPtr& message
75 image_channels_ = message->data.size() / (message->height * message->width);
86 const sensor_msgs::CameraInfo::ConstPtr& message
95 sensor_msgs::PointCloud2::Ptr message
126 float* pointCloudDataP =
reinterpret_cast<float*
>(&(message->data[0]));
128 const uint32_t height = message->height;
129 const uint32_t width = message->width;
130 const uint32_t cloudStep = message->point_step / message->fields.size();
132 uint32_t validPoints = 0;
133 for( uint32_t index = 0 ; index < height * width ; ++index, pointCloudDataP += cloudStep)
135 float x = pointCloudDataP[0];
136 float y = pointCloudDataP[1];
137 float z = pointCloudDataP[2];
144 if (
sqrt(x * x + y * y * z * z) > 58.0)
164 if (u <
color_image_.width && v < color_image_.height && u >= 0.0 && v >= 0.0)
167 colorPointCloudDataP[0] = x;
168 colorPointCloudDataP[1] = y;
169 colorPointCloudDataP[2] = z;
171 uint8_t* colorChannelP =
reinterpret_cast<uint8_t*
>(&colorPointCloudDataP[3]);
183 colorChannelP[2] = imageDataP[2];
184 colorChannelP[1] = imageDataP[1];
185 colorChannelP[0] = imageDataP[0];
188 colorChannelP[1] = imageDataP[1];
189 colorChannelP[0] = imageDataP[0];
192 colorChannelP[0] = imageDataP[0];
193 colorChannelP[2] = imageDataP[0];
194 colorChannelP[1] = imageDataP[0];
198 colorPointCloudDataP += cloudStep;
247 int main(
int argc,
char** argv)
251 ros::init(argc, argv,
"color_laser_publisher");
256 std::string tf_prefix;
257 nh_private.
param<std::string>(
"tf_prefix", tf_prefix,
"multisense");
263 catch(std::exception& e)
ros::Subscriber color_image_sub_
ros::Publisher color_laser_publisher_
void publish(const boost::shared_ptr< M > &message) const
sensor_msgs::Image color_image_
int main(int argc, char **argv)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
sensor_msgs::CameraInfo camera_info_
ROSCPP_DECL void spin(Spinner &spinner)
void laserPointCloudCallback(sensor_msgs::PointCloud2::Ptr message)
ros::Subscriber laser_pointcloud_sub_
void cameraInfoCallback(const sensor_msgs::CameraInfo::ConstPtr &message)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
uint32_t getNumPublishers() const
ros::NodeHandle node_handle_
void colorImageCallback(const sensor_msgs::Image::ConstPtr &message)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ColorLaser(ros::NodeHandle &nh, const std::string &tf_prefix)
INLINE Rall1d< T, V, S > sqrt(const Rall1d< T, V, S > &arg)
uint32_t getNumSubscribers() const
ros::Subscriber camera_info_sub_
sensor_msgs::PointCloud2 color_laser_pointcloud_