Skip to content

Commit

Permalink
refactor(osqp_interface, motion_velocity_smoother): unsolved status log
Browse files Browse the repository at this point in the history
Signed-off-by: Takayuki Murooka <[email protected]>
  • Loading branch information
takayuki5168 committed Oct 15, 2022
1 parent 0f16c2b commit b2614d5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "osqp_interface/csc_matrix_conv.hpp"
#include "osqp_interface/visibility_control.hpp"

#include <rclcpp/rclcpp.hpp>

#include <limits>
#include <memory>
#include <string>
Expand Down Expand Up @@ -179,6 +181,8 @@ class OSQP_INTERFACE_PUBLIC OSQPInterface
inline float64_t getObjVal() const { return m_latest_work_info.obj_val; }
/// \brief Returns flag asserting interface condition (Healthy condition: 0).
inline int64_t getExitFlag() const { return m_exitflag; }

void logUnsolvedStatus(const std::string & prefix_message = "") const;
};

} // namespace osqp
Expand Down
20 changes: 20 additions & 0 deletions common/osqp_interface/src/osqp_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,26 @@ OSQPInterface::optimize(
return result;
}

void OSQPInterface::logUnsolvedStatus(const std::string & prefix_message) const
{
const int status = getStatus();
if (status == 1) {
// No need to log since optimziatoin was solved.
return;
}

// create message
std::string output_message = "";
if (prefix_message != "") {
output_message = prefix_message + " ";
}

const auto status_message = getStatusMessage();
output_message += "Optimization failed due to " + status_message;

// log with warning
RCLCPP_WARN(rclcpp::get_logger("osqp_interface"), output_message.c_str());
}
} // namespace osqp
} // namespace common
} // namespace autoware
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,7 @@ bool JerkFilteredSmoother::apply(
output.at(i).acceleration_mps2 = a_stop_decel;
}

const int status_val = std::get<3>(result);
if (status_val != 1) {
RCLCPP_ERROR(logger_, "optimization failed : %s", qp_solver_.getStatusMessage().c_str());
}
qp_solver_.logUnsolvedStatus("[motion_velocity_smoother]");

if (TMP_SHOW_DEBUG_INFO) {
// jerk calculation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,7 @@ bool L2PseudoJerkSmoother::apply(
// v_max[i], optval.at(i + N), optval.at(i), optval.at(i + 2 * N), optval.at(i + 3 * N));
// }

const int status_val = std::get<3>(result);
if (status_val != 1) {
RCLCPP_WARN(logger_, "optimization failed : %s", qp_solver_.getStatusMessage().c_str());
}
qp_solver_.logUnsolvedStatus("[motion_velocity_smoother]");

const auto tf2 = std::chrono::system_clock::now();
const double dt_ms2 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,7 @@ bool LinfPseudoJerkSmoother::apply(
// v_max[i], optval.at(i + N), optval.at(i), optval.at(i + 2 * N), optval.at(i + 3 * N));
// }

const int status_val = std::get<3>(result);
if (status_val != 1) {
RCLCPP_WARN(logger_, "optimization failed : %s", qp_solver_.getStatusMessage().c_str());
}
qp_solver_.logUnsolvedStatus("[motion_velocity_smoother]");

const auto tf2 = std::chrono::system_clock::now();
const double dt_ms2 =
Expand Down

0 comments on commit b2614d5

Please sign in to comment.