Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support pcl::PointXYZRGBA to pcl::VLPGrabber #1738

Closed
wants to merge 212 commits into from

Conversation

UnaNancyOwen
Copy link
Member

Add support pcl::PointXYZRGBA to pcl::VLPGrabber.
This change will be able to attach color to point cloud using pcl::visualization::PointCloudColorHandlerRGBField.
It has already been supported in pcl::HDLGrabber.

@SergioRAgostinho SergioRAgostinho added this to the pcl-1.9.0 milestone Oct 24, 2016
@SergioRAgostinho SergioRAgostinho added the needs: code review Specify why not closed/merged yet label Oct 24, 2016
@UnaNancyOwen
Copy link
Member Author

@SergioRAgostinho
I think that this Pull Request should be included in PCL 1.8.1.
It is minor update for pcl::VLPGrabber that is included in PCL from PCL 1.8.0.

@SergioRAgostinho
Copy link
Member

@UnaNancyOwen but it makes changes to the public API and it breaks the ABI for the VLPGrabber class :/

@UnaNancyOwen
Copy link
Member Author

@SergioRAgostinho Okay, I understand.

Copy link
Member

@SergioRAgostinho SergioRAgostinho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see the usefulness of what you implemented, but I don't like the fact that the class is populating pointclouds of all types it supports, without taking into account which callbacks are actually registered. Your functionality extends this behaviour even more.

So before integrating this new feature, I would prefer to look into how to correct what I just described, and then add your functionality on top, with it just being active if I register a callback which request a pointcloud with color info.

private:
pcl::RGB laser_rgb_mapping_[VLP_MAX_NUM_LASERS];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the impression that PCL's convention is to have members bellow methods.

This guy needs a brief comment on top explaining what this is.


protected:
static const int VLP_MAX_NUM_LASERS = 16;
static const int VLP_DUAL_MODE = 0x39;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although you just moved these guys from the .cpp file, it would be nice to add a comment, to generate proper documentation about them on doxygen.

Why not both of uint8_t?

{
double vlp16_vertical_corrections[] = { -15, 1, -13, 3, -11, 5, -9, 7, -7, 9, -5, 11, -3, 13, -1, 15
for (int i = 0; i < 8; i++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following up on the comments above. I assume the limit is half the VLP_MAX_NUM_LASERS

for (uint8_t i = 0; i < VLP_MAX_NUM_LASERS / 2u ; ++i)

{
laser_rgb_mapping_[i * 2].b = static_cast<uint8_t> (i * 6 + 64);
laser_rgb_mapping_[i * 2 + 1].b = static_cast<uint8_t> ((i + 16) * 6 + 64);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... looking at this

union
{
  union
  {
    struct
    { 
      uint8_t b; 
      uint8_t g;
      uint8_t r;
      uint8_t a;
    };
    float rgb;
  };
  uint32_t rgba;
};

You're initialising the first element of b, which I have the impression that actually corresponds to the alpha component and not the blue one), because I think rgba is packed like |a|r|g|b| . I remember we had problems with floats NaN and the alfa component because of this.

0x40 0x00 0x00 0x00
0xA0 0x00 0x00 0x00

0x46 0x00 0x00 0x00
0xA6 0x00 0x00 0x00

0x4B 0x00 0x00 0x00
0xAB 0x00 0x00 0x00

0x52 0x00 0x00 0x00
0xB2 0x00 0x00 0x00

0x58 0x00 0x00 0x00
0xB8 0x00 0x00 0x00

0x5E 0x00 0x00 0x00
0xBE 0x00 0x00 0x00

...

Are you just not modifying the alpha component? Can you show me a visual results of this change you made?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be properly colored.
2017-09-13_02h19_02

current_sweep_xyzi_->header.seq = sweep_counter;

sweep_counter++;

HDLGrabber::fireCurrentSweep ();
}
current_sweep_xyz_.reset (new pcl::PointCloud<pcl::PointXYZ> ());
current_sweep_xyzrgb_.reset (new pcl::PointCloud<pcl::PointXYZRGBA> ());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although you're just using this from the base class it's kind of sad it's called *_xyzrgb and then it takes a pointcloud XYZRGBA :(

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to change name of this variable, It need to change base class.
I think It would be better to separate it into other pull requests.
What do you think?

BTW, Sorry for late reply.
I'm planning to start fix this pull request in a few days. Thanks,

*/
void
setLaserColorRGB (const pcl::RGB& color,
unsigned int laserNumber);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be uint8_t.

/////////////////////////////////////////////////////////////////////////////
void
pcl::VLPGrabber::setLaserColorRGB (const pcl::RGB& color,
unsigned int laserNumber)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uint8_t

return;

laser_rgb_mapping_[laserNumber] = color;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's kinda limiting to only be able to set one color at the time on a 16 element array. Why not add something which allows copying an entire block?

Copy link
Member Author

@UnaNancyOwen UnaNancyOwen Sep 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean adding a function such as following?

// set one color to all lasers
void
pcl::VLPGrabber::setLaserColorRGB (const pcl::RGB& color)
{
  for (uint8_t i = 0; i < VLP_MAX_NUM_LASERS; i++)
  {
    setLaserColorRGB (color, i); 
  } 
}

or

// set colors array to lasers
// note: in this case, this grabber need to provide api for the users to obtain the number of lasers.
void
pcl::VLPGrabber::setLaserColorRGB (const pcl::RGB (&colors)[VLP_MAX_NUM_LASERS])
{
  laser_rgb_mapping_ = colors;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be added to the base class as well as this class.
These change would be better to separate it into other pull requests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean adding a function such as following?

I meant the second one but if you want to be generic between HDL and VPL grabbers we should provide a signature which specifies iterators for the read beginning and end positions.

I think it should be added to the base class as well as this class.
These change would be better to separate it into other pull requests.

No need for the separate PR. Just add another commit providing the setters in HDL.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant the second one but if you want to be generic between HDL and VPL grabbers we should provide a signature which specifies iterators for the read beginning and end positions.

Can you show implementation examples?

No need for the separate PR. Just add another commit providing the setters in HDL.

I get it.

Copy link
Member

@SergioRAgostinho SergioRAgostinho Nov 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like the following would be ok for both base and derived classes but won't allow you to make a boundary check

// provide iteraror range
template<typename IterT> void
pcl::HDLGrabber::setLaserColorRGB (const IterT& begin, const IterT& end)
{
  std::copy (begin, end, laser_rgb_mapping_);
}

This needs to be implemented in the header because of the template ~and HDL will require it's own version due to the different name of the constant~~.

Another idea to allow boundary checking would be to rename these max num lasers constants to a single max_num_lasers, which is set on object construction, but this already involves a lot more changes...

@SergioRAgostinho SergioRAgostinho added needs: author reply Specify why not closed/merged yet and removed needs: code review Specify why not closed/merged yet labels Jul 2, 2017
@UnaNancyOwen
Copy link
Member Author

UnaNancyOwen commented Sep 12, 2017

@SergioRAgostinho I fixed part of pointed out in first review. Could you please confirm this changes?

I think following points would be better to separate it into other pull requests, because it need to change base class or it should be fixed to the base class as well as this class.

#1738 (comment)
#1738 (comment)

Thanks,

@SergioRAgostinho SergioRAgostinho added needs: code review Specify why not closed/merged yet and removed needs: author reply Specify why not closed/merged yet labels Nov 7, 2017
@SergioRAgostinho
Copy link
Member

Can you rebase this again? I'll have another at it soon.

@UnaNancyOwen
Copy link
Member Author

I squashed commits. Is there anything else to do?

@SergioRAgostinho
Copy link
Member

I squashed commits. Is there anything else to do?

The idea was not to squash everything yet. It was just to rebase to the current tip of master. If you check the status of this PR it says I can't merge it because there's conflicting files. The rebase will fix that.

https://stackoverflow.com/questions/7929369/how-to-rebase-local-branch-with-remote-master/18442755#18442755

@SergioRAgostinho SergioRAgostinho added changelog: API break Meta-information for changelog generation changelog: enhancement Meta-information for changelog generation needs: author reply Specify why not closed/merged yet and removed needs: code review Specify why not closed/merged yet labels Nov 22, 2017
Add support pcl::PointXYZRGBA to pcl::VLPGrabber.
This change will be able to attach color to point cloud using
pcl::visualization::PointCloudColorHandlerRGBField.
@@ -71,7 +71,7 @@ namespace pcl
* Represents 1 corrected packet from the HDL Velodyne. Each laser has a different RGB
*/
typedef void
(sig_cb_velodyne_hdl_scan_point_cloud_xyzrgb) (const boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGBA> >&,
(sig_cb_velodyne_hdl_scan_point_cloud_xyzrgba) (const boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGBA> >&,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are public typedefs and need to be deprecated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean these typedef definitions should change to protected (or private) access specifier?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change is not in scope. The idea is to not break the public API while warning the users to update their code to the new signature type. You'll need to change it to something like this

typedef void
(sig_cb_velodyne_hdl_scan_point_cloud_xyzrgba) (const boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGBA> >&,
                                                float,
                                                float);

typedef PCL_DEPRECATED ("Use 'sig_cb_velodyne_hdl_scan_point_cloud_xyzrgba' instead")
sig_cb_velodyne_hdl_scan_point_cloud_xyzrgba sig_cb_velodyne_hdl_scan_point_cloud_xyzrgb;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So apparently there's no portable solution because the deprecation attribute for typedefs is placed in different places depending on the compiler, so you'll need to safeguard against msvc and (gcc/clang). More info here https://stackoverflow.com/questions/4995868/deprecate-typedef

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add PCL_DEPRECATED

@@ -98,7 +98,7 @@ namespace pcl
* This signal is sent when the Velodyne passes angle "0". Each laser has a different RGB
*/
typedef void
(sig_cb_velodyne_hdl_sweep_point_cloud_xyzrgb) (const boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGBA> >&);
(sig_cb_velodyne_hdl_sweep_point_cloud_xyzrgba) (const boost::shared_ptr<const pcl::PointCloud<pcl::PointXYZRGBA> >&);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add PCL_DEPRECATED

@@ -152,12 +152,17 @@ namespace pcl
filterPackets (const boost::asio::ip::address& ipAddress,
const unsigned short port = 443);

/** \brief Allows one to customize the colors used for each of the lasers.
/** \brief Allows one to customize the colors used for each number of the lasers.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Switch to Allows one to customize the colors used by each laser..
  • Add the documentation for the input parameter.

@@ -80,13 +80,34 @@ namespace pcl
virtual std::string
getName () const;

/** \brief Allows one to customize the colors used for each of the lasers. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method description similar to the one before. Add doc regarding input parameters.

/** \brief Allows one to customize the colors used for each of the lasers. */
void
setLaserColorRGB (const pcl::RGB& color,
uint8_t laserNumber);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You normally wouldn't need to redefine this method, but this inheritance scheme is completely broken.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This declaration is correct, because the definition is different from base class. (laser number check)

void
pcl::HDLGrabber::setLaserColorRGB (const pcl::RGB& color,
                                   uint8_t laserNumber)
{
  if (laserNumber >= HDL_MAX_NUM_LASERS)
    return;

  laser_rgb_mapping_[laserNumber] = color;
}
void
pcl::VLPGrabber::setLaserColorRGB (const pcl::RGB& color,
                                   uint8_t laserNumber)
{
  if (laserNumber >= VLP_MAX_NUM_LASERS)
    return;

  laser_rgb_mapping_[laserNumber] = color;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right 👍

/** \brief Allows one to customize the colors used for each number of the lasers. */
void
setLaserColorRGB (const pcl::RGB& color,
unsigned int laserNumber);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Doc parameters
  • Why is this method defined in private scope?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, It is mistake.


/** \brief Allows one to customize the colors used for each of the lasers. */
void
setLaserColorRGB (const pcl::RGB (&colors)[VLP_MAX_NUM_LASERS]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here

Fix Add set colors to lasers.
@@ -189,6 +201,7 @@ namespace pcl
static const int HDL_LASER_PER_FIRING = 32;
static const int HDL_MAX_NUM_LASERS = 64;
static const int HDL_FIRING_PER_PKT = 12;
pcl::RGB laser_rgb_mapping_[HDL_MAX_NUM_LASERS];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though you're moving this to protected scope, which is correct, remember that VLPGrabber has its own laser_rgb_mapping_ member, which overshadows this one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

setLaserColorRGB( const IterT& begin, const IterT& end )
{
std::copy( begin, end, laser_rgb_mapping_ );
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing in the parenthesis in the functions/methods

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Fix Space
Deprecates old typedefs, because changed to xyzrgba from xyzrgb.
yongduek and others added 23 commits November 24, 2017 21:34
Add search path suffixes for PCL port of Vcpkg.
Add support pcl::PointXYZRGBA to pcl::VLPGrabber.
This change will be able to attach color to point cloud using
pcl::visualization::PointCloudColorHandlerRGBField.
@UnaNancyOwen
Copy link
Member Author

Sorry, I tried to organize commits, but I couldn't do it successfully.
I will send a new pull request because I'm not familiar with git operation.

@SergioRAgostinho
Copy link
Member

In case you want to read more about it, I always find this post very useful and intuitive.
https://www.atlassian.com/git/tutorials/merging-vs-rebasing

@UnaNancyOwen
Copy link
Member Author

@SergioRAgostinho Thank you telling me the documents about it! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: API break Meta-information for changelog generation changelog: enhancement Meta-information for changelog generation
Projects
None yet
Development

Successfully merging this pull request may close these issues.