Repository navigation
feat(autoware_mpc_lateral_controller): take the logger and the clock out of the control - #13451
Conversation
|
Thank you for contributing to the Autoware project! 🚧 If your pull request is in progress, switch it to draft mode. Please ensure:
|
…g can reach MPC::setReferenceTrajectory checks the size of the smoothed trajectory right after it pushed a point onto it, so the size is never zero. calcNearestPoseInterp checks the converted trajectory for points after it already returned on an empty input, and the conversion writes one point per input element. Signed-off-by: Kazuki Komiya <290287332+kazkomiya@users.noreply.github.com>
…nd the solver time as diagnostics The two DEBUG lines named "(before lpf)" and "(after lpf)" both printed the value after the filter, because the filter had already overwritten the variable. The value before the filter was never reachable. The solver time was a DEBUG line as well, so reading it needed the log. The five values now go to ~/output/lateral_diagnostic, which lengthens the array from 27 to 32 entries. Entries [0] to [26] keep their meaning. The four error derivatives are written only by the dynamics vehicle model, as the removed lines were, so the other models leave them at zero. Signed-off-by: Kazuki Komiya <290287332+kazkomiya@users.noreply.github.com>
…njected interface MPC wrote to a logger of its own, which needed rclcpp to be initialised before the control could run. It now writes through LogWriter, an interface with no ROS type in it. RosLogWriter is the one implementation that writes to a logger, and the node builds it, so only the node layer reaches rclcpp for the log. log_writer.hpp and ros_log_writer.hpp hold nothing that belongs to this package apart from their namespace and the AW_MPC_ prefix of the macros, so another package can take them as they are. The macros build the message only when it would be read, in the way the logging macros of rclcpp do. Write them in a source file: the waiting time of a throttled line lives in a static of the line that writes it, and a static inside a function defined in a header is shared between shared libraries. Signed-off-by: Kazuki Komiya <290287332+kazkomiya@users.noreply.github.com>
MPC and SteeringPredictor receive the time of the control cycle as an argument and no longer hold a clock. The caller already passed the same time as the stamp of every message the cycle produces, so the computation now reads the instant the cycle started instead of an instant a few microseconds later. Signed-off-by: Kazuki Komiya <290287332+kazkomiya@users.noreply.github.com>
a49be15 to
411cf91
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #13451 +/- ##
==========================================
- Coverage 37.56% 37.44% -0.12%
==========================================
Files 2025 2033 +8
Lines 141946 142080 +134
==========================================
- Hits 53319 53199 -120
- Misses 88627 88881 +254
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
interimadd
left a comment
There was a problem hiding this comment.
Thanks for PR. I have approved with minor comment.
a6b950b to
4396e47
Compare
Signed-off-by: Kazuki Komiya <290287332+kazkomiya@users.noreply.github.com>
4396e47 to
5864547
Compare
| return true; | ||
| } | ||
|
|
||
| void RosLogWriter::write(const Level level, const std::string_view line) const |
There was a problem hiding this comment.
The rclcpp logger can record the calling function and line number along with the message string, but I believe that with RosLogWriter, all of these will end up pointing to the write function. Could you fix this if possible?
… log comes from The writer received only the level and the text, so RCUTILS_CONSOLE_OUTPUT_FORMAT reported ros_log_writer.cpp for every line. The macros now fill a Site with the function, the file and the line of the caller, and RosLogWriter passes it to rcutils_log. Signed-off-by: Kazuki Komiya <290287332+kazkomiya@users.noreply.github.com>
…out of the control (autowarefoundation#13451) feat(autoware_mpc_lateral_controller): take the logger and the clock out of the control (autowarefoundation#13451) MPC and the classes it uses no longer hold a logger or a clock of ROS, so they can run and be tested without rclcpp::init(). They write the log through an injected LogWriter and take the time of the control cycle as an argument. All log lines go to the child logger of the node and reach /rosout. ~/output/lateral_diagnostic grows from 27 to 32 entries: the error derivatives and the solver time, which only DEBUG lines printed before. Signed-off-by: Kazuki Komiya <290287332+kazkomiya@users.noreply.github.com>
…out of the control (autowarefoundation#13451) feat(autoware_mpc_lateral_controller): take the logger and the clock out of the control (autowarefoundation#13451) MPC and the classes it uses no longer hold a logger or a clock of ROS, so they can run and be tested without rclcpp::init(). They write the log through an injected LogWriter and take the time of the control cycle as an argument. All log lines go to the child logger of the node and reach /rosout. ~/output/lateral_diagnostic grows from 27 to 32 entries: the error derivatives and the solver time, which only DEBUG lines printed before. Signed-off-by: Kazuki Komiya <290287332+kazkomiya@users.noreply.github.com>
Description
The aim of this series is to let the lateral controller run and be tested without a node, so that
it can later move to a package of its own.
MPCand the classes it uses hold a logger and aclock of their own, which means
rclcpp::init()has to run first.This PR removes those two dependencies: the package writes logs via a ROS-independent interface, and it takes
the time of the cycle as an argument.
commit1: remove two branches nothing can reach
commit2: publish the error derivatives and the solver time as diagnostics
Two commits above are trying to reduce redundant log messages.
commit3: write the log through an injected interface
LogWriteris the interface,NullLogWriterdrops everything, andRosLogWriterwrites to alogger of ROS.
A plain interface would have been enough without throttling. The waiting time of a throttled
line has to live per place in the code, as
RCLCPP_*_THROTTLEkeeps it, and a function cannothold that state unless every caller passes it. That is why the
AW_MPC_*macros exist. Since amacro was needed anyway, they cover the five severities of ROS, so that the logic can keep them
after it moves out of this package. Apart from their namespace and the
AW_MPC_prefix, thetwo headers hold nothing that belongs to this package.
commit4: take the ROS clock out of MPC
MPCandSteeringPredictorreceive the time of the cycle as an argument. The caller alreadypassed the same time as the stamp of every message the cycle produces.
test_steering_predictor.cppis new: the clock the classheld made a test impossible to write before.
Behaviour that changes
The diagnostic array grows from 27 to 32 entries. [0] to [26] keep their meaning. The four
error derivatives are written only by the
dynamicsvehicle model, as the removed DEBUG lineswere. The README lists the new entries.
Five logger names become one. The four names below built with
rclcpp::get_logger()werenever registered with
rosout, so their lines reached the terminal but not/rosout, and~/config_loggercould not set their level.This PR sends every line to the child logger of the node, which/rosoutpublishes and~/config_loggercan set.<node>.lateral_controllermpc_loggermpc_steer_predictormpc_utilsmpc_utilThe steering prediction reads a different clock under simulated time.
SteeringPredictorholds a clock no time source feeds, so it reads the wall clock even with
use_sim_timeset.It takes the stamp the node passes instead.
Three DEBUG lines and two ERROR lines are gone, as commit1 and commit2 describe.
Interface changes
DynamicsBicycleModeltakes aconst LogWriter &in its constructor, andMPCUtils::calcTrajectoryYawFromXYtakes one as its first argument.MPC::setLoggerandMPC::setClockgive way toMPC::setLogWriter.MPC::calculateMPCandSteeringPredictor::calcSteerPredictiontake the time of the cycle. No caller of any of theseoutside this package was found in this repository.
Related links
How was this PR tested?
process is properly launched by
The node comes up with the fifteen topics it had before,
/diagnosticscarriescontroller: MPC_solve_checker, andros2 component loadreaches the constructor through theclass loader. With the five inputs published,
~/output/lateral_diagnosticcarries 32 entriesand the warning of the solver appears once per second under the logger name
controller.lateral_controller. Setting that logger toDEBUGthrough~/config_loggermakesthe DEBUG lines of MPC appear and setting it back to
INFOstops them.unit test
Evaluator (TIER IV internal)
Because Evaluator cannot be executed momentarily for some technical issues, I tried to locally execute scenario tests to be fulfilled, but failed due to administration to some datasets.
We agreed with the reviewers that evaluator shall be done after the logic is extracted in later PR and then this PR can be open and merged.
->
Confirmed success in the test scnearios below in evaluator
https://evaluation.ci.tier4.jp/evaluation/reports/de0e7bd1-50c9-5ade-8ce7-665e5d5d994d?project_id=autoware_dev
https://evaluation.ci.tier4.jp/evaluation/reports/e6be184a-a794-58e3-96bb-6dd0404a63e3?project_id=autoware_dev
https://evaluation.ci.tier4.jp/evaluation/reports/92aa3150-a3df-5bcd-89f8-53791537b57e?project_id=autoware_dev