Skip to content

Commit

Permalink
chore(motion_velocity_smoother): remove string stream creation
Browse files Browse the repository at this point in the history
Signed-off-by: Fumiya Watanabe <[email protected]>
  • Loading branch information
rej55 committed May 27, 2024
1 parent 9d71cce commit c305ccd
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,14 @@ bool calcStopVelocityWithConstantJerkAccLimit(
}

// for debug
std::stringstream ss;
RCLCPP_DEBUG(rclcpp::get_logger("velocity_planning_utils"), "Calculate stop velocity.");
for (unsigned int i = 0; i < ts.size(); ++i) {
ss << "t: " << ts.at(i) << ", x: " << xs.at(i) << ", v: " << vs.at(i) << ", a: " << as.at(i)
<< ", j: " << js.at(i) << std::endl;
RCLCPP_DEBUG_STREAM(
rclcpp::get_logger("velocity_planning_utils"), "--- "
<< "t: " << ts.at(i) << ", x: " << xs.at(i)
<< ", v: " << vs.at(i) << ", a: " << as.at(i)
<< ", j: " << js.at(i));
}

Check warning on line 209 in planning/motion_velocity_smoother/src/smoother/analytical_jerk_constrained_smoother/velocity_planning_utils.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

calcStopVelocityWithConstantJerkAccLimit already has high cyclomatic complexity, and now it increases in Lines of Code from 93 to 94. 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.
RCLCPP_DEBUG(
rclcpp::get_logger("velocity_planning_utils"), "Calculate stop velocity. %s", ss.str().c_str());

const double a_target = 0.0;
const double v_margin = 0.3;
Expand Down

0 comments on commit c305ccd

Please sign in to comment.