-
Notifications
You must be signed in to change notification settings - Fork 8
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
[WIP] Stereo Image Proc Disparity Image acceleration #1
base: ros2
Are you sure you want to change the base?
Conversation
Signed-off-by: Andrew Brahim <dirksavage88@gmail.com>
Signed-off-by: Andrew Brahim <dirksavage88@gmail.com>
Signed-off-by: Andrew Brahim <dirksavage88@gmail.com>
Signed-off-by: Andrew Brahim <dirksavage88@gmail.com>
Signed-off-by: Andrew Brahim <dirksavage88@gmail.com>
Signed-off-by: Andrew Brahim <dirksavage88@gmail.com>
…parity image out fix Signed-off-by: Andrew Brahim <dirksavage88@gmail.com>
Signed-off-by: Andrew Brahim <dirksavage88@gmail.com>
Signed-off-by: Andrew Brahim <dirksavage88@gmail.com>
…ores cv mat output from CV Bridge Signed-off-by: Andrew Brahim <dirksavage88@gmail.com>
Signed-off-by: Andrew Brahim <dirksavage88@gmail.com>
@vmayoral i’m able to colcon build stereo image proc but don’t see the kernel accelerator in the build-kv260/stereo_image_proc folder. I do get a warning that the .xclbin file was not found (but I also get this for the acceleration examples too). Am I missing something in the cmake file ? |
Hey @dirksavage88, seems you're making good progress 👍!
Looks good to me from a CMakeLists.txt perspective, so my only thought is that you might be getting errors in the build process. Can you check the build logs in This week I'm overflowed with work, so I'll try and make a complete review of you contribution next week. Ping me if you don't hear from me next week. |
Signed-off-by: Andrew Brahim <dirksavage88@gmail.com>
Looks like it had an issue with the platform in the config file, and in the other log it could not find the *.xo file. I've changed the platform to match what the log suggests. v++_stereolbm_accel_27105.backup.log |
Signed-off-by: Andrew Brahim <dirksavage88@gmail.com>
@dirksavage88, from the log file: ERROR: [v++ 60-602] Source file does not exist: /home/papadrew/vitis_ws/build-kv260/stereo_image_proc/stereolbm_accel.xo
INFO: [v++ 60-1662] Stopping dispatch session having empty uuid.
INFO: [v++ 60-1653] Closing dispatch client. is generally an indicator that your kernel did not synthesize successfully. There's something wrong with your code and it's not compiling a Xilinx Object ( From your other log file (the backup): ...
ERROR: [v++ 60-1258] No valid platform was found that matches 'kv260_custom_platform'. Please make sure that the platform is specified correctly, and the platform has the right version number. The platform repo paths are:
/home/papadrew/vitis_ws/acceleration/firmware/select/platform
/home/papadrew/tools/Xilinx/Vitis/2020.2/platforms
The valid platforms found from the above repo paths are:
/home/papadrew/vitis_ws/acceleration/firmware/select/platform/kv260_base.xpfm
ERROR: [v++ 60-587] Failed to add a platform: specified platform kv260_custom_platform is not found or is not valid
ERROR: [v++ 60-592] Failed to finish compilation
INFO: [v++ 60-1653] Closing dispatch client. It appears to me like you're mixing things up. Your Vitis setup seems to be |
@vmayoral I’ll take a look at it this weekend. Should I be compiling using sw or hw_emu to save time while I work out any issues with the code? Also will I need to move to ROS rolling for Vitis 2021.2? |
Using those build targets certainly helps iterating, but make sure you built against
I would recommend you to do so, yes. Most of the other image_pipeline examples are based on Vitis 2021.2. |
EDIT: I installed Rolling base from the Debian packages and it worked. I see my issue here: https://github.com/dirksavage88/image_pipeline/blob/f95cae7aabe1bfdcd711dda49935a30196c9f4f8/stereo_image_proc/src/stereo_image_proc/disparity_fpga.cpp#L376 Instead of trying to set the sensor msg image data member to the CV matrix (no header or encoding) I need to use the function overload to convert the entire CVImage to a disparity message and then that gets passed to publish. |
…x to image message conversion (cvimage -> ros image msg) Signed-off-by: dirksavage88 <dirksavage88@gmail.com>
…n cmakelist Signed-off-by: dirksavage88 <dirksavage88@gmail.com>
…esis completes without error Signed-off-by: dirksavage88 <dirksavage88@gmail.com>
@vmayoral I believe the kernel passes synthesis: I changed the kv260_custom_platform under vitis 2021.2. Looking at the vitis analyzer results. |
…clean up comments Signed-off-by: dirksavage88 <dirksavage88@gmail.com>
Hey, |
Signed-off-by: dirksavage88 <dirksavage88@gmail.com>
EDIT: Kernel passes synthesis and linked successfully, I now generated an *.xclbin file. Next is test + benchmark. I have a Jetson nano coming soon so hopefully that is a fair comparison @vmayoral |
Signed-off-by: dirksavage88 <dirksavage88@gmail.com>
Signed-off-by: dirksavage88 <dirksavage88@gmail.com>
stereo_image_proc/CMakeLists.txt
Outdated
target_link_libraries(disparity_fpga ${OpenCL_LIBRARY}) | ||
target_compile_definitions(disparity_fpga PRIVATE "COMPOSITION_BUILDING_DLL") | ||
|
||
rclcpp_components_register_nodes(disparity_fpga "stereo_image_proc::DisparityNodeFPGA") |
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 is this macro call differing from the one above ?
https://github.com/ros2/rclcpp/blob/master/rclcpp_components/cmake/rclcpp_components_register_node.cmake
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 my mistake. And this caused me issues when building, I ended up commenting out parameter callbacks.
Good catch!
@@ -0,0 +1,37 @@ | |||
#! /usr/bin/env python |
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.
Do we still need dynamic reconfigure in ros2 ?
The new parameter api support runtime changes to parameter through callbacks afaik
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 believe I copied this over from the image_proc acceleration package, I can delete this if it is not needed
stereo_image_proc/CMakeLists.txt
Outdated
) | ||
# disparity_fpga component (with OpenCL) | ||
ament_auto_add_library(disparity_fpga SHARED src/stereo_image_proc/disparity_fpga.cpp) | ||
ament_target_dependencies(${PROJECT_NAME} ${lib_depends}) |
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 is not needed. you probably wanted to set dependencies for disparity_fpga ?!
for (auto ¶m : params) | ||
{ | ||
std::string param_name = param.get_name().c_str(); | ||
std::string param_val = param.value_to_string().c_str(); |
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 params are doubles !
OCL_CHECK(err, err = krnl_->setArg(4, disp_info_msg->width)); | ||
OCL_CHECK(err, err = krnl_->setArg(5, disp_info_msg->height)); | ||
|
||
OCL_CHECK(err, queue_->enqueueWriteBuffer(imageRToDevice, CL_TRUE, 0, image_r_in_size_bytes, cv_ptr_r->image.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 enqueuing left and right buffers can be done in parallel, so no need to block the first
Simply make sure to flush the queue before enqueue the stereo matching kernel task
cv_bridge::CvImagePtr cv_ptr_l; | ||
cv_bridge::CvImagePtr cv_ptr_r; | ||
cv::Mat hls_disp16; | ||
static const double inv_dpp = 1.0 / NO_OF_DISPARITIES; |
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 would use constexp double
anyways, vitis stereo_lbm uses 12.4 fixed point, you have to the divide by 16, no ?
Signed-off-by: dirksavage88 <dirksavage88@gmail.com>
Integrate ROS acceleration stereo block match implementation (Vitis Vision library). Goal is baseline implementation of disparity image generation through the Vitis vision stereo block matching function. Next steps are to implement pointcloud and then a stereo image pipeline.
Currently testing in ROS 2 Rolling ubuntu 20.04 focal.
Roadblocks/TODO:
colcon build fails on publish method (fixed)
Synthesis fails (see below patch)
ROS rolling issue with stereo image proc pinhole camera header file (currently colcon ignored in main repo)
Apply patch to resolve revision number overflow issue, see here
verify parameter mapping to satisfy vitis vision xf_stereolbm_accel.cpp (e.g min_disparity, prefilter_cap, uniqueness ratio etc)
HLS C simulation + synthesis
disparity_fpga_nodes runs but does not show in ros2 node list or ros2 node info
test parameters (e.g. # of disparities)
qemu, gazebo simulation
install on kv260 (other platforms of community members can test)
Notes: disparity_fpga utilizes the parameter callbacks found in the original disparity_node.cpp, while I don’t know if this is necessary (since most parameters set at run time should suffice), I left this code untouched.