-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(follow_trajectory_action): adapt to work with considering slopes #1226
fix(follow_trajectory_action): adapt to work with considering slopes #1226
Conversation
…lation and BehaviorTree
… pitch consideration, add calc distance along lanes - if possible
This PR edits vehicle model that is copied from simple_planning_simulator. Please consider making changes to the original code to avoid confusion or consult developers (@hakuturu583, @yamacir-kit and @HansRobo ). |
...imple_sensor_simulator/vehicle_simulation/vehicle_model/sim_model_delay_steer_acc_geared.hpp
Outdated
Show resolved
Hide resolved
…osition_z_ to store Oz position
@yamacir-kit |
…tPose and calculateEgoPitch
This reverts commit 1f72837.
…_ when not npc_logic_started
const auto relative_position = | ||
quaternion_operation::getRotationMatrix(initial_pose_.orientation) * world_relative_position_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://eigen.tuxfamily.org/dox/TopicPitfalls.html
In short: do not use the auto keywords with Eigen's expressions, unless you are 100% sure about what you are doing. In particular, do not use the auto keyword as a replacement for a Matrix<> type.
const Eigen::Vector3d relative_position =
This should fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for finding problem!
I also think it should be fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @hakuturu583, it was my pleasure.
Description
Jira ticket: link
Regressions: link
Abstract
Fixes
toLaneletPose()
in FollowTrajectoryAction,Background
I’ve adapted FollowTrajectoryAction to get the Passed result for scenario RoutingAction.FollowTrajectoryAction-autoware.yaml.
NaN time - details
Matching distance - details
The issue was related to the failure to match the lane when changing lanes.
The issue has arisen as a result of the changes involved in the unification of the matching_distance values when matching Entity position to lane - source PR.
This occurred due to missing adaptation of FollowTrajectoryAction to the new approach, to be more precise matching_distance on the BehaviorTree side was different than in TrafficSimulator - commit with the fix, most significant changes:
Slope adaptation - details
After making the above changes, FollowTrajectoryAction successfully arrives at all waypoints, but there is a trouble with having enough accuracy when stopping at the last one.
consider_pose_by_road_slope
to false, FollowTrajectoryAction achieves sufficient accuracy, which confirmed that these slope-related changes are causing this issue.consider_pose_by_road_slope
has no effect on HdMapUtils::toMapPose(). Despite settingconsider_pose_by_road_slope
to false, orientation is still calculated with the slope taken into account.To better understand the issue, I’ve developed an additional scenario "Scenario with slopes" in which there are higher and longer slopes. FollowTrajectoryAction is triggered after 1 second from the start of the scenario and its waypoints form a Polyline is similar to the one marked in red in the figure.
Link to scenario with slopes and map files.
1. The execution of the scenario with slopes and scenario **autoware.yaml before any changes are presented below.
1.1 Before changes - Scenario with slopes - NPC:
As can be seen, the NPC does not move on the lanelet, but moves along the Polyline created by waypoints directly, so that sometimes it is above the lanelet and sometimes below it. The pitch is all the time equal to 0.
In such a case, the calculation of the remaining distance using the euclidean distance works correctly - FollowTrajectoryAction chooses the acceleration well, as a result of which the NPC, after accelerating, moves at a constant speed from which it brakes at the last waypoint.
slope3_no_fix_npc.trimmed.mp4
1.2 Before changes - Scenario with slopes - EGO
As can be seen, the position (in Oz axis) of the Ego, compared to the case for the NPC, is aligned to the lanelet. Because of this, the position on the output of the action after the FollowTrajectoryAction step is different from that on the input of the action in the next step. As a result of that, Ego has a position other than the expected (set) one, FollowTrajectoryAction continues to set accelerations all the time, and Ego does not have a constant speed. The pitch (on FollowTrajectoryAction side) is all the time equal to 0.
slope3_no_fix_ego.trimmed.mp4
1.3 Before changes - **autoware.yaml - NPC
As can be seen, in this case FollowTrajectoryAction works well, and pitch slopes and Oz axis changes are so small that they are unnoticeable.
autoware_no_fix_npc.trimmed.mp4
1.4 Before changes - **autoware.yaml - EGO
However, for Ego, issues arise. They are caused by the same reason as described in 1.2 - the position at the output of FollowTrajectoryAction is different from that at the input in the next step. Ego's velocity changes unexpectedly when changing lanes (where there are differences in the Oz axis and pitch). Because of these issues, FollowTrajectoryAction does not work properly and has a large inaccuracy when stopping.
autoware_no_fix_ego.trimmed.mp4
2. Based on an analysis of the NPCVehicle's behavior in "Scenario with slopes", I’ve developed the fixes required to work with the changes that introduce slope consideration - commit with fixes (adaptation for slopes). The execution of the scenario with slopes and scenario **autoware.yaml after these changes are presented below.
Most significant changes:
distance_along_lanelet
for the calculations of the remaining distancescenario_simulator_v2/simulation/traffic_simulator/src/behavior/follow_trajectory.cpp
Lines 73 to 90 in dfb711f
fill_lanelet_data_and_adjust_orientation
for lanelet position filling, taking pitch from lanelet and applying it to entity orientationscenario_simulator_v2/simulation/traffic_simulator/src/behavior/follow_trajectory.cpp
Lines 91 to 113 in dfb711f
desired_velocity
vector using pitch along lanelet (if possible) and yaw on the targetscenario_simulator_v2/simulation/traffic_simulator/src/behavior/follow_trajectory.cpp
Lines 378 to 399 in dfb711f
current_velocity
vectorscenario_simulator_v2/simulation/traffic_simulator/src/behavior/follow_trajectory.cpp
Lines 419 to 428 in dfb711f
desired_velocity
to calc entity orientationscenario_simulator_v2/simulation/traffic_simulator/src/behavior/follow_trajectory.cpp
Lines 583 to 596 in dfb711f
scenario_simulator_v2/simulation/traffic_simulator/src/behavior/follow_trajectory.cpp
Lines 598 to 603 in dfb711f
Results:
2.1 Adaptation for slopes - Scenario with slopes - NPC:
As can be seen, FollowTrajectoryAction moves the NPC along the lanalet taking into account its slope - as expected. Accelerations are also calculated correctly, ensuring that the NPC reaches a constant speed and stops with sufficient accuracy.
slope3_fix_npc.trimmed.mp4
2.2 Adaptation for slopes - Scenario with slopes - EGO
As can be seen, despite the improvement for Npc, the issue for Ego still exists - speeds change in unexpected ways - after the FollowTrajectoryAction step, the input position is different than the output position in the previous step.
slope3_no_additional_fix_ego.trimmed.mp4
2.3 Adaptation for slopes - **autoware.yaml - NPC
As can be seen now, when the NPC is aligned in the Oz axis to the lanelet and the pitch is taken into account, there are speed changes during lane changes here. This is because the waypoints are in other lanes, so that the distance along the lanelet cannot be calculated, and the euclidean distance is used. (Here the position in Oz is different on both lanes - I checked it, however, I did not take a screen shot...). However, here, for the NPC, after the FollowTrajectoryAction step, the input position is the same as the output position in the previous step.
autoware_fix_npc.trimmed.mp4
2.4 Adaptation for slopes- **autoware.yaml - EGO
As can be seen, the Ego behaves similarly to the NPC - here there are also speed changes caused by the position in Oz. However, for Ego, after the FollowTrajectoryAction step, the input position is different than the output position in the previous step. For this reason, FollowTrajectoryAction cannot achieve the expected accuracy.
autoware_no_additional_fix_ego.trimmed.mp4
3. After analysis, I found the source of the issue, which was related to the way of overwriting positions in EgoEntitySimulation. I’ve developed a fix, thanks to which the position read is the same as written and FollowTrajectoryAction works properly for Ego - commit with fix (fix for Ego). The execution of the scenario with slopes and scenario **autoware.yaml after these changes are presented below.
Most significant changes:
Results:
3.1 Fix for Ego - Scenario with slopes - NPC:
The same as 2.1.
3.2 Fix for Ego - Scenario with slopes - EGO
As can be seen, now the Ego behaves exactly the same as the NPC - after the FollowTrajectoryAction step, the input position is the same as the output position in the previous step. FollowTrajectoryAction ensures stopping at the last point with sufficient accuracy.
slope3_fix_ego.trimmed.mp4
3.3 Fix for Ego - **autoware.yaml - NPC
The same as 2.3.
3.4 Fix for Ego - **autoware.yaml - EGO
As can be seen, now the Ego behaves exactly the same as the NPC - after the FollowTrajectoryAction step, the input position is the same as the output position in the previous step. FollowTrajectoryAction ensures stopping at the last point with sufficient accuracy.
autoware_fix_ego.trimmed.mp4
Destructive Changes
Oz position in SimModelInterface
getZ()
method has been implemented, which returns 0 for every model except the one currently in use.update()
in SimModelInterface is used, everything still works on 2D, and the position in Oz is only used duringoverwrite()
- that is, only by FollowTrajectoryAction.Using distance along
lanelet2
if possible instead of euclidean distance