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

DO NOT MERGE Azure Kinect Auto Tune Exposure Node #6

Open
wants to merge 497 commits into
base: plusone
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
497 commits
Select commit Hold shift + click to select a range
dde672a
corrected node handle name
ShannonPlusOne Jun 5, 2023
8d9c689
remove mock image for now
ShannonPlusOne Jun 5, 2023
e4ad4ee
updated testing param names
ShannonPlusOne Jun 5, 2023
3b44611
fixing makefile
ShannonPlusOne Jun 5, 2023
cd21522
update cmake to include when testing
ShannonPlusOne Jun 5, 2023
0160db1
fixing makefile
ShannonPlusOne Jun 5, 2023
a1203a2
fixing make file
ShannonPlusOne Jun 5, 2023
02e6d74
fixing cmake file
ShannonPlusOne Jun 5, 2023
c1e1798
added sanity prints
ShannonPlusOne Jun 5, 2023
a024a88
is ros too powerful when in control of time
ShannonPlusOne Jun 5, 2023
5ba80d3
sanity checks
ShannonPlusOne Jun 5, 2023
6481e25
like a record baby
ShannonPlusOne Jun 5, 2023
f4aa43c
initialize node with node handle
ShannonPlusOne Jun 5, 2023
9690980
updated test params
ShannonPlusOne Jun 5, 2023
2d3179e
added time limit
ShannonPlusOne Jun 5, 2023
6b23828
refactoring node to check error codes
ShannonPlusOne Jun 5, 2023
3604de3
updated test file
ShannonPlusOne Jun 5, 2023
685daea
fixed return type in header file
ShannonPlusOne Jun 5, 2023
bee4c20
fixed variable typo
ShannonPlusOne Jun 6, 2023
cea37fd
blue check
ShannonPlusOne Jun 6, 2023
9479f08
fixed variable typo, shortened test time out allowance
ShannonPlusOne Jun 6, 2023
35ea7dd
fixed typos (rearranged arguments to be more uniform)
ShannonPlusOne Jun 6, 2023
1bb15f1
fixing image transport
ShannonPlusOne Jun 6, 2023
1c7edce
semicolons will be the end of me
ShannonPlusOne Jun 6, 2023
5b92f05
added opencv requirement for testing
ShannonPlusOne Jun 6, 2023
75c0417
updated testing requirements for catkin in cmake
ShannonPlusOne Jun 6, 2023
33141d1
fixed cmake
ShannonPlusOne Jun 6, 2023
a00dd7a
fixing makefile
ShannonPlusOne Jun 6, 2023
7e5fefa
fixed cmake
ShannonPlusOne Jun 6, 2023
f2021f1
pinpointing where error is coming from
ShannonPlusOne Jun 6, 2023
68dff3c
fixing make file and test calls
ShannonPlusOne Jun 6, 2023
e336f32
fixed param typo
ShannonPlusOne Jun 6, 2023
15377a5
pls build
ShannonPlusOne Jun 6, 2023
1db6d7e
Merge pull request #6 from ShannonPlusOne/azure-tests
ShannonPlusOne Jun 6, 2023
c63eccb
removed original test file
ShannonPlusOne Jun 6, 2023
531b059
target blue check
ShannonPlusOne Jun 6, 2023
1dd2c7a
target blue in header file
ShannonPlusOne Jun 6, 2023
2d67da8
target blue check tests
ShannonPlusOne Jun 6, 2023
f94f056
corrected assert true to assert false
ShannonPlusOne Jun 6, 2023
c2c77b8
added more tests, refactored error code calls
ShannonPlusOne Jun 6, 2023
8ec9b87
updated header file
ShannonPlusOne Jun 6, 2023
6120eff
updated calls, fixed parameter errors
ShannonPlusOne Jun 6, 2023
aebe065
missed semicolon
ShannonPlusOne Jun 6, 2023
b08afe4
refactoring exp bounds and blue value bounds
ShannonPlusOne Jun 6, 2023
88e9fbb
fixed param typos
ShannonPlusOne Jun 6, 2023
da51f2a
fixed param typos
ShannonPlusOne Jun 6, 2023
bff5394
added custom dynamic reconfig back to tests
ShannonPlusOne Jun 6, 2023
9c0bfa6
added exposure bounds test
ShannonPlusOne Jun 7, 2023
310a516
fixed param typo
ShannonPlusOne Jun 7, 2023
ff6e306
blue bounds check
ShannonPlusOne Jun 7, 2023
e0ef477
fixed error code call typo
ShannonPlusOne Jun 7, 2023
7b1a8bc
fixed typo
ShannonPlusOne Jun 7, 2023
f77bf42
fixed test_message typo for blue bound check
ShannonPlusOne Jun 7, 2023
a83ec7f
cleaned up tests
ShannonPlusOne Jun 7, 2023
35f24a0
removed in progress code
ShannonPlusOne Jun 7, 2023
f125216
added empty image check
ShannonPlusOne Jun 7, 2023
c9a978c
corrected header file
ShannonPlusOne Jun 7, 2023
b1323a5
fixed mat param
ShannonPlusOne Jun 7, 2023
f768202
fixed pointer call
ShannonPlusOne Jun 7, 2023
df10b5c
cleaned up
ShannonPlusOne Jun 7, 2023
fe23cfe
fixed error code typo
ShannonPlusOne Jun 7, 2023
6457b99
mock published images and dynamic reconfigured callback
ShannonPlusOne Jun 7, 2023
11406fa
fixed test param typo
ShannonPlusOne Jun 7, 2023
f683c6e
Merge pull request #7 from ShannonPlusOne/azure-tests
ShannonPlusOne Jun 7, 2023
04892ac
Update README.md
ShannonPlusOne Jun 7, 2023
829f572
updated header file to #pragma once
ShannonPlusOne Jun 7, 2023
7b364ec
added more thorough documentation, removed points2 code
ShannonPlusOne Jun 7, 2023
d25eb94
added default constructor/deconstructor back to appease catkin test
ShannonPlusOne Jun 7, 2023
1f864e8
removed points header for now
ShannonPlusOne Jun 7, 2023
662334a
fixed typo header file
ShannonPlusOne Jun 7, 2023
af46134
removed pseudo publisher from test file
ShannonPlusOne Jun 7, 2023
f26948a
added back mock image data
ShannonPlusOne Jun 8, 2023
24f40b2
call constructor with node handle in test file
ShannonPlusOne Jun 8, 2023
8ec7562
removed fake image publisher and mock dynamic reconfigure in test file
ShannonPlusOne Jun 8, 2023
6f5979e
updated cmake, removed fake publisher in test
ShannonPlusOne Jun 8, 2023
338e82d
added header file to library
ShannonPlusOne Jun 8, 2023
61f111a
fixing cmake
ShannonPlusOne Jun 8, 2023
0cd2ac1
fixing cmake, moving heavy libraries from h to cpp
ShannonPlusOne Jun 8, 2023
9d0fd7d
added #include <opencv2/core/mat.hpp> to test file
ShannonPlusOne Jun 8, 2023
6acad90
moved cv bridge h file back to node h file
ShannonPlusOne Jun 8, 2023
fe329ac
moved image transport
ShannonPlusOne Jun 8, 2023
f09d417
go back
ShannonPlusOne Jun 8, 2023
8cef2ca
fixing cmake
ShannonPlusOne Jun 8, 2023
e48a1f4
image_transport.h is deprecated, using .hpp
ShannonPlusOne Jun 8, 2023
41af02b
correcting header file path
ShannonPlusOne Jun 8, 2023
2546047
wrong header file, hpp is ros2
ShannonPlusOne Jun 8, 2023
411e9f4
updated cmake
ShannonPlusOne Jun 8, 2023
5a0d512
removed ros init in test file
ShannonPlusOne Jun 8, 2023
ce34b51
updating package file
ShannonPlusOne Jun 8, 2023
3ad31f1
adding ros init back to test file
ShannonPlusOne Jun 8, 2023
71dfa43
moved image transport and opencv to cpp file
ShannonPlusOne Jun 8, 2023
84ec608
declare k4acvimgptr in callback
ShannonPlusOne Jun 8, 2023
c9d9753
added opencv header back to node header
ShannonPlusOne Jun 8, 2023
e77e1fc
revert
ShannonPlusOne Jun 8, 2023
0b71ce7
linking header file cmake
ShannonPlusOne Jun 8, 2023
42c8deb
fixing cmake
ShannonPlusOne Jun 8, 2023
7cfcec4
fixing cmake
ShannonPlusOne Jun 8, 2023
a021180
cmake
ShannonPlusOne Jun 8, 2023
6523d46
fixing make file required
ShannonPlusOne Jun 8, 2023
281c8fa
revert
ShannonPlusOne Jun 8, 2023
8a8b5c3
removed portesting library
ShannonPlusOne Jun 8, 2023
da130e8
removed libraries
ShannonPlusOne Jun 8, 2023
f5b1730
fixing makefile
ShannonPlusOne Jun 8, 2023
9fb1000
fixing cmake
ShannonPlusOne Jun 8, 2023
6e1c513
include node for gtest
ShannonPlusOne Jun 8, 2023
434b08b
multiple main, only include header file
ShannonPlusOne Jun 8, 2023
5eb1c5a
fix makefile
ShannonPlusOne Jun 8, 2023
3209e65
fixing makefile
ShannonPlusOne Jun 8, 2023
e596e1a
removed main from calibration node, added init to Microsoft node
ShannonPlusOne Jun 8, 2023
7a7a367
typo
ShannonPlusOne Jun 8, 2023
e885bd0
revert
ShannonPlusOne Jun 8, 2023
3fc142b
removed main from node
ShannonPlusOne Jun 8, 2023
2799540
fdjkldlkjfaljkfdaldjfslj
ShannonPlusOne Jun 8, 2023
90ce033
fixing header files, refactored node
ShannonPlusOne Jun 8, 2023
1765264
rearranging cmake
ShannonPlusOne Jun 8, 2023
baab7f3
moved include
ShannonPlusOne Jun 8, 2023
c9efe40
fixing cmake
ShannonPlusOne Jun 8, 2023
c6d37f1
install lib
ShannonPlusOne Jun 8, 2023
dcd5de0
removed header files from cpp files
ShannonPlusOne Jun 8, 2023
2b20ced
cleaned up and added por labels
ShannonPlusOne Jun 8, 2023
5f9dec1
Merge pull request #8 from ShannonPlusOne/azure-polish
ShannonPlusOne Jun 8, 2023
e9f6082
changed int to unit32_t or uint8_t
ShannonPlusOne Jun 9, 2023
25fdf16
updated int types to appropriate uint
ShannonPlusOne Jun 9, 2023
e86652a
corrected error code to int8_t (needs to be + and -)
ShannonPlusOne Jun 9, 2023
2222117
consts
ShannonPlusOne Jun 9, 2023
d5b5711
added consistent _ to private members
ShannonPlusOne Jun 9, 2023
2afab2c
fixed int type in msg
ShannonPlusOne Jun 9, 2023
3714baf
fixed srv files
ShannonPlusOne Jun 9, 2023
8780cd9
fixed srv files
ShannonPlusOne Jun 9, 2023
ed65238
updated srv to reflect const changes
ShannonPlusOne Jun 9, 2023
7457abe
revert
ShannonPlusOne Jun 9, 2023
c53f906
revert
ShannonPlusOne Jun 9, 2023
c9b3f31
generate messages sooner
ShannonPlusOne Jun 9, 2023
d63bbd9
wrong order
ShannonPlusOne Jun 9, 2023
05ae3fd
revert error code name
ShannonPlusOne Jun 9, 2023
86a2655
cannot use consts in ros msg files, updated header and cpp to reflect
ShannonPlusOne Jun 9, 2023
88cc2a2
ros pls
ShannonPlusOne Jun 9, 2023
391a5cb
ros msg primitive type doesn't follow cpp types TIL
ShannonPlusOne Jun 9, 2023
a37f48e
appeasing catkin test default tors
ShannonPlusOne Jun 9, 2023
fcf552d
tors in cpp
ShannonPlusOne Jun 9, 2023
6cf296c
fixed consts in utest
ShannonPlusOne Jun 9, 2023
a41aaf0
updated utest error codes to correct int8
ShannonPlusOne Jun 9, 2023
db7272b
by nature of uint8 blue vals can only be 0-255 therefore always in range
ShannonPlusOne Jun 9, 2023
3423ecd
by using uint8 as the type for anything blue value related the variab…
ShannonPlusOne Jun 9, 2023
73809e3
Merge pull request #9 from ShannonPlusOne/azure-polish2
ShannonPlusOne Jun 9, 2023
559ca1a
added white balance reconfigure support
ShannonPlusOne Jun 20, 2023
de78261
updated header file with appropriate methods, fixed duplicate/incorre…
ShannonPlusOne Jun 20, 2023
bedec73
corrected test typos
ShannonPlusOne Jun 20, 2023
418c65a
fixed test typos, calling exposure checks not wb checks
ShannonPlusOne Jun 20, 2023
24e5811
Merge pull request #10 from ShannonPlusOne/azure-polish2
ShannonPlusOne Jun 20, 2023
138d9e4
fleshed out white balance service
ShannonPlusOne Jun 21, 2023
2fb3303
corrected includes in header file for new srv
ShannonPlusOne Jun 21, 2023
021e0fb
renamed node for broader definition
ShannonPlusOne Jun 21, 2023
df0dffc
corrected test file with updated naming convention
ShannonPlusOne Jun 21, 2023
8adc00c
added sgd algorithm for exposure/white balance tuning
ShannonPlusOne Jun 21, 2023
6c50e38
updated service with appropriate var types
ShannonPlusOne Jun 21, 2023
b394182
fixed brackets typo
ShannonPlusOne Jun 21, 2023
f4512f3
added sgd tune srv file to cmake
ShannonPlusOne Jun 21, 2023
6850ba3
fixed msg float type to float32
ShannonPlusOne Jun 21, 2023
b679d4f
fixed type typo in header
ShannonPlusOne Jun 21, 2023
c900fc1
corrected string formatting for double
ShannonPlusOne Jun 21, 2023
844d2fd
corrected cv color convert for hls
ShannonPlusOne Jun 21, 2023
30438e6
corrected opencv calls for hls image conversion
ShannonPlusOne Jun 21, 2023
1930dbf
testing starting from minimum exposure and minimum white balance
ShannonPlusOne Jun 21, 2023
5f4f834
added bound checks for sgd
ShannonPlusOne Jun 21, 2023
ff8c8ff
added info messages for current errors/avgs
ShannonPlusOne Jun 21, 2023
967c568
updated sgd
ShannonPlusOne Jun 21, 2023
be0f311
exposure bgr, white balance white
ShannonPlusOne Jun 21, 2023
7b1718f
was exiting loop early due to typo, oops
ShannonPlusOne Jun 21, 2023
7327676
added rmse
ShannonPlusOne Jun 21, 2023
0e66c6e
starting at default exposure, fixed normal dist to be 0-1
ShannonPlusOne Jun 21, 2023
7b1880d
normal dist -1 to 1
ShannonPlusOne Jun 21, 2023
29ff7a6
changing learning rate
ShannonPlusOne Jun 21, 2023
3b62bc5
starting from min camera params
ShannonPlusOne Jun 22, 2023
2966b4a
updating exposure settings through pointers
ShannonPlusOne Jun 22, 2023
73da0db
updated errors
ShannonPlusOne Jun 22, 2023
2dc1c93
updated header file for updated rmse
ShannonPlusOne Jun 22, 2023
2516763
starting at default values
ShannonPlusOne Jun 22, 2023
51f05a6
added random dis back
ShannonPlusOne Jun 22, 2023
67c8751
reduced num iterations
ShannonPlusOne Jun 22, 2023
704dfe2
pointers
ShannonPlusOne Jun 22, 2023
77b90f1
subtract for updates
ShannonPlusOne Jun 22, 2023
0789bb0
removed normal dis
ShannonPlusOne Jun 22, 2023
f17d6be
testing one param at a time
ShannonPlusOne Jun 22, 2023
df9241f
updated rgbcallback to update hls image
ShannonPlusOne Jun 22, 2023
0ec4304
removed mutex lock for image conversion in rgb callback
ShannonPlusOne Jun 22, 2023
a40ae03
added normal distribution back
ShannonPlusOne Jun 22, 2023
f5ab56c
added exposure calculations back in
ShannonPlusOne Jun 22, 2023
750f3ac
updated exposure info to only allow for actual exposure options for K…
ShannonPlusOne Jun 22, 2023
6247cba
corrected array init, updated update exposure to check closest value …
ShannonPlusOne Jun 22, 2023
a6bf068
updated update exposure with checks for closest exp
ShannonPlusOne Jun 22, 2023
1ba937c
fixed typo
ShannonPlusOne Jun 22, 2023
0beaa8a
appeasing abs gods
ShannonPlusOne Jun 22, 2023
b834eb9
added break statements
ShannonPlusOne Jun 22, 2023
fecb776
made separate exposure conversion function
ShannonPlusOne Jun 22, 2023
7a7cf75
added testing for kinect exposure standardization
ShannonPlusOne Jun 22, 2023
5abeee3
gave tests own array
ShannonPlusOne Jun 22, 2023
bb8f378
fixed typo in test file
ShannonPlusOne Jun 22, 2023
57d4ab7
fixing uint32 weirdness
ShannonPlusOne Jun 22, 2023
e8c9f52
what is happening
ShannonPlusOne Jun 22, 2023
4b1b9a5
trying to fix incorrect num comparisons
ShannonPlusOne Jun 22, 2023
49a9f9f
do the other tests that large fail?
ShannonPlusOne Jun 22, 2023
c8ee50f
corrected typo in loop (facepalm)
ShannonPlusOne Jun 22, 2023
82703ab
cleaning up auto tune
ShannonPlusOne Jun 22, 2023
01a7bbc
fixed typo re added color channels dec
ShannonPlusOne Jun 22, 2023
654e5fd
fixed typo
ShannonPlusOne Jun 22, 2023
c18fad8
standardize exposure in sgd
ShannonPlusOne Jun 22, 2023
eef5de0
normal dis for exp
ShannonPlusOne Jun 22, 2023
7d5783a
we're gonna break it, learning rate 100
ShannonPlusOne Jun 22, 2023
94516c3
ok 100 was too much how about 10
ShannonPlusOne Jun 22, 2023
41e96a1
updated learning rate
ShannonPlusOne Jun 27, 2023
cd6c413
updated error calculations
ShannonPlusOne Jun 27, 2023
0387323
updated sgd error calculations
ShannonPlusOne Jun 28, 2023
8bfc5e7
removed prediction/cost/gradient functions for now
ShannonPlusOne Jun 28, 2023
1d148a7
updated error calculations
ShannonPlusOne Jun 28, 2023
77d3dc7
updated sgd service for better readability
ShannonPlusOne Jun 28, 2023
ddb2a57
updated header file for updated sgd tune params
ShannonPlusOne Jun 28, 2023
146c066
updated rmse
ShannonPlusOne Jun 28, 2023
267cba2
corrected param order
ShannonPlusOne Jun 28, 2023
5dfb703
added check for div by 0
ShannonPlusOne Jun 28, 2023
dbd1238
fixed rmse calculation
ShannonPlusOne Jun 28, 2023
1eca6bc
iterations need to be float or else all rmse will be 0
ShannonPlusOne Jun 28, 2023
a46fdb2
updated rmse, using vectors to calculate correctly
ShannonPlusOne Jun 28, 2023
c9d65eb
fixed include for vector
ShannonPlusOne Jun 28, 2023
5b6dcd4
fixed vectors
ShannonPlusOne Jun 28, 2023
765bde2
exposure isn't changing at all
ShannonPlusOne Jun 28, 2023
86c61c0
normal dist
ShannonPlusOne Jun 28, 2023
8793829
include random
ShannonPlusOne Jun 28, 2023
e96852e
updated iterations (rmse vector getting too large)
ShannonPlusOne Jun 28, 2023
fae3e5f
added all bgrw error to both metrics
ShannonPlusOne Jun 28, 2023
d8300cb
exposure time is making no changes
ShannonPlusOne Jun 28, 2023
5095b0f
updating exposure changes
ShannonPlusOne Jun 28, 2023
ba39df5
updating error calculations
ShannonPlusOne Jun 28, 2023
4dc3e60
normalizing white rmse 0-1 to use index for exposure setting
ShannonPlusOne Jun 28, 2023
059577e
fixed typos
ShannonPlusOne Jun 28, 2023
6744af6
revert
ShannonPlusOne Jun 28, 2023
41a1456
updated exposure update calc
ShannonPlusOne Jun 28, 2023
cd5491b
sanity print out for final blue value
ShannonPlusOne Jun 28, 2023
7277747
standardizing input for rmse
ShannonPlusOne Jun 28, 2023
0104dde
fixed typo
ShannonPlusOne Jun 28, 2023
778ace7
fixed typo on param list
ShannonPlusOne Jun 28, 2023
719f1fa
update header file
ShannonPlusOne Jul 17, 2023
b5b7544
updated for demo
ShannonPlusOne Aug 11, 2023
d409e5f
Merge pull request #11 from ShannonPlusOne/azure-polish2
ShannonPlusOne Aug 11, 2023
9e8319e
Update k4a_por_calibration.h
ShannonPlusOne Aug 11, 2023
4dbd513
Update k4a_por_calibration.cpp
ShannonPlusOne Aug 11, 2023
4bb071d
Update k4a_por_calibration.h
ShannonPlusOne Aug 11, 2023
35047a2
Update CMakeLists.txt
ShannonPlusOne Aug 11, 2023
19b7a33
Update CMakeLists.txt
ShannonPlusOne Aug 11, 2023
d8d54fc
Add files via upload
ShannonPlusOne Aug 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 100 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ option(CUDA_SUPPORT "use CUDA support onnxruntime library" ON)
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
message_generation
sensor_msgs
image_transport
image_geometry
Expand All @@ -34,6 +35,19 @@ find_package(OpenCV REQUIRED)
generate_dynamic_reconfigure_options(
cfg/AzureKinectParams.cfg
)
add_message_files(
FILES
k4aCameraExposureServiceErrorCode.msg
)
add_service_files(
FILES
k4a_auto_tune_exposure.srv
k4a_update_exposure.srv
)
generate_messages(
DEPENDENCIES
std_msgs
)

###################################
## catkin specific configuration ##
Expand All @@ -45,16 +59,49 @@ generate_dynamic_reconfigure_options(
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES k4a_ros_bridge
# CATKIN_DEPENDS roscpp std_msgs
# DEPENDS system_lib
INCLUDE_DIRS include
LIBRARIES k4a_exposure_calibration_lib
CATKIN_DEPENDS
roscpp
std_msgs
message_runtime
image_transport
cv_bridge
# DEPENDS system_lib
)

###########
## Build ##
###########

##################################
####### START POR BUILD ##########
##################################

include_directories(
${catkin_INCLUDE_DIRS}
include
)
add_library(k4a_exposure_calibration_lib
src/k4a_exposure_calibration.cpp)
target_link_libraries(k4a_exposure_calibration_lib ${catkin_LIBRARIES})
add_dependencies(k4a_exposure_calibration_lib ${catkin_EXPORTED_TARGETS})

add_executable(k4a_exposure_calibration_node
src/k4a_exposure_calibration_node.cpp
)
target_link_libraries(k4a_exposure_calibration_node
${catkin_LIBRARIES}
${OpenCV_LIBS}
k4a_exposure_calibration_lib
)
add_dependencies(k4a_exposure_calibration_node ${PROJECT_NAME}_gencfg ${catkin_EXPORTED_TARGETS})
target_compile_features(k4a_exposure_calibration_node PUBLIC cxx_std_11)

##################################
####### END POR BUILD ############
##################################


## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
Expand All @@ -67,7 +114,6 @@ add_executable(${PROJECT_NAME}_node
)
add_dependencies(${PROJECT_NAME}_node ${PROJECT_NAME}_gencfg)
target_compile_features(${PROJECT_NAME}_node PUBLIC cxx_std_11)

add_library(${PROJECT_NAME}_nodelet
src/k4a_ros_bridge_nodelet.cpp
src/k4a_ros_device.cpp
Expand All @@ -77,6 +123,7 @@ add_library(${PROJECT_NAME}_nodelet
add_dependencies(${PROJECT_NAME}_nodelet ${PROJECT_NAME}_gencfg)
target_compile_features(${PROJECT_NAME}_nodelet PUBLIC cxx_std_11)


## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
## target back to the shorter version for ease of user use
Expand Down Expand Up @@ -222,6 +269,33 @@ include(Installk4a)
###### END AZURE KINECT SDK ######
##################################


##################################
####### START POR TESTING ########
##################################

if(CATKIN_ENABLE_TESTING)
find_package(rostest REQUIRED
cv_bridge
image_transport)
include_directories(
${catkin_INCLUDE_DIRS}
"include"
k4a_exposure_calibration_node.h
)
add_rostest_gtest(utest_node test/utest_launch.test src/test/utest.cpp)
target_link_libraries(utest_node
${K4A_LIBS}
${catkin_LIBRARIES}
${OpenCV_LIBS}
k4a_exposure_calibration_lib
)
endif()

##################################
###### END POR TESTING ###########
##################################

include_directories(
${catkin_INCLUDE_DIRS}
"include"
Expand Down Expand Up @@ -253,6 +327,26 @@ install(TARGETS ${PROJECT_NAME}_node
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(TARGETS k4a_exposure_calibration_lib
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

##################################
###### START POR INSTALL #########
##################################

install(TARGETS k4a_exposure_calibration_node
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

##################################
###### END POR INSTALL ###########
##################################

install(TARGETS ${PROJECT_NAME}_nodelet
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
Expand All @@ -271,3 +365,4 @@ install(FILES
nodelet_plugins.xml
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ However, this node does ***not*** expose all the sensor data from the Azure Kine

For more information about how to use the node, please see the [usage guide](docs/usage.md).

## PlusOne Robotics Features

The k4a_exposure_calibration node allows users to both update the Azure Kinect camera's exposure and to auto tune the exposure for a provided average blue value from the command line.

## Status

This code is provided as a starting point for using the Azure Kinect Developer Kit with ROS. Community developed features are welcome.
Expand Down
158 changes: 158 additions & 0 deletions include/azure_kinect_ros_driver/k4a_exposure_calibration.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
// PlusOne Robotics
// Author: Shannon Stoehr
// email: [email protected]

#pragma once

// Library headers
#include <ros/ros.h>
#include <sensor_msgs/Image.h>
#include <image_transport/image_transport.h>
#include <cv_bridge/cv_bridge.h>
#include <opencv2/opencv.hpp>
#include <dynamic_reconfigure/client.h>
#include <k4a/k4a.h>
#include <mutex>

// Project headers
#include "azure_kinect_ros_driver/AzureKinectParamsConfig.h"
#include "azure_kinect_ros_driver/k4a_update_exposure.h"
#include "azure_kinect_ros_driver/k4a_auto_tune_exposure.h"
#include "azure_kinect_ros_driver/k4aCameraExposureServiceErrorCode.h"

/**
* @brief Class that allows the user to tune exposure in real time from the command line
*/
class K4AExposureCalibration
{
public:
/** @brief default constructor and destructor*/
K4AExposureCalibration();
Copy link

Choose a reason for hiding this comment

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

I'd remove the default constructor so as not to allow it. It doesn't make much sense without a NodeHandle anyway.

Copy link
Author

Choose a reason for hiding this comment

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

So, unfortunately for now these are required in order for the current catkin testing setup to work.

~K4AExposureCalibration();

/**
* @brief initializes calibrator with a provided node handle
* @details Subscribes the node to /rgb/raw/image.
* Advertises the k4a_update_exposure service and the k4a_auto_tune_exposure service.
* @param[in] nh ROS node handle
*/
K4AExposureCalibration(ros::NodeHandle& nh);
ShannonPlusOne marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief call k4a_nodelet_manager/set_parameters to update exposure value
* @param[in] req_exposure new exposure
* @param[out] error_code error code included in response
* @param[out] res_msg human-readable error message included in response
* @return true if exposure is successfully updated
*/
bool k4aUpdateExposure(int req_exposure, int& error_code, std::string& res_msg);
ShannonPlusOne marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief auto tune exposure with given target blue value
* @param[in] target_blue_value requested blue value to tune exposure to
* @param[out] final_exposure exposure camera is set to after call
* @param[out] error_code error code included in response
* @param[out] res_msg human-readable error message included in response
* @return true if auto tuning exposure is successfully completed
*/
bool k4aAutoTuneExposure(int target_blue_value, int& final_exposure, int& error_code, std::string& res_msg);
ShannonPlusOne marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief check if dynamic_reconfigure response has correctly updated exposure
* @param[in] requested_exposure exposure originally requested in k4aUpdateExposure
* @param[out] updated_exposure exposure that was returned by the dynamic_reconfigure call
* @param[out] error_code error code included in response
* @param[out] res_msg human-readable error message included in response
* @return true if requested_exposure == updated_exposure
*/
bool k4aCameraExposureUpdateCheck(int requested_exposure, int updated_exposure, int& error_code, std::string& res_msg);
ShannonPlusOne marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief check if requested_exposure is in appropriate bounds
* @param[in] requested_exposure exposure originally requested in k4aUpdateExposure
* @param[out] updated_exposure exposure that was returned by the dynamic_reconfigure call
ShannonPlusOne marked this conversation as resolved.
Show resolved Hide resolved
* @param[out] error_code error code included in response
* @param[out] res_msg human-readable error message included in response
* @return true if requested_exposure == updated_exposure
*/
bool k4aCameraExposureBoundsCheck(int requested_exposure, int& error_code, std::string& res_msg);
ShannonPlusOne marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief check if target_blue_value has been achieved
* @details When conducting the auto tune loop, this method compares the average blue
* value of the image at a particular exposure to the desired target average
* blue value provided by the user in k4aAutoTuneExposure
* @param[in] target_blue_val target blue value originally requested in k4aAutoTuneExposure
* @param[in] current_average_blue_value the average blue value of the image at a point in time
* @param[out] error_code error code included in response
* @param[out] res_msg human-readable error message included in response
*/
bool k4aTargetBlueCheck(int target_blue_val, int current_avg_blue_value, int& error_code, std::string& res_msg);

/**
* @brief check if target_blue_value is in appropriate range
* @param[in] target_blue_value target blue value originally requested in k4aAutoTuneExposure
* @param[out] error_code error code included in response
* @param[out] res_msg human-readable error message included in response
*/
bool k4aBlueBoundsCheck(int target_blue_value, int& error_code, std::string& res_msg);

/**
* @brief did the node receive an image at all?
* @param[in] mat current OpenCV mat stored in latest_k4a_image for k4aAutoTuneExposure loop
* @param[out] error_code error code included in response
* @param[out] res_msg human-readable error message included in response
*/
bool k4aImagePopulatedCheck(cv::Mat& mat, int& error_code, std::string& res_msg);

private:
/**
* @brief callback for /rgb/raw/image subscription
* @details This callback handles updating the current image for the node.
* It converts the ROS image message to an OpenCV mat for auto tuning calculations.
* @param[out] msg message received from image transport subscriber subscribed to /rgb/raw/image
ShannonPlusOne marked this conversation as resolved.
Show resolved Hide resolved
*/
void rgbRawImageCallback(const sensor_msgs::ImageConstPtr& msg);

/**
* @brief callback for k4aUpdateExposure
* @details This callback handles requests to update the camera exposure from the
* k4a_update_exposure service.
* @param[in] req request received from calling k4a_update_exposure
* @param[out] res response sent from k4a_update_exposure
*/
bool k4aUpdateExposureCallback(azure_kinect_ros_driver::k4a_update_exposure::Request &req,
azure_kinect_ros_driver::k4a_update_exposure::Response &res);

/**
* @brief callback for k4aAutoTuneExposure
* @details This callback handles requests to update the camera exposure from the
* k4a_auto_tune_exposure service.
* @param[in] req request received from calling k4a_auto_tune_exposure
* @param[out] res response sent from k4a_auto_tune_exposure
*/
bool k4aAutoTuneExposureCallback(azure_kinect_ros_driver::k4a_auto_tune_exposure::Request &req,
azure_kinect_ros_driver::k4a_auto_tune_exposure::Response &res);

// private members
ros::NodeHandle nh_;
image_transport::Subscriber subRGBRaw;
ShannonPlusOne marked this conversation as resolved.
Show resolved Hide resolved
ros::ServiceServer update_exposure_service;
ros::ServiceServer auto_tune_exposure_service;

// allocate memory space to store latest image
cv::Mat latest_k4a_image; /** @brief latest image*/
cv::Mat* const latest_k4a_image_ptr = &latest_k4a_image; /** @brief pointer to latest image*/
ShannonPlusOne marked this conversation as resolved.
Show resolved Hide resolved
cv_bridge::CvImageConstPtr k4aCvImagePtr; /** @brief pointer to convert ROS image to OpenCV mat*/
std::mutex latest_k4a_image_mutex; /** @brief mutex to protect latest image*/
azure_kinect_ros_driver::k4aCameraExposureServiceErrorCode k4a_error_code; /** @brief error codes*/

// config file info
// TODO: PULL THESE VALUES FROM CONFIG FILE "azure_kinect_ros_driver/AzureKinectParamsConfig.h"
const int MIN_EXPOSURE = 488;
Copy link

Choose a reason for hiding this comment

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

use uint32_t or uint64_t instead of int. Make it unsigned and either 32 bit or 64 bit. Up to you.

const int MAX_EXPOSURE = 1000000;
const int DEFAULT_EXPOSURE = 15625;
const int EXPOSURE_INC = 250;
const int MIN_BLUE = 0;
const int MAX_BLUE = 255;
};
4 changes: 4 additions & 0 deletions launch/plusone.launch
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,8 @@
</include>

</group>

<!-- Start the K4A exposure calibration -->
<node pkg="azure_kinect_ros_driver" type="k4a_exposure_calibration_node" name="k4a_exposure_calibration" output="screen">
</node>
</launch>
17 changes: 17 additions & 0 deletions msg/k4aCameraExposureServiceErrorCode.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Overall successful exposure calibration
int8 SUCCESS = 1

# Failure to call service '/set_parameters'
int8 CAMERA_EXPOSURE_SET_FAILURE = -1

# Failure to receive Image from callback
int8 IMAGE_NOT_RECEIVED_FAILURE = -2

# Requested camera exposure is out of bounds Failure
ShannonPlusOne marked this conversation as resolved.
Show resolved Hide resolved
int8 REQUESTED_CAMERA_EXPOSURE_OUT_OF_BOUNDS_FAILURE = -3

# Requested camera blue value is out of bounds Failure
int8 REQUESTED_CAMERA_BLUE_VALUE_OUT_OF_BOUNDS_FAILURE = -4

# Requested camera blue value hasn't been achieved yet
int8 REQUESTED_CAMERA_BLUE_VALUE_NOT_MET = -5
6 changes: 6 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<!-- <url type="website">http://wiki.ros.org/azure_kinect_ros_driver</url> -->

<buildtool_depend>catkin</buildtool_depend>
<build_depend>message_generation</build_depend>

<depend>roscpp</depend>
<depend>std_msgs</depend>
Expand All @@ -32,6 +33,11 @@
<depend>dynamic_reconfigure</depend>

<exec_depend>rgbd_launch</exec_depend>
<exec_depend>message_runtime</exec_depend>

<test_depend>gtest</test_depend>
<test_depend>image_transport</test_depend>
<test_depend>cv_bridge</test_depend>

<export>
<nodelet plugin="${prefix}/nodelet_plugins.xml" />
Expand Down
Loading