Skip to content

Conversation

SebastianMunozP
Copy link
Contributor

Copy link
Collaborator

@lia-viam lia-viam left a 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)
Copy link
Collaborator

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

@SebastianMunozP SebastianMunozP force-pushed the RSDK-11481-Implement-CLI-to-learn-to-manage-camera branch from 92d8e00 to 58e3173 Compare August 4, 2025 02:39
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) {
Copy link
Contributor

@seanavery seanavery Aug 5, 2025

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

Copy link
Collaborator

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

Copy link
Contributor

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!

Copy link
Collaborator

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

Copy link
Collaborator

@hexbabe hexbabe left a 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/
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] missing newline eof

Comment on lines +12 to +17
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
Copy link
Collaborator

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;
Copy link
Collaborator

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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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) {
Copy link
Collaborator

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,
Copy link
Collaborator

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;
Copy link
Collaborator

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
Copy link
Collaborator

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;
Copy link
Collaborator

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;
Copy link
Collaborator

Choose a reason for hiding this comment

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

realsense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants