-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Conversation
@SergioRAgostinho |
@UnaNancyOwen but it makes changes to the public API and it breaks the ABI for the VLPGrabber class :/ |
@SergioRAgostinho Okay, I understand. |
There was a problem hiding this 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.
io/include/pcl/io/vlp_grabber.h
Outdated
private: | ||
pcl::RGB laser_rgb_mapping_[VLP_MAX_NUM_LASERS]; |
There was a problem hiding this comment.
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.
io/include/pcl/io/vlp_grabber.h
Outdated
|
||
protected: | ||
static const int VLP_MAX_NUM_LASERS = 16; | ||
static const int VLP_DUAL_MODE = 0x39; |
There was a problem hiding this comment.
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
?
io/src/vlp_grabber.cpp
Outdated
{ | ||
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++) |
There was a problem hiding this comment.
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)
io/src/vlp_grabber.cpp
Outdated
{ | ||
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); | ||
} |
There was a problem hiding this comment.
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 0x000x46 0x00 0x00 0x00
0xA6 0x00 0x00 0x000x4B 0x00 0x00 0x00
0xAB 0x00 0x00 0x000x52 0x00 0x00 0x00
0xB2 0x00 0x00 0x000x58 0x00 0x00 0x00
0xB8 0x00 0x00 0x000x5E 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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
io/src/vlp_grabber.cpp
Outdated
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> ()); |
There was a problem hiding this comment.
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 :(
There was a problem hiding this comment.
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,
io/include/pcl/io/vlp_grabber.h
Outdated
*/ | ||
void | ||
setLaserColorRGB (const pcl::RGB& color, | ||
unsigned int laserNumber); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be uint8_t
.
io/src/vlp_grabber.cpp
Outdated
///////////////////////////////////////////////////////////////////////////// | ||
void | ||
pcl::VLPGrabber::setLaserColorRGB (const pcl::RGB& color, | ||
unsigned int laserNumber) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint8_t
io/src/vlp_grabber.cpp
Outdated
return; | ||
|
||
laser_rgb_mapping_[laserNumber] = color; | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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;
}
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 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) Thanks, |
Can you rebase this again? I'll have another at it soon. |
8c6145e
to
1515a0f
Compare
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. |
Add support pcl::PointXYZRGBA to pcl::VLPGrabber. This change will be able to attach color to point cloud using pcl::visualization::PointCloudColorHandlerRGBField.
1515a0f
to
0dc4b89
Compare
Add set colors to lasers.
io/include/pcl/io/hdl_grabber.h
Outdated
@@ -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> >&, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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> >&); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add PCL_DEPRECATED
io/include/pcl/io/hdl_grabber.h
Outdated
@@ -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. |
There was a problem hiding this comment.
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.
io/include/pcl/io/vlp_grabber.h
Outdated
@@ -80,13 +80,34 @@ namespace pcl | |||
virtual std::string | |||
getName () const; | |||
|
|||
/** \brief Allows one to customize the colors used for each of the lasers. */ |
There was a problem hiding this comment.
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.
io/include/pcl/io/vlp_grabber.h
Outdated
/** \brief Allows one to customize the colors used for each of the lasers. */ | ||
void | ||
setLaserColorRGB (const pcl::RGB& color, | ||
uint8_t laserNumber); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right 👍
io/include/pcl/io/vlp_grabber.h
Outdated
/** \brief Allows one to customize the colors used for each number of the lasers. */ | ||
void | ||
setLaserColorRGB (const pcl::RGB& color, | ||
unsigned int laserNumber); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, It is mistake.
io/include/pcl/io/vlp_grabber.h
Outdated
|
||
/** \brief Allows one to customize the colors used for each of the lasers. */ | ||
void | ||
setLaserColorRGB (const pcl::RGB (&colors)[VLP_MAX_NUM_LASERS]); |
There was a problem hiding this comment.
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.
io/include/pcl/io/hdl_grabber.h
Outdated
@@ -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]; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
io/include/pcl/io/hdl_grabber.h
Outdated
setLaserColorRGB( const IterT& begin, const IterT& end ) | ||
{ | ||
std::copy( begin, end, laser_rgb_mapping_ ); | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Deprecates old typedefs, because changed to xyzrgba from xyzrgb.
Update examples to support VTK >= 7.1
Suppress strict alias warning
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.
Sorry, I tried to organize commits, but I couldn't do it successfully. |
In case you want to read more about it, I always find this post very useful and intuitive. |
@SergioRAgostinho Thank you telling me the documents about it! 👍 |
Add support
pcl::PointXYZRGBA
topcl::VLPGrabber
.This change will be able to attach color to point cloud using
pcl::visualization::PointCloudColorHandlerRGBField
.It has already been supported in
pcl::HDLGrabber
.