Preview points in Lateral Controller
The following lines (485-489) in lat_controller.cc appear incorrect:
const auto preview_point =
trajectory_analyzer_.QueryNearestPointByRelativeTime(preview_time);
const auto matched_point = trajectory_analyzer_.QueryNearestPointByPosition(
preview_point.path_point().x(), preview_point.path_point().y());
This will result in preview_point == matched_point, as QueryNearestPointByPosition() will return preview_point as the nearest point.
Surely this is incorrect? Maybe the correct approach is to calculate the lateral deviation from our current position relative to preview_point?
Is there any update on this? I was attempting to enable the LQR lateral controller's preview_window, and it didn't appear to be having any effect. (I am trying to get the vehicle to take a low-speed right-hand turn at an intersection, but it is consistently clipping the corner.) Should the MPC controller be used instead?
[Edit]
To be even more specific, is the computation of const double dx = preview_point.path_point().x() - matched_point.path_point().x(); correct? (The same concern holds for dy.)
It does seem like these computations will result in dx=0 and dy=0, which will then cause preview_d_error to then also be 0 for all elements in the preview window. Which when multiplied by a Q matrix will cause the preview to have no affect.
I'm curious if maybe preview_point.path_point().x() should be com.x() instead. Is there a reference from which we could double check this logic?
At line 503 I added:
AINFO << " dx: " << dx << "," << " dy: " << dy << ","
<< " preview_d_error: " << preview_d_error;
I then changed the configuration file to have preview_window: 1 and added a fifth entry matrix_q: 0.025 to get the mentioned portion of the code to run. Now in the control.INFO log I get:
I0227 14:31:34.771937 19453 lat_controller.cc:503] dx: 0, dy: 0, preview_d_error: 0
which shows up repeatedly confirming the values are identical to zero. (Which I assume is incorrect.)
I increased the preview_window: 2 and added a sixth entry matrix_q: 0.025 and get as expected two repeated messages confirming values identical to zero.
I0227 14:39:24.858026 28752 lat_controller.cc:503] dx: 0, dy: 0, preview_d_error: 0
I0227 14:39:24.858039 28752 lat_controller.cc:503] dx: 0, dy: 0, preview_d_error: 0
I found the same problem here, it doesn't make sense to QueryNearestPointByPosition for a trajectory point. Any update on this?
Closed due to inactivity. If the problem persists, pls feel free to reopen it or create a new one and refer to it.