10 #include <pcl/io/pcd_io.h> 11 #include <pcl/point_types.h> 12 #include <pcl/filters/voxel_grid.h> 14 #include "hrpsys/idl/pointcloud.hh" 19 static const char*
spec[] =
21 "implementation_id",
"PointCloudViewer",
22 "type_name",
"PointCloudViewer",
23 "description",
"Point Cloud Viewer",
24 "version", HRPSYS_PACKAGE_VERSION,
26 "category",
"example",
27 "activity_type",
"DataFlowComponent",
30 "lang_type",
"compile",
40 m_cloudIn(
"cloud", m_cloud),
42 m_viewer(
"Point Cloud Viewer"),
106 std::cout <<
m_profile.instance_name<<
": onActivated(" << ec_id <<
")" << std::endl;
112 std::cout <<
m_profile.instance_name<<
": onDeactivated(" << ec_id <<
")" << std::endl;
123 bool is_color_points =
false;
124 for (
int i = 0;
i <
m_cloud.fields.length();
i++) {
125 std::string tmp_name(
m_cloud.fields[
i].name);
126 if (tmp_name.find(
"r") != std::string::npos || tmp_name.find(
"g") != std::string::npos || tmp_name.find(
"b") != std::string::npos) {
127 is_color_points =
true;
132 if (is_color_points) {
133 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud (
new pcl::PointCloud<pcl::PointXYZRGB>);
134 cloud->is_dense =
m_cloud.is_dense;
136 float *src =
reinterpret_cast<float*
>(
m_cloud.data.get_buffer());
137 for (
unsigned int i = 0;
i< cloud->points.size();
i++) {
138 cloud->points[
i].x = src[0];
139 cloud->points[
i].y = src[1];
140 cloud->points[
i].z = src[2];
141 unsigned char *rgb = (
unsigned char *)(src+3);
142 cloud->points[
i].r = rgb[0];
143 cloud->points[
i].g = rgb[1];
144 cloud->points[
i].b = rgb[2];
151 pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (
new pcl::PointCloud<pcl::PointXYZ>);
153 float *src = (
float *)
m_cloud.data.get_buffer();
154 for (
unsigned int i=0;
i<cloud->points.size();
i++){
155 cloud->points[
i].x = src[0];
156 cloud->points[
i].y = src[1];
157 cloud->points[
i].z = src[2];
213 RTC::Create<PointCloudViewer>,
214 RTC::Delete<PointCloudViewer>);
ComponentProfile m_profile
virtual RTC::ReturnCode_t onActivated(RTC::UniqueId ec_id)
png_infop png_charpp int png_charpp profile
pcl::visualization::CloudViewer m_viewer
void PointCloudViewerInit(RTC::Manager *manager)
virtual RTC::ReturnCode_t onDeactivated(RTC::UniqueId ec_id)
coil::Properties & getProperties()
virtual RTC::ReturnCode_t onInitialize()
ExecutionContextHandle_t UniqueId
PointCloudViewer(RTC::Manager *manager)
Constructor.
InPort< PointCloudTypes::PointCloud > m_cloudIn
virtual RTC::ReturnCode_t onExecute(RTC::UniqueId ec_id)
static const char * spec[]
bool addInPort(const char *name, InPortBase &inport)
bool registerFactory(coil::Properties &profile, RtcNewFunc new_func, RtcDeleteFunc delete_func)
PointCloudTypes::PointCloud m_cloud
virtual ~PointCloudViewer()
Destructor.