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

Extending LibRS's GL support to RS ROS2 #2956

Merged
merged 6 commits into from
Feb 1, 2024

Conversation

Arun-Prasad-V
Copy link
Contributor

No description provided.

@@ -117,6 +117,7 @@ find_package(tf2 REQUIRED)
find_package(diagnostic_updater REQUIRED)

find_package(realsense2 2.54.1)
find_package(realsense2-gl 2.54.1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This means we will need to publish realsense2-gl as well right?
We need to think about if we need to make this optional somehow

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have added a cmake variable BUILD_ACCELERATE_WITH_GPU.

Copy link
Collaborator

Choose a reason for hiding this comment

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

As discussed, can you check how we do it in the viewer?
Do we depend on realsense-gl and can disable/enable on runtime?

Copy link
Collaborator

Choose a reason for hiding this comment

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

As discussed, can you check how we do it in the viewer? Do we depend on realsense-gl and can disable/enable on runtime?

Yes, I think we should release/publish realsense2-gl as well.
The viewer is depending on realsense2-gl, and you can choose this from the settings of the viewer, whether to run or not the GLSL.
@Arun-Prasad-V, did you test if user changes the parameter from 0 to 1 during runtime, while the build was without OpenGL ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to follow this guidelines same as for the SDK.

  1. Users w/o GPU are not affected (meaning users w/o GPU can install and run the ROS node)
  2. Users with GPU can decide if to leverage the GPU or not (launch file is sufficient)
  3. We need to activate the internal formal conversion using GPU as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Arun-Prasad-V, did you test if user changes the parameter from 0 to 1 during runtime, while the build was without OpenGL ?

Right now, dynamic change is not supported. User must set this param during launch.
And, if the build was without OpenGL, then this param won't be exposed to user.

@@ -215,6 +218,7 @@ set(dependencies
nav_msgs
tf2
realsense2
realsense2-gl
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same, OK for POC
For final solution we will need to rethink about it

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Nir-Az I don't think there is another way for doing that.. except if you want to create new branch for ROS, let's say, ros2-development-gl :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK, So we will have to make sure this compile on platforms w/o a GPU, and that ROS build farm accept it

@@ -82,6 +82,10 @@ void BaseRealSenseNode::getParameters()
_base_frame_id = _parameters->setParam<std::string>(param_name, DEFAULT_BASE_FRAME_ID);
_base_frame_id = (static_cast<std::ostringstream&&>(std::ostringstream() << _camera_name << "_" << _base_frame_id)).str();
_parameters_names.push_back(param_name);

param_name = std::string("data_processing_mode");
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe accelerate_with_gpu , on/off``?
Or as is with values CPU/GPU ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the param name to accelerate_with_gpu and declared this param as int not bool. Because, if in case in future, we need to add new values (like for CUDA, etc.,), it can be added easily to the int param.
@Nir-Az, your thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure CUDA is replacing GPU, let's make sure how it works in LibRS

@Arun-Prasad-V Arun-Prasad-V marked this pull request as ready for review January 10, 2024 15:51
@@ -22,6 +22,10 @@ using namespace rs2;

void BaseRealSenseNode::setup()
{
#if defined (ACCELERATE_WITH_GPU)
bool use_gpu_processing = (_accelerate_with_gpu == accelerate_with_gpu::GL_GPU);
initOpenGLProcessing(use_gpu_processing);
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we save this call if accelerate_with_gpu != GL_GPU ?
or, we must call it and init things there ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

or, we must call it and init things there ?

We must call initOpenGLProcessing() and init things even for accelerate_with_gpu != GL_GPU case, because the filter objects are created from rs::gl::colorizer, rs2::gl::align and rs2::gl::pointcloud. classes

Copy link
Collaborator

@SamerKhshiboun SamerKhshiboun left a comment

Choose a reason for hiding this comment

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

LGTM, Excellent work !

Copy link
Collaborator

@Nir-Az Nir-Az left a comment

Choose a reason for hiding this comment

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

Great work!

@Nir-Az Nir-Az merged commit 58593f6 into IntelRealSense:ros2-development Feb 1, 2024
6 checks passed
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.

3 participants