Open VRichardJP opened 10 months ago
isEngageStatus
does not return true
when engaging backward (i.e. target_vel < node_param_.engage_velocity
)
MotionVelocitySmootherNode::calcExternalVelocityLimit()
assumes forward drive:
when v0 < 0.0
, max_velocity_with_deceleration_
is set to negative value, but it is supposedly absolute velocity.
applyExternalVelocityLimit()
logic looks strange on backward path:
calcTrajectoryVelocity()
after input velocity has been "flipped" in onCurrentTrajectory
:trajectory_utils::applyMaximumVelocityLimit()
, motion_utils::insertTargetPoint()
is used to insert a point further on the path, from which the external speed limit will be applied. However, the functions will always fail on reversed path because of this check:And the external velocity limit is not applied on the path:
I feel that if we wanted the same logic to apply to both forward and backward trajectories, the flipVelocity
should rather flip every thing: orientation, velocity, acceleration, etc
With the freespace planner in the planning simulator:
Turn left while going forward:
One of the middle point of /planning/scenario_planning/motion_velocity_smoother/trajectory
trajectory shows front_wheel_angle_rad = 0.300...
Same but with vehicle and goal pose swapped:
One of the middle point shows front_wheel_angle_rad = -0.300...
We should get the same front_wheel_angle_rad
in both cases, but in the reverse case it is as if the vehicle was turning right.
So far, I have been able to fix all the issues above by refactoring the "velocity flipping" logic a bit and by replacing the flipVelocity
function by this one:
void MotionVelocitySmootherNode::flipTrajectory(TrajectoryPoints & points) const
{
for (auto & pt : points) {
pt.pose = flipPose(pt.pose);
pt.longitudinal_velocity_mps = -pt.longitudinal_velocity_mps;
pt.lateral_velocity_mps = -pt.lateral_velocity_mps;
// NOTE(VRichardJP) this is actually a directed acceleration so it should not be flipped
// pt.acceleration_mps2 = -pt.acceleration_mps2;
pt.heading_rate_rps = -pt.heading_rate_rps;
pt.front_wheel_angle_rad = -pt.front_wheel_angle_rad;
pt.rear_wheel_angle_rad = -pt.rear_wheel_angle_rad;
}
}
which flips everything in the trajectory, not just velocity. I also do the same for all ego pose/twist while driving in reverse:
geometry_msgs::msg::Pose MotionVelocitySmootherNode::flipPose(const geometry_msgs::msg::Pose & pose) const
{
geometry_msgs::msg::Pose output = pose;
// rotation by 180 degrees
tf2::Quaternion q_rot;
q_rot.setRPY(0, 0, M_PI);
tf2::Quaternion q;
tf2::fromMsg(pose.orientation, q);
q *= q_rot;
output.orientation = tf2::toMsg(q);
return output;
}
This way, flipped backward trajectories just looks like forward trajectories, which just need to be flipped at the end of processing.
This pull request has been automatically marked as stale because it has not had recent activity.
Checklist
Description
As I investigate freespace planners, I observe
motion_velocity_smoother
has many issues handling trajectories going backwards. The trajectories are assumed to go forward in many places but calculation are plain wrong if the path goes backward.I would like to list all issues here.
isEngageStatus()
on backward engageMotionVelocitySmootherNode::calcExternalVelocityLimit()
assumes forward driveapplyExternalVelocityLimit
front_wheel_angle_rad
on backward pathPurpose
Find and fix logic when backward trajectories are used.
Possible approaches
N/A
Definition of done
N/A