Skip to content

Commit

Permalink
fix member variable type and error logs
Browse files Browse the repository at this point in the history
Signed-off-by: ismetatabay <[email protected]>
  • Loading branch information
ismetatabay committed Aug 2, 2024
1 parent 6dce598 commit 136a5ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class TrtYoloXNode : public rclcpp::Node
bool is_roi_overlap_segment_;
bool is_publish_color_mask_;
float overlap_roi_score_threshold_;
int gpu_id_;
uint8_t gpu_id_;
// TODO(badai-nguyen): change to function
std::map<std::string, int> remap_roi_to_semantic_ = {
{"UNKNOWN", 3}, // other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ void TrtYoloXNode::onConnect()
void TrtYoloXNode::onImage(const sensor_msgs::msg::Image::ConstSharedPtr msg)
{
if (!setCudaDeviceId(gpu_id_)) {
RCLCPP_ERROR(this->get_logger(), "GPU %d does not exist or is not suitable.", gpu_id_);
RCLCPP_ERROR_THROTTLE(
get_logger(), *get_clock(), 2000, "GPU %d does not exist or is not suitable.", gpu_id_);
return;
}

Check warning on line 141 in perception/autoware_tensorrt_yolox/src/tensorrt_yolox_node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

TrtYoloXNode::onImage increases in cyclomatic complexity from 10 to 11, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
Expand Down Expand Up @@ -230,7 +231,8 @@ bool TrtYoloXNode::setCudaDeviceId(const int gpu_id)
{
cudaError_t cuda_err = cudaSetDevice(gpu_id);
if (cuda_err != cudaSuccess) {
RCLCPP_ERROR(this->get_logger(), "Failed to set gpu device with id: %d ", gpu_id);
RCLCPP_ERROR_THROTTLE(
get_logger(), *get_clock(), 2000, "Failed to set gpu device with id: %d ", gpu_id);
return false;
} else {
return true;
Expand Down

0 comments on commit 136a5ff

Please sign in to comment.