-
-
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 Intel LibRealSense grabber and viewer #1633
Conversation
This grabber could also close #1215 |
PCL definitely needs support for librealsense, but I strongly dislike an idea of having both |
@taketwo Thank you for your replay, I am happy to know that PCL needs librealsense. Your points make sense, we should extract just one interface for the RealSense camera users and the control of frame rate and resolution should be added. However, I am not sure how to design the interface for this moment, I will discuss with my colleagues on how to design the grabber and if there is any update, I will post it in this thread. You are always welcomed to give me some suggestions, thank you again. Good day! |
@taketwo Hi, sorry for the late update. I have discussed with my colleague and take your words as a reference, we will change our grabber name as Good day! |
Since we decide which driver back-end to use during the configuration of PCL, we don't need any "real" polymorphism. We just need to separate functions into common and backend-specific at the level of source code files. That means, there is one and only "real_sense_grabber.h", it has no backend-specific code. And in the implementation file "real_sense_grabber.cpp" we keep only common functions, and put SDK and librealsense-dependent stuff into separate files (e.g. "real_sense/sdk/real_sense_grabber.cpp" and "real_sense/librealsense/real_sense_grabber.cpp"). And CMake decides which one to compile. The same for the device manager code. What do you think? |
@taketwo Thank you for your suggestion! I love your solution, actually I am doing it mostly like your suggestion since I found it is not a good way to extract a common class, and there is a little bit difference between what I have done and your suggestion. But I think your solution is better than mine, I will use your solution and test it when I have finished. Good day! |
@lebronzhang , please rebase to master. Thanks! |
@taketwo please take a look. Thanks! |
@lebronzhang , the buildbot failed, please take a look. |
6fc567b
to
9128e24
Compare
@huningxin Thank you for your reminder, all checks have passed now:) |
In general looks fine, pretty much how I expected it. One thing that I'm not satisfied with though is the CMake-related bits. Now we have two options: Would be nice to have some people confirming that this works with both backends on Windows and with librealsense on Linux. |
{ | ||
PCL_WARN ("[pcl::RealSenseGrabber::setConfidenceThreshold] Attempted to set threshold outside valid range (0-15)"); | ||
} | ||
else if (!device_->getDevice ()->supports_option (rs::option::f200_confidence_threshold)) |
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.
Why f200_confidence_threshold
? Don't other cameras support 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.
According to https://github.com/IntelRealSense/librealsense/blob/5831907ed32a52d9ff4cf7170c0580de8c283ff5/include/librealsense/rs.hpp#L61, there is only f200_confidence_threshold
defined.
I'm not sure who has hardware for testing this, but we can always request some help on the dev's mailing list. Although working with grabbers tends to be more of the same, it would also be cool if you guys could provide a tutorial, especially detailing how to select your backend. |
Hardware I have, if only someone gives me some time... :D |
Well, I think this will be integrated into 1.9.0 and it would be cool to release a 1.8.1 before, so I would say there's no rush. |
@lebronzhang did test the RSSDK backend on Windows and librealsense backend on Linux. They are the most common use cases IMO. @lebronzhang , could you please share the test results here?
Great idea. @taketwo , did you have the RSSDK grabber tutorial? It would be good to have a tutorial of RealSense cameras and include backend selection steps. What do you think? |
Hi, guys, I have tested the RSSDK backend on Windows and librealsense backend on Linux. Here is the details:
I found the same problems in the PCL master branch, so do you ever come across these problems? What do you think the problem might be? @taketwo Librealsense backend on Linux |
Backtrace it if possible.
Well now this definitely pushes it to 1.9.0. ^^ |
} | ||
for (int dy = 0; dy < depth_height; ++dy) | ||
{ | ||
uint i = dy * depth_width - 1; |
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.
Why do you use uint
instead of uint32_t
? (real_sense_grabber.cpp #L215, #L280)
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.
Thank you for your reminder, this is a mistake, I will modify it at once:)
realsense produces pcl::PointXYZRGBA but what we should do if we want to use pcl::PointXYZRGB ? |
Any update on this? |
We've started reviewing PRs in LIFO order. This won't be merged before the next release. If you need it already just apply the PR on your local fork.
|
For those interested in using this on Linux:
Setup
|
endif () | ||
else (WIN32) | ||
set(LIBREALSENSE_RELEASE_NAME librealsense.so) | ||
set(LIBREALSENSE_DEBUG_NAME librealsense.a) |
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 doesn't make much sense, in contrast with the windows branch. The first one is the shared lib and the second the static one. But both can be either release or debug.
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(LIBREALSENSE LIBREALSENSE_LIBRARIES LIBREALSENSE_INCLUDE_DIRS) | ||
|
||
endif (LIBREALSENSE_LIBRARIES AND LIBREALSENSE_INCLUDE_DIRS) |
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.
Lack of new line at the end of the file.
|
||
class RealSenseDevice; | ||
|
||
class PCL_EXPORTS RealSenseDeviceManager : boost::noncopyable |
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 moment you define your custom destructor the class is stripped of default copy operators, so this is not so usefull anymore. But then again, your destructor is not doing anything so it should just be deleted.
|
||
typedef boost::shared_ptr<RealSenseDeviceManager> Ptr; | ||
|
||
static Ptr& |
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.
Shouldn't this be a const reference? Your class is implemented as a lazy initialized singleton, so I assume you don't want to allow it to be reset and a new manager allocated later on.
} // namespace io | ||
} // namespace pcl | ||
|
||
#endif /* PCL_IO_REAL_SENSE_DEVICE_MANAGER_H */ |
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.
New line at the end of the file.
{ | ||
// This is called from public captureDevice() functions and should already be | ||
// under scoped lock | ||
RealSenseDevice::Ptr device (new RealSenseDevice (device_info.serial)); |
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.
Use make_shared instead.
device->device_ = context_.get_device (device_info.index); | ||
device_info.isCaptured = true; | ||
return device; | ||
} |
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.
No new line at the end of the file.
friend class RealSenseDeviceManager; | ||
|
||
std::string device_id_; | ||
rs::device* device_; |
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 don't like this very much. You're passing a pointer to the user which is managed by the realsense. If the user wants he can delete the pointer. Instead I propose to hold a reference to the rs::device. The user can do whatever he wants with the reference without being able to delete the resource.
} | ||
} | ||
device->stop (); | ||
} |
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.
Needs a new line at the end of the file.
|
||
pcl::io::real_sense::RealSenseDeviceManager::~RealSenseDeviceManager () | ||
{ | ||
} |
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.
To be deleted.
This pull request has been automatically marked as stale because it hasn't had Come back whenever you have time. We look forward to your contribution. |
Does this grabber supports Intel® RealSense™ SDK 2.0 (Librealsense) 2 for D400, D415, D430 Camera? |
I'd like to see this merged on master. If I apply the requested changes, should I create my own pull request (with attribution to lebronzhang), or can I attach it to this one in some way? |
Hey. This one requires C++11 support which we currently don't officially support but it's a milestone for the first quarter/half of this year. So merging to master (even after applying whatever change might be necessary) is not really possible at this point. I would apply it on your personal fork and keep it public for the time being. |
@nawalgupta No, This grabber based on librealsense 1.x. |
This pull request has been automatically marked as stale because it hasn't had Come back whenever you have time. We look forward to your contribution. |
This pull request has been automatically marked as stale because it hasn't had Come back whenever you have time. We look forward to your contribution. |
@SergioRAgostinho We don't really need libRealSense1.0 grabber now that we have libRealSense2.0 grabber? If not, please close this as well as #1215 |
This pull request adds a new grabber for Intel RealSense devices (e.g. Intel® RealSense™ F200, SR300 and R200 cameras) that supports Intel librealsense. I think it is ready to be merged into the PCL.
If there is anything needed to be done, please contact me immediately. Thanks.