diff --git a/ros/angel_utils/nodes/simple_2d_detection_overlay.cxx b/ros/angel_utils/nodes/simple_2d_detection_overlay.cxx index 299836f04..bf480257b 100644 --- a/ros/angel_utils/nodes/simple_2d_detection_overlay.cxx +++ b/ros/angel_utils/nodes/simple_2d_detection_overlay.cxx @@ -1,10 +1,10 @@ #include #include #include -#include -#include #include +#include #include +#include // ROS2 things #include @@ -20,8 +20,8 @@ #include // Our stuff -#include #include +#include #include using angel_msgs::msg::ObjectDetection2dSet; @@ -37,7 +37,7 @@ namespace { // ---------------------------------------------------------------------------- #define DEFINE_PARAM_NAME( var_name, param_name_str ) \ - static constexpr char const* var_name = param_name_str + static constexpr char const* var_name = param_name_str // Topic we expect to receive headset RGB images from. DEFINE_PARAM_NAME( PARAM_TOPIC_INPUT_IMAGES, "topic_input_images" ); @@ -64,26 +64,26 @@ static constexpr size_t const TENe9 = 1000000000; static constexpr double const LINE_FACTOR = 0.0015; // Max length of the bounding box label displayed before wrapping the tezt static constexpr int const MAX_LINE_LEN = 15; -// Map indicating joint->joint connecting lines -static std::map> JOINT_CONNECTION_LINES = { // mapping of joint line connections - {"nose", {"mouth"}}, - {"mouth", {"throat"}}, - {"throat", {"chest", "left_upper_arm", "right_upper_arm"}}, - {"chest", {"back"}}, - {"left_upper_arm", {"left_lower_arm"}}, - {"left_lower_arm", {"left_wrist"}}, - {"left_wrist", {"left_hand"}}, - {"right_upper_arm", {"right_lower_arm"}}, - {"right_lower_arm", {"right_wrist"}}, - {"right_wrist", {"right_hand"}}, - {"back", {"left_upper_leg", "right_upper_leg"}}, - {"left_upper_leg", {"left_knee"}}, - {"left_knee", {"left_lower_leg"}}, - {"left_lower_leg", {"left_foot"}}, - {"right_upper_leg", {"right_knee"}}, - {"right_knee", {"right_lower_leg"}}, - {"right_lower_leg", {"right_foot"}} - }; +// Map indicating joint->joint connecting lines for drawing the pose on an +// image. +static std::map< std::string, std::vector< std::string > > JOINT_CONNECTION_LINES = { + { "nose", { "mouth" } }, + { "mouth", { "throat" } }, + { "throat", { "chest", "left_upper_arm", "right_upper_arm" } }, + { "chest", { "back" } }, + { "left_upper_arm", { "left_lower_arm" } }, + { "left_lower_arm", { "left_wrist" } }, + { "left_wrist", { "left_hand" } }, + { "right_upper_arm", { "right_lower_arm" } }, + { "right_lower_arm", { "right_wrist" } }, + { "right_wrist", { "right_hand" } }, + { "back", { "left_upper_leg", "right_upper_leg" } }, + { "left_upper_leg", { "left_knee" } }, + { "left_knee", { "left_lower_leg" } }, + { "left_lower_leg", { "left_foot" } }, + { "right_upper_leg", { "right_knee" } }, + { "right_knee", { "right_lower_leg" } }, + { "right_lower_leg", { "right_foot" } } }; /// Convert a header instance into a single-value time component to be used as /// and order-able key. @@ -213,8 +213,7 @@ ::Simple2dDetectionOverlay( rclcpp::NodeOptions const& options ) std::shared_ptr< Simple2dDetectionOverlay > node_handle = { this, - []( auto * ){} - }; + []( auto* ){} }; // Empty deleter to prevent double deletion of this class when this goes // out of scope @@ -319,7 +318,7 @@ ::collect_detections( ObjectDetection2dSet::SharedPtr const det_set ) auto log = this->get_logger(); // Lock - std::lock_guard guard(m_draw_lock); + std::lock_guard< std::mutex > guard( m_draw_lock ); // lookup image for det_set->source_stamp // check that detection header frame_id matches @@ -407,7 +406,7 @@ ::collect_detections( ObjectDetection2dSet::SharedPtr const det_set ) /// Number of detections to draw. size_t draw_n = max_conf_vec.size(); /// Indices of the detections to draw. - std::vector< size_t > draw_indices(max_conf_vec.size()); + std::vector< size_t > draw_indices( max_conf_vec.size() ); std::iota( draw_indices.begin(), draw_indices.end(), 0 ); // Find top k results @@ -419,11 +418,10 @@ ::collect_detections( ObjectDetection2dSet::SharedPtr const det_set ) RCLCPP_DEBUG( log, "Top k: %d", filter_top_k ); // Arg-sort the top-k highest confidence detections. - draw_n = std::min( max_conf_vec.size(), (size_t)filter_top_k ); + draw_n = std::min( max_conf_vec.size(), (size_t) filter_top_k ); std::partial_sort( draw_indices.begin(), draw_indices.begin() + draw_n, draw_indices.end(), - [&]( size_t A, size_t B ) - { - return max_conf_vec[A] > max_conf_vec[B]; + [ & ]( size_t A, size_t B ){ + return max_conf_vec[ A ] > max_conf_vec[ B ]; } ); } @@ -431,7 +429,8 @@ ::collect_detections( ObjectDetection2dSet::SharedPtr const det_set ) size_t idx; for( size_t i = 0; i < draw_n; ++i ) { - idx = draw_indices.at(i); + idx = draw_indices.at( i ); + cv::Point pt_ul = { (int) round( det_set->left[ idx ] ), (int) round( det_set->top[ idx ] ) }, pt_br = { (int) round( det_set->right[ idx ] ), @@ -441,19 +440,18 @@ ::collect_detections( ObjectDetection2dSet::SharedPtr const det_set ) std::string line = max_label_vec[ idx ]; int line_len = line.length(); - for (int i=0; iimage, split_line, line_loc, cv::FONT_HERSHEY_COMPLEX, line_thickness, COLOR_TEXT, line_thickness ); } - } - if(insert) + if( insert ) { // Insert this frame into our drawing history. m_drawn_frame_map.insert( { source_nanosec_key, img_ptr } ); @@ -467,7 +465,8 @@ ::collect_detections( ObjectDetection2dSet::SharedPtr const det_set ) m_drawn_frame_map.erase( m_drawn_frame_map.begin() ); } } - else{ + else + { // Frame was already drawn on by the other message, time to publish auto out_img_msg = img_ptr->toImageMsg(); m_pub_overlay_image->publish( *out_img_msg ); @@ -488,7 +487,7 @@ ::collect_joints( HandJointPosesUpdate::SharedPtr const joints_msg ) auto log = this->get_logger(); // Lock - std::lock_guard guard(m_draw_lock); + std::lock_guard< std::mutex > guard( m_draw_lock ); // lookup image for joints_msg->source_stamp // check that detection header frame_id matches @@ -525,7 +524,7 @@ ::collect_joints( HandJointPosesUpdate::SharedPtr const joints_msg ) } // Only plot the patient skeleton - if(joints_msg->hand != "patient") + if( joints_msg->hand != "patient" ) { RCLCPP_WARN( log, @@ -552,9 +551,9 @@ ::collect_joints( HandJointPosesUpdate::SharedPtr const joints_msg ) img_ptr = find_drawn_it->second; } - std::map> joint_positions = {}; - - static auto const COLOR_PT = cv::Scalar{ 0, 255, 0 }; + std::map< std::string, std::vector< double > > joint_positions = {}; + + static auto const COLOR_PT = cv::Scalar{ 0, 255, 0 }; int line_thickness = thickness_for_drawing( img_ptr->image ); RCLCPP_DEBUG( log, "Using line thickness: %d", line_thickness ); @@ -563,13 +562,13 @@ ::collect_joints( HandJointPosesUpdate::SharedPtr const joints_msg ) { double x = joint.pose.position.x; double y = joint.pose.position.y; - joint_positions[joint.joint] = {x, y}; // save for later + joint_positions[ joint.joint ] = { x, y }; // save for later // Plot the point cv::Point pt = { (int) round( x ), (int) round( y ) }; - cv::circle( img_ptr->image, pt, line_thickness*3, - COLOR_PT, cv::FILLED); + cv::circle( img_ptr->image, pt, line_thickness * 3, + COLOR_PT, cv::FILLED ); } // Draw the joint connections @@ -578,26 +577,24 @@ ::collect_joints( HandJointPosesUpdate::SharedPtr const joints_msg ) for(auto const& connection : JOINT_CONNECTION_LINES) { std::string joint_name = connection.first; - std::vector joint_connections = connection.second; - std::vector first_joint = joint_positions[joint_name]; - pt1 = { - (int) round( first_joint[0] ), - (int) round( first_joint[1] ) - }; + std::vector< std::string > joint_connections = connection.second; + std::vector< double > first_joint = joint_positions[ joint_name ]; + pt1 = { + (int) round( first_joint[ 0 ] ), + (int) round( first_joint[ 1 ] ) }; for(auto const& connecting_joint : joint_connections) { - std::vector connecting_pt = joint_positions[connecting_joint]; - pt2 = { - (int) round( connecting_pt[0] ), - (int) round( connecting_pt[1] ) - }; + std::vector< double > connecting_pt = joint_positions[ connecting_joint ]; + pt2 = { + (int) round( connecting_pt[ 0 ] ), + (int) round( connecting_pt[ 1 ] ) }; - cv::line(img_ptr->image, pt1, pt2, COLOR_PT, line_thickness, cv::LINE_8); + cv::line( img_ptr->image, pt1, pt2, COLOR_PT, line_thickness, cv::LINE_8 ); } } - if(insert) + if( insert ) { // Insert this frame into our drawing history. m_drawn_frame_map.insert( { source_nanosec_key, img_ptr } ); @@ -611,7 +608,8 @@ ::collect_joints( HandJointPosesUpdate::SharedPtr const joints_msg ) m_drawn_frame_map.erase( m_drawn_frame_map.begin() ); } } - else{ + else + { // Frame was already drawn on by the other message, time to publish auto out_img_msg = img_ptr->toImageMsg(); m_pub_overlay_image->publish( *out_img_msg ); diff --git a/uncrustify.cfg b/uncrustify.cfg index 1151dd001..b5111891c 100644 --- a/uncrustify.cfg +++ b/uncrustify.cfg @@ -1,4 +1,4 @@ -# Uncrustify-0.76.0 +# Uncrustify-0.78.1 # # General options @@ -99,6 +99,12 @@ sp_cpp_lambda_square_paren = remove # ignore/add/remove/force/not_defined # no argument list is present, as in '[] { ... }'. sp_cpp_lambda_square_brace = remove # ignore/add/remove/force/not_defined +# Add or remove space after the opening parenthesis and before the closing +# parenthesis of a argument list of a C++11 lambda, as in +# '[]( ){ ... }' +# with an empty list. +sp_cpp_lambda_argument_list_empty = ignore # ignore/add/remove/force/not_defined + # Add or remove space after the opening parenthesis and before the closing # parenthesis of a argument list of a C++11 lambda, as in # '[]( int x ){ ... }'. @@ -195,9 +201,36 @@ sp_before_ptr_star = remove # ignore/add/remove/force/not_defined # variable name. If set to ignore, sp_before_ptr_star is used instead. sp_before_unnamed_ptr_star = ignore # ignore/add/remove/force/not_defined +# Add or remove space before pointer star '*' that is followed by a qualifier. +# If set to ignore, sp_before_unnamed_ptr_star is used instead. +sp_before_qualifier_ptr_star = ignore # ignore/add/remove/force/not_defined + +# Add or remove space before pointer star '*' that is followed by 'operator' keyword. +# If set to ignore, sp_before_unnamed_ptr_star is used instead. +sp_before_operator_ptr_star = ignore # ignore/add/remove/force/not_defined + +# Add or remove space before pointer star '*' that is followed by +# a class scope (as in 'int *MyClass::method()') or namespace scope +# (as in 'int *my_ns::func()'). +# If set to ignore, sp_before_unnamed_ptr_star is used instead. +sp_before_scope_ptr_star = ignore # ignore/add/remove/force/not_defined + +# Add or remove space before pointer star '*' that is followed by '::', +# as in 'int *::func()'. +# If set to ignore, sp_before_unnamed_ptr_star is used instead. +sp_before_global_scope_ptr_star = ignore # ignore/add/remove/force/not_defined + +# Add or remove space between a qualifier and a pointer star '*' that isn't +# followed by a variable name, as in '(char const *)'. If set to ignore, +# sp_before_ptr_star is used instead. +sp_qualifier_unnamed_ptr_star = ignore # ignore/add/remove/force/not_defined + # Add or remove space between pointer stars '*', as in 'int ***a;'. sp_between_ptr_star = remove # ignore/add/remove/force/not_defined +# Add or remove space between pointer star '*' and reference '&', as in 'int *& a;'. +sp_between_ptr_ref = ignore # ignore/add/remove/force/not_defined + # Add or remove space after pointer star '*', if followed by a word. # # Overrides sp_type_func. @@ -232,13 +265,24 @@ sp_ptr_star_func_type = ignore # ignore/add/remove/force/not_defined sp_ptr_star_paren = add # ignore/add/remove/force/not_defined # Add or remove space before a pointer star '*', if followed by a function -# prototype or function definition. +# prototype or function definition. If set to ignore, sp_before_ptr_star is +# used instead. sp_before_ptr_star_func = remove # ignore/add/remove/force/not_defined +# Add or remove space between a qualifier and a pointer star '*' followed by +# the name of the function in a function prototype or definition, as in +# 'char const *foo()`. If set to ignore, sp_before_ptr_star is used instead. +sp_qualifier_ptr_star_func = ignore # ignore/add/remove/force/not_defined + # Add or remove space before a pointer star '*' in the trailing return of a # function prototype or function definition. sp_before_ptr_star_trailing = ignore # ignore/add/remove/force/not_defined +# Add or remove space between a qualifier and a pointer star '*' in the +# trailing return of a function prototype or function definition, as in +# 'auto foo() -> char const *'. +sp_qualifier_ptr_star_trailing = ignore # ignore/add/remove/force/not_defined + # Add or remove space before a reference sign '&'. sp_before_byref = remove # ignore/add/remove/force/not_defined @@ -297,6 +341,7 @@ sp_before_angle = remove # ignore/add/remove/force/not_defined sp_inside_angle = add # ignore/add/remove/force/not_defined # Add or remove space inside '<>'. +# if empty. sp_inside_angle_empty = remove # ignore/add/remove/force/not_defined # Add or remove space between '>' and ':'. @@ -433,6 +478,7 @@ sp_cpp_before_struct_binding = add # ignore/add/remove/force/not_defined sp_inside_square = add # ignore/add/remove/force/not_defined # Add or remove space inside '[]'. +# if empty. sp_inside_square_empty = ignore # ignore/add/remove/force/not_defined # (OC) Add or remove space inside a non-empty Objective-C boxed array '@[' and @@ -591,6 +637,7 @@ sp_inside_type_brace_init_lst = add # ignore/add/remove/force/not_defined sp_inside_braces = add # ignore/add/remove/force/not_defined # Add or remove space inside '{}'. +# if empty. sp_inside_braces_empty = remove # ignore/add/remove/force/not_defined # Add or remove space around trailing return operator '->'. @@ -608,7 +655,7 @@ sp_type_brace_init_lst = remove # ignore/add/remove/force/not_defined sp_func_proto_paren = remove # ignore/add/remove/force/not_defined # Add or remove space between function name and '()' on function declaration -# without parameters. +# if empty. sp_func_proto_paren_empty = remove # ignore/add/remove/force/not_defined # Add or remove space between function name and '(' with a typedef specifier. @@ -618,7 +665,7 @@ sp_func_type_paren = ignore # ignore/add/remove/force/not_defined sp_func_def_paren = remove # ignore/add/remove/force/not_defined # Add or remove space between function name and '()' on function definition -# without parameters. +# if empty. sp_func_def_paren_empty = remove # ignore/add/remove/force/not_defined # Add or remove space inside empty function '()'. @@ -628,6 +675,16 @@ sp_inside_fparens = remove # ignore/add/remove/force/not_defined # Add or remove space inside function '(' and ')'. sp_inside_fparen = add # ignore/add/remove/force/not_defined +# Add or remove space inside user functor '(' and ')'. +sp_func_call_user_inside_rparen = ignore # ignore/add/remove/force/not_defined + +# Add or remove space inside empty functor '()'. +# Overrides sp_after_angle unless use_sp_after_angle_always is set to true. +sp_inside_rparens = ignore # ignore/add/remove/force/not_defined + +# Add or remove space inside functor '(' and ')'. +sp_inside_rparen = ignore # ignore/add/remove/force/not_defined + # Add or remove space inside the first parentheses in a function type, as in # 'void (*x)(...)'. sp_inside_tparen = add # ignore/add/remove/force/not_defined @@ -967,6 +1024,14 @@ sp_extern_paren = ignore # ignore/add/remove/force/not_defined # Add or remove space after the opening of a C++ comment, as in '// A'. sp_cmt_cpp_start = add # ignore/add/remove/force/not_defined +# remove space after the '//' and the pvs command '-V1234', +# only works with sp_cmt_cpp_start set to add or force. +sp_cmt_cpp_pvs = false # true/false + +# remove space after the '//' and the command 'lint', +# only works with sp_cmt_cpp_start set to add or force. +sp_cmt_cpp_lint = false # true/false + # Add or remove space in a C++ region marker comment, as in '// BEGIN'. # A region marker is defined as a comment which is not preceded by other text # (i.e. the comment is the first non-whitespace on the line), and which starts @@ -1049,6 +1114,12 @@ sp_after_noexcept = remove # ignore/add/remove/force/not_defined # Add or remove space after '_'. sp_vala_after_translation = ignore # ignore/add/remove/force/not_defined +# Add or remove space before a bit colon ':'. +sp_before_bit_colon = ignore # ignore/add/remove/force/not_defined + +# Add or remove space after a bit colon ':'. +sp_after_bit_colon = ignore # ignore/add/remove/force/not_defined + # If true, a is inserted after #define. force_tab_after_define = false # true/false @@ -2279,8 +2350,21 @@ nl_after_func_class_proto_group = 0 # unsigned number nl_class_leave_one_liner_groups = true # true/false # The number of newlines after '}' of a multi-line function body. +# +# Overrides nl_min_after_func_body and nl_max_after_func_body. nl_after_func_body = 2 # unsigned number +# The minimum number of newlines after '}' of a multi-line function body. +# +# Only works when nl_after_func_body is 0. +nl_min_after_func_body = 0 # unsigned number + +# The maximum number of newlines after '}' of a multi-line function body. +# +# Only works when nl_after_func_body is 0. +# Takes precedence over nl_min_after_func_body. +nl_max_after_func_body = 0 # unsigned number + # The number of newlines after '}' of a multi-line function body in a class # declaration. Also affects class constructors/destructors. # @@ -2784,6 +2868,13 @@ align_right_cmt_at_col = 0 # unsigned number # 0: Don't align (default). align_func_proto_span = 0 # unsigned number +# Whether to ignore continuation lines when evaluating the number of +# new lines for the function prototype alignment's span. +# +# false: continuation lines are part of the newlines count +# true: continuation lines are not counted +align_func_proto_span_ignore_cont_lines = false # true/false + # How to consider (or treat) the '*' in the alignment of function prototypes. # # 0: Part of the type 'void * foo();' (default) @@ -2833,9 +2924,22 @@ align_single_line_brace_gap = 0 # unsigned number # 0: Don't align (default). align_oc_msg_spec_span = 0 # unsigned number -# Whether to align macros wrapped with a backslash and a newline. This will -# not work right if the macro contains a multi-line comment. -align_nl_cont = false # true/false +# Whether and how to align backslashes that split a macro onto multiple lines. +# This will not work right if the macro contains a multi-line comment. +# +# 0: Do nothing (default) +# 1: Align the backslashes in the column at the end of the longest line +# 2: Align with the backslash that is farthest to the left, or, if that +# backslash is farther left than the end of the longest line, at the end of +# the longest line +# 3: Align with the backslash that is farthest to the right +align_nl_cont = 0 # unsigned number + +# The minimum number of spaces between the end of a line and its continuation +# backslash. Requires align_nl_cont. +# +# Default: 1 +align_nl_cont_spaces = 1 # unsigned number # Whether to align macro functions and variables together. align_pp_define_together = false # true/false @@ -3146,6 +3250,12 @@ mod_remove_extra_semicolon = true # true/false # Whether to remove duplicate include. mod_remove_duplicate_include = false # true/false +# the following options (mod_XX_closebrace_comment) use different comment, +# depending of the setting of the next option. +# false: Use the c comment (default) +# true : Use the cpp comment +mod_add_force_c_closebrace_comment = false # true/false + # If a function body exceeds the specified number of newlines and doesn't have # a comment after the close brace, a comment will be added. mod_add_long_function_closebrace_comment = 0 # unsigned number @@ -3534,6 +3644,11 @@ debug_sort_the_tracks = true # true/false # only if the -p option is set. debug_decode_the_flags = false # true/false +# use (or not) the exit(EX_SOFTWARE) function. +# +# Default: true +debug_use_the_exit_function_pop = true # true/false + # insert the number of the line at the beginning of each line set_numbering_for_html_output = false # true/false @@ -3593,5 +3708,5 @@ set FUNC_WRAP TEST set FUNC_WRAP TEST_F set FUNC_WRAP TEST_P set FUNC_WRAP TYPED_TEST -# option(s) with 'not default' value: 274 +# option(s) with 'not default' value: 277 #