30 LaneConstraint(Translation2d center_line_start, Translation2d center_line_end,
33 if (tolerance != 0.0) {
34 double dx = center_line_end.
x() - center_line_start.
x();
35 double dy = center_line_end.
y() - center_line_start.
y();
36 double dist = std::hypot(dx, dy);
37 auto offset = Translation2d{0.0, tolerance}.rotate_by(
38 Rotation2d{dx / dist, dy / dist});
41 center_line_start + offset,
42 center_line_end + offset,
46 {0.0, 0.0}, center_line_start, center_line_end, Side::ON};
49 m_bottom_line{[&]() -> std::optional<PointLineRegionConstraint> {
50 if (tolerance != 0.0) {
51 double dx = center_line_end.x() - center_line_start.x();
52 double dy = center_line_end.y() - center_line_start.y();
53 double dist = std::hypot(dx, dy);
54 auto offset = Translation2d{0.0, tolerance}.
rotate_by(
55 Rotation2d{dx / dist, dy / dist});
58 center_line_start - offset,
59 center_line_end - offset,
74 void apply(slp::Problem<double>& problem,
const Pose2v<double>& pose,
75 const Translation2v<double>& linear_velocity,
76 const slp::Variable<double>& angular_velocity,
77 const Translation2v<double>& linear_acceleration,
78 const slp::Variable<double>& angular_acceleration) {
79 m_top_line.apply(problem, pose, linear_velocity, angular_velocity,
80 linear_acceleration, angular_acceleration);
81 if (m_bottom_line.has_value()) {
82 m_bottom_line.value().apply(problem, pose, linear_velocity,
83 angular_velocity, linear_acceleration,
84 angular_acceleration);