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

Added documents for migration to URP/HDRP, and other improvements. #188

Merged
merged 20 commits into from
Mar 10, 2025

Conversation

Bob-Eric
Copy link
Contributor

@Bob-Eric Bob-Eric commented Jan 30, 2025

  1. Rewrote the Depth Camera Shader by Shader Graph to better support URP/HDRP. And added documents for migration. However, versions prior to Unity 2022 with built-in render pipeline need to use the legacy depth material.
  2. The depth value of the depth camera means the perpendicular distance from the camera plane, not a straight line from the object to the camera lens. So it is corrected.
  3. Changed asmdef to exclude Editor scripts when building.
  4. Loaded the shader via a material reference and create the corresponding material. This means there is no longer need to add custom shaders to the Always Included Shaders when building.
  5. Merged branch beta/v2.x.x. It is now possible to encode colour images in RGB8, depth images in 32FC1 and 16UC1 formats.
  6. Added raycast layermask option for raycast-based lidar sensors.
  7. Fixed a bug in TF sensor. Added TF and Clock example scene.
  8. Updated to Unity 2023.2.

alexandrefch and others added 17 commits October 7, 2024 18:27
* Switch compressed image to raw image

* Remove 'compressed' from camera topic name in camera prefab
…cs-Japan#182)

* Update to test unity2020.3.x to 2022.3.x

* Delete unnecessary files

* Fix to delete unnecessary file copy
…pth camera support UPR/HDRP; load the shader via a material reference and create the corresponding material; rename the Color2Depth shader to DepthBufferLidar shader and use it for DepthBufferLidar; Change asmdef to exclude Editor scripts when packaging
… null references in RGBDCamera_ros prefab; adjusted texture format in RGBCameraSensor; updated ImageMsgSerializer to support raw texture data serialization .
…scripts; added GPU read error logging to DepthCameraSensor; updated RaycastCommand API in IUpdateRaycastCommandsJob; added UnitySensorsROS to Some sensor prefabs; added Raycast LayerMask in RaycastLiDARSensor.
…laces the PointUtilities class and updates the associated prefabs; remove redundant Usings
…chCount in Job to improve performance; added logging of GPU read errors; removed unsafe code in PointCloud2MsgSerializer.
…re data into a single array; disabled HUD display for ROS TCP Connector to avoid lag caused by frequent GC at high frame rates; removed redundant AlwaysIncludedShaders
…mera frame_id format; fixed TFMessageMsgSerializer multiple TransformStampedMsg references to the same HeaderMsg
@Bob-Eric Bob-Eric marked this pull request as ready for review January 30, 2025 15:17
@RyodoTanaka RyodoTanaka self-requested a review March 3, 2025 15:13
@RyodoTanaka
Copy link
Member

@Bob-Eric
This PR is awesome !!
Honestly, we are not good at shader, but you almost fix every problems !
Thank you so much.

I will check your update step by step.

@RyodoTanaka
Copy link
Member

RyodoTanaka commented Mar 3, 2025

Check list

  • Rewrote the Depth Camera Shader by Shader Graph to better support URP/HDRP. And added documents for migration. However, versions prior to Unity 2022 with built-in render pipeline need to use the legacy shader.
  • The depth value of the depth camera means the perpendicular distance from the camera plane, not a straight line from the object to the camera lens. So it is corrected.
  • Changed asmdef to exclude Editor scripts when building.
  • Loaded the shader via a material reference and create the corresponding material. This means there is no longer need to add custom shaders to the Always Included Shaders when building.
  • Merged branch beta/v2.x.x. It is now possible to encode colour images in RGB8, depth images in 32FC1 and 16UC1 formats.
  • Added raycast layermask option for raycast-based lidar sensors.
  • Fixed a bug in TF sensor. Added TF and Clock example scene.
  • Updated to Unity 2023.2.

@RyodoTanaka
Copy link
Member

RyodoTanaka commented Mar 4, 2025

I found those problems.

Environment

  • Unity : 2022.3.49f1
  • Branch : pr188/dev/upstream

Depth Buffer Lidar has incorrect images.

As following, this PR still has a problem on Depth Buffer Lidars.
With 360 deg Lidar, they will return not circle, but lined observation that mentioned on #114 .
Progress from the #144 is, the data looks not be bended comparing with #144 representation.
This issue can represent with Assets/UnitySensorsROS/Samples/LiDAR/Velodyne/Demo_VLP_128_with_DepthBuffer_ros.unity.

Screenshot from 2025-03-04 11-49-15

Screenshot from 2025-03-04 11-49-24

Screenshot from 2025-03-04 11-57-38

Depth Camera Color mistake

I found that with Legacy Shader, the blue and red colors are replaced as showing on following.
This issue can represent with Assets/UnitySensorsROS/Samples/Camera/Demo_RGBDCamera_ros.unity , after you change to the legacy shader.

Screenshot from 2025-03-04 13-36-49

@Bob-Eric
Do you have any idea to fix those ... ?

@RyodoTanaka
Copy link
Member

RyodoTanaka commented Mar 4, 2025

@Bob-Eric
I have other question, to test your latest shader, which Unity version is necessary, 2023.2.x, right ?

@Bob-Eric
Copy link
Contributor Author

Bob-Eric commented Mar 4, 2025

@Bob-Eric I have other question, to test your latest shader, which Unity version is necessary, 2023.2.x, right ?

If you want to use URP or HDRP, 2022, 2023 are okay, but if you want to use built in pileline in unity 2022, you need to use the legacy depth material.

@Bob-Eric Bob-Eric closed this Mar 4, 2025
@Bob-Eric Bob-Eric reopened this Mar 4, 2025
@Bob-Eric
Copy link
Contributor Author

Bob-Eric commented Mar 4, 2025

Depth Buffer Lidar has incorrect images

I didn't change the logic of the Depth Buffer lidar shader, so it should behave the same as before!
It's actually still bended, if you move the lidar up a little bit...

{4B526C5C-4941-4455-9AAF-1DE2A8158915}

Also, I think it's possible to get the coordinates of the pixel point in the camera system directly in the ShaderGraph via the Position node.

{875AC376-A670-4302-AFB8-5532B53791F9}

Depth Camera Color mistake

As for the Depth Camera Color mistake, I think there was an error in the ROS message serialization part, I published the red point cloud directly and it showed blue in rviz...

image

The easiest way to do this is to flip the R and B channels in Assets/UnitySensors/Runtime/Scripts/Sensors/Camera/RGBDCamera/ITextureToColorPointsJob.cs
And you will get the correct color...

{CFAC7B38-4D56-4AD8-9788-CCCCEC2E7636}

@RyodoTanaka
Copy link
Member

@Bob-Eric
Thank you for your reply !

Depth Buffer Lidar has incorrect images

I see the modification is not changed, and this PR should be accepted, I think.

But we still need to fix this bending problem in other development.
So, if you have any idea to fix that, I really appreciate to know it and get PR.

Depth Camera Color mistake

I understand that the ROS software has mistake...
I think we should create some PR to them.
I do not switch R / G implementation.

So, I will accept all of this PR.

Copy link
Member

Choose a reason for hiding this comment

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

This part, I will create Issue and we should deal with those FIXME topics.
#166

@RyodoTanaka RyodoTanaka merged commit 5bd4a0d into Field-Robotics-Japan:master Mar 10, 2025
0 of 4 checks passed
@Bob-Eric Bob-Eric deleted the dev/upstream branch March 10, 2025 07:34
RyodoTanaka added a commit that referenced this pull request Mar 11, 2025
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