ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Yes, we knew that, but the float should be non-zero anyway. Actually using the union

typedef union
  {
    struct /*anonymous*/
    {
      unsigned char Blue;
      unsigned char Green;
      unsigned char Red;
      unsigned char Alpha;
    };
    float float_value;
    long long_value;
  } RGBValue;

returned binary invalid types. But we've solved it converting it first to PointXYZRGB

pcl::PointCloud<pcl::pointxyzrgb>::iterator pt_iter = this->pcl_xyzrgb.begin(); for (int rr = 0; rr < (int)pcl_xyzrgb.height; ++rr) { for (int cc = 0; cc < (int)pcl_xyzrgb.width; ++cc, ++pt_iter) { pcl::PointXYZRGB &pt = pt_iter; RGBValue color; color.float_value= pt.rgb; matlab_xyzrgb << rr << " " << cc << " " << pt.x1000 << " " << pt.y1000 << " " << pt.z1000 << " " << (int)color.Red << " " << (int)color.Green << " " << (int)color.Blue << std::endl; } }

The code above works.

Yes, we knew that, but the float should be non-zero anyway. Actually using the union

typedef union
  {
    struct /*anonymous*/
    {
      unsigned char Blue;
      unsigned char Green;
      unsigned char Red;
      unsigned char Alpha;
    };
    float float_value;
    long long_value;
  } RGBValue;

returned binary invalid types. But we've solved it converting it first to PointXYZRGB

pcl::PointCloud<pcl::pointxyzrgb>::iterator

pcl::PointCloud<pcl::PointXYZRGB>::iterator pt_iter = this->pcl_xyzrgb.begin();
for (int rr = 0; rr < (int)pcl_xyzrgb.height; ++rr) {
  for (int cc = 0; cc < (int)pcl_xyzrgb.width; ++cc, ++pt_iter) {
    pcl::PointXYZRGB &pt = pt_iter;
*pt_iter;
    RGBValue color;
    color.float_value= pt.rgb;
    matlab_xyzrgb << rr << " " << cc << " " << pt.x1000 << " " << pt.y1000 << " " << pt.z1000 pt.x*1000 << " " << pt.y*1000 << " " << pt.z*1000 << " " << (int)color.Red << " " << (int)color.Green << " " << (int)color.Blue << std::endl;
  }
}

}

The code above works.