-
Notifications
You must be signed in to change notification settings - Fork 9
[RSDK-11481] Implement cli to learn to manage camera #78
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
base: main
Are you sure you want to change the base?
[RSDK-11481] Implement cli to learn to manage camera #78
Conversation
…ne RealSense Camera at the same time
… in device struct
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.
LGTM, just some suggestions/points for discussion
src/cli/main.cpp
Outdated
return std::fabs(p.x) >= min_distance || std::fabs(p.y) >= min_distance || std::fabs(p.z) >= min_distance; | ||
} | ||
|
||
std::vector<unsigned char> RGBPointsToPCD(std::tuple<rs2::points, rs2::video_frame> data) |
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 this implementation could be mostly copied from the one in my orbbec PR if you like
92d8e00
to
58e3173
Compare
return std::fabs(p.x) >= min_distance || std::fabs(p.y) >= min_distance || std::fabs(p.z) >= min_distance; | ||
} | ||
|
||
std::vector<PointXYZRGB> getRGBPoints(std::pair<rs2::points, rs2::video_frame>&& data) { |
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 we need to use the rvalue &&
reference on the input pair?
Would we use rvalue ref so that we can use std::move?
If that was the case I would expect:
auto points = std::move(data.first);
auto video_frame = std::move(data.second);
Also, curious why we pass in as a std::pair as opposed to separate args if we immediately split it up at the beginning of the method.
Still learning C++, so mostly asking for my understanding
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.
Rvalue reference is the result of std::move. Its implementation is simply a static_cast to &&
. See here for discussion:
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-consume
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 see, thanks for the ref!
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.
Unresolving to ask a question. So does that mean the caller of this function always needs to pass in a std::move value? What if they don't
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.
Left a mixture of cpp learning questions, regular questions, and suggestions
appimage-amd64-cli: export ARCH = x86_64 | ||
appimage-amd64-cli: viam-camera-realsense | ||
$(call BUILD_APPIMAGE,$(OUTPUT_NAME),$(ARCH)) | ||
cp ./packaging/appimages/$(OUTPUT_NAME)-*-$(ARCH).AppImage ./packaging/appimages/deploy/ |
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.
[nit] missing newline eof
if [ "${SANITIZE}" = "ON" ]; then | ||
mkdir -p $TARGET_APPDIR/usr/lib | ||
cp /lib/x86_64-linux-gnu/libabsl_* $TARGET_APPDIR/usr/lib/ | ||
cp /lib/x86_64-linux-gnu/libboost_* $TARGET_APPDIR/usr/lib/ | ||
cp /lib/x86_64-linux-gnu/libicu* $TARGET_APPDIR/usr/lib/ | ||
fi |
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.
have we tested if ASAN works with this binary?
|
||
#include <librealsense2/rs.hpp> | ||
|
||
static const double min_distance = 1e-6; |
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.
unclear why we need to filter min_distance. Is it to reduce noise?
unsigned int rgb; | ||
}; | ||
|
||
bool validPoint(const rs2::vertex &p) |
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.
bool validPoint(const rs2::vertex &p) | |
bool isValidPoint(const rs2::vertex &p) |
return std::fabs(p.x) >= min_distance || std::fabs(p.y) >= min_distance || std::fabs(p.z) >= min_distance; | ||
} | ||
|
||
std::vector<PointXYZRGB> getRGBPoints(std::pair<rs2::points, rs2::video_frame>&& data) { |
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.
Unresolving to ask a question. So does that mean the caller of this function always needs to pass in a std::move value? What if they don't
// If they match, it returns true and prints the matching parameters | ||
// If they do not match, it returns false | ||
// alignment | ||
bool checkIfMatchingColorDepthProfiles(const rs2::video_stream_profile &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.
This feels like something the SDK should take care of... is there no utility they provide that does this?
auto cfg = createSwD2CAlignConfig(my_dev->pipe, ctx, my_dev->device); | ||
if (cfg == nullptr) | ||
{ | ||
std::cerr << "Failed to create matching color-depth config for device: " << my_dev->serial_number << std::endl; |
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 we handle the error in this way? why not throw
auto dsp = dp.as<rs2::video_stream_profile>(); | ||
if (dsp.format() != RS2_FORMAT_Z16) | ||
{ | ||
continue; // Only consider Z16 format for depth |
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 if this is already something we do in the realsense module that is just being mirrored here, but is there a reason why Z16 and RGB8 are the formats we consider valid, as well as matching?
|
||
std::cout << "waiting for key press\n"; | ||
std::cin.get(); | ||
std::cout << "stopping orbbec program" << std::endl; |
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.
realsense
devices_by_serial().clear(); | ||
std::lock_guard<std::mutex> frame_lock(frame_set_by_serial_mu()); | ||
frame_set_by_serial().clear(); | ||
std::cout << "stopped orbbec program" << std::endl; |
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.
realsense
https://viam.atlassian.net/browse/RSDK-11481