Skip to content

Commit 99b9f25

Browse files
authored
Merge branch 'main' into feature/smooth_ndt_map_update
2 parents f06d431 + 28154f6 commit 99b9f25

File tree

24 files changed

+815
-94
lines changed

24 files changed

+815
-94
lines changed

control/pid_longitudinal_controller/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
<maintainer email="takamasa.horibe@tier4.jp">Takamasa Horibe</maintainer>
99
<maintainer email="takayuki.murooka@tier4.jp">Takayuki Murooka</maintainer>
10+
<maintainer email="mamoru.sobue@tier4.jp">Mamoru Sobue</maintainer>
1011

1112
<license>Apache 2.0</license>
1213

control/pid_longitudinal_controller/src/pid_longitudinal_controller.cpp

+22-2
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ PidLongitudinalController::ControlData PidLongitudinalController::getControlData
456456
current_interpolated_pose.first);
457457
control_data.nearest_idx = current_interpolated_pose.second + 1;
458458
control_data.target_idx = control_data.nearest_idx;
459+
const auto nearest_point = current_interpolated_pose.first;
460+
auto target_point = current_interpolated_pose.first;
459461

460462
// check if the deviation is worth emergency
461463
m_diagnostic_data.trans_deviation =
@@ -491,11 +493,25 @@ PidLongitudinalController::ControlData PidLongitudinalController::getControlData
491493
control_data.interpolated_traj.points.insert(
492494
control_data.interpolated_traj.points.begin() + control_data.target_idx,
493495
target_interpolated_point.first);
496+
target_point = target_interpolated_point.first;
494497
}
495498

499+
// ==========================================================================================
500+
// NOTE: due to removeOverlapPoints(), the obtained control_data.target_idx and
501+
// control_data.nearest_idx may become invalid if the number of points decreased.
502+
// current API does not provide the way to check duplication beforehand and this function
503+
// does not tell how many/which index points were removed, so there is no way
504+
// to tell if our `control_data.target_idx` point still exists or removed.
505+
// ==========================================================================================
496506
// Remove overlapped points after inserting the interpolated points
497507
control_data.interpolated_traj.points =
498508
motion_utils::removeOverlapPoints(control_data.interpolated_traj.points);
509+
control_data.nearest_idx = motion_utils::findFirstNearestIndexWithSoftConstraints(
510+
control_data.interpolated_traj.points, nearest_point.pose, m_ego_nearest_dist_threshold,
511+
m_ego_nearest_yaw_threshold);
512+
control_data.target_idx = motion_utils::findFirstNearestIndexWithSoftConstraints(
513+
control_data.interpolated_traj.points, target_point.pose, m_ego_nearest_dist_threshold,
514+
m_ego_nearest_yaw_threshold);
499515

500516
// send debug values
501517
m_debug_values.setValues(DebugValues::TYPE::PREDICTED_VEL, control_data.state_after_delay.vel);
@@ -610,8 +626,12 @@ void PidLongitudinalController::updateControlState(const ControlData & control_d
610626
? (clock_->now() - *m_last_running_time).seconds() > p.stopped_state_entry_duration_time
611627
: false;
612628

613-
const double current_vel_cmd =
614-
std::fabs(m_trajectory.points.at(control_data.nearest_idx).longitudinal_velocity_mps);
629+
// ==========================================================================================
630+
// NOTE: due to removeOverlapPoints() in getControlData() m_trajectory and
631+
// control_data.interpolated_traj have different size.
632+
// ==========================================================================================
633+
const double current_vel_cmd = std::fabs(
634+
control_data.interpolated_traj.points.at(control_data.nearest_idx).longitudinal_velocity_mps);
615635
const bool emergency_condition = m_enable_overshoot_emergency &&
616636
stop_dist < -p.emergency_state_overshoot_stop_dist &&
617637
current_vel_cmd < vel_epsilon;

perception/image_projection_based_fusion/src/fusion_node.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ void FusionNode<Msg, Obj, Msg2D>::subCallback(const typename Msg::ConstSharedPtr
167167
timer_->cancel();
168168
postprocess(*(cached_msg_.second));
169169
publish(*(cached_msg_.second));
170-
cached_msg_.second = nullptr;
171170
std::fill(is_fused_.begin(), is_fused_.end(), false);
172171

173172
// add processing time for debug
@@ -187,6 +186,8 @@ void FusionNode<Msg, Obj, Msg2D>::subCallback(const typename Msg::ConstSharedPtr
187186
"debug/pipeline_latency_ms", pipeline_latency_ms);
188187
processing_time_ms = 0;
189188
}
189+
190+
cached_msg_.second = nullptr;
190191
}
191192

192193
std::lock_guard<std::mutex> lock(mutex_cached_msgs_);
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**:
22
ros__parameters:
33
update_rate_hz: 20.0
4+
new_frame_id: "base_link"
45
use_twist_compensation: true
56
use_twist_yaw_compensation: false
67
static_object_speed_threshold: 1.0

planning/behavior_path_planner_common/src/utils/drivable_area_expansion/static_drivable_area.cpp

+17-14
Original file line numberDiff line numberDiff line change
@@ -650,14 +650,14 @@ std::optional<size_t> getOverlappedLaneletId(const std::vector<DrivableLanes> &
650650

651651
for (const auto & lanelet : lanelets) {
652652
for (const auto & target_lanelet : target_lanelets) {
653-
std::vector<Point2d> intersections{};
653+
std::vector<Polygon2d> intersections{};
654654
boost::geometry::intersection(
655-
lanelet.polygon2d().basicPolygon(), target_lanelet.polygon2d().basicPolygon(),
656-
intersections);
655+
toPolygon2d(lanelet), toPolygon2d(target_lanelet), intersections);
657656

658-
// if only one point intersects, it is assumed not to be overlapped
659-
if (intersections.size() > 1) {
660-
return true;
657+
for (const auto & polygon : intersections) {
658+
if (boost::geometry::area(polygon) > 1e-3) {
659+
return true;
660+
}
661661
}
662662
}
663663
}
@@ -1463,11 +1463,10 @@ std::pair<std::vector<lanelet::ConstPoint3d>, bool> getBoundWithFreeSpaceAreas(
14631463
throw std::domain_error("invalid case.");
14641464
}
14651465

1466-
const auto goal_is_in_freespace = boost::geometry::within(
1467-
to2D(toLaneletPoint(route_handler->getGoalPose().position).basicPoint()),
1468-
to2D(polygon).basicPolygon());
1469-
1470-
return std::make_pair(expanded_bound, is_driving_freespace || goal_is_in_freespace);
1466+
const auto skip_post_process = route_case == RouteCase::INIT_POS_IS_IN_FREESPACE ||
1467+
route_case == RouteCase::GOAL_POS_IS_IN_FREESPACE ||
1468+
is_driving_freespace;
1469+
return std::make_pair(expanded_bound, skip_post_process);
14711470
}
14721471

14731472
std::vector<geometry_msgs::msg::Point> postProcess(
@@ -1569,7 +1568,9 @@ std::vector<geometry_msgs::msg::Point> postProcess(
15691568
// Insert a start point
15701569
processed_bound.push_back(start_point);
15711570

1572-
return findNearestSegmentIndexFromLateralDistance(tmp_bound, start_point);
1571+
const auto p_tmp =
1572+
geometry_msgs::build<Pose>().position(start_point).orientation(front_pose.orientation);
1573+
return findNearestSegmentIndexFromLateralDistance(tmp_bound, p_tmp, M_PI_2);
15731574
}();
15741575

15751576
// Get Closest segment for the goal point
@@ -1579,8 +1580,10 @@ std::vector<geometry_msgs::msg::Point> postProcess(
15791580
findNearestSegmentIndexFromLateralDistance(tmp_bound, goal_pose, M_PI_2);
15801581
const auto goal_point =
15811582
calcLongitudinalOffsetGoalPoint(tmp_bound, goal_pose, goal_start_idx, vehicle_length);
1582-
const size_t goal_idx =
1583-
std::max(goal_start_idx, findNearestSegmentIndexFromLateralDistance(tmp_bound, goal_point));
1583+
const auto p_tmp =
1584+
geometry_msgs::build<Pose>().position(goal_point).orientation(goal_pose.orientation);
1585+
const size_t goal_idx = std::max(
1586+
goal_start_idx, findNearestSegmentIndexFromLateralDistance(tmp_bound, p_tmp, M_PI_2));
15841587

15851588
return std::make_pair(goal_idx, goal_point);
15861589
}();

planning/external_velocity_limit_selector/config/default_common.param.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/**:
22
ros__parameters:
33
# constraints param for normal driving
4+
max_vel: 11.1 # max velocity limit [m/s]
5+
46
normal:
57
min_acc: -0.5 # min deceleration [m/ss]
68
max_acc: 1.0 # max acceleration [m/ss]

planning/motion_velocity_smoother/config/default_common.param.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/**:
22
ros__parameters:
33
# constraints param for normal driving
4+
max_vel: 11.1 # max velocity limit [m/s]
5+
46
normal:
57
min_acc: -0.5 # min deceleration [m/ss]
68
max_acc: 1.0 # max acceleration [m/ss]

planning/motion_velocity_smoother/src/motion_velocity_smoother_node.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ rcl_interfaces::msg::SetParametersResult MotionVelocitySmootherNode::onParameter
173173
update_param_bool("enable_lateral_acc_limit", p.enable_lateral_acc_limit);
174174
update_param_bool("enable_steering_rate_limit", p.enable_steering_rate_limit);
175175

176-
update_param("max_velocity", p.max_velocity);
176+
update_param("max_vel", p.max_velocity);
177177
update_param(
178178
"margin_to_insert_external_velocity_limit", p.margin_to_insert_external_velocity_limit);
179179
update_param("replan_vel_deviation", p.replan_vel_deviation);
@@ -277,7 +277,7 @@ void MotionVelocitySmootherNode::initCommonParam()
277277
p.enable_lateral_acc_limit = declare_parameter<bool>("enable_lateral_acc_limit");
278278
p.enable_steering_rate_limit = declare_parameter<bool>("enable_steering_rate_limit");
279279

280-
p.max_velocity = declare_parameter<double>("max_velocity"); // 72.0 kmph
280+
p.max_velocity = declare_parameter<double>("max_vel");
281281
p.margin_to_insert_external_velocity_limit =
282282
declare_parameter<double>("margin_to_insert_external_velocity_limit");
283283
p.replan_vel_deviation = declare_parameter<double>("replan_vel_deviation");

planning/obstacle_cruise_planner/config/default_common.param.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/**:
22
ros__parameters:
33
# constraints param for normal driving
4+
max_vel: 11.1 # max velocity limit [m/s]
5+
46
normal:
57
min_acc: -1.0 # min deceleration [m/ss]
68
max_acc: 1.0 # max acceleration [m/ss]

planning/obstacle_stop_planner/config/common.param.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/**:
22
ros__parameters:
33
# constraints param for normal driving
4+
max_vel: 11.1 # max velocity limit [m/s]
5+
46
normal:
57
min_acc: -0.5 # min deceleration [m/ss]
68
max_acc: 1.0 # max acceleration [m/ss]

planning/planning_test_utils/config/test_common.param.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/**:
22
ros__parameters:
33
# constraints param for normal driving
4+
max_vel: 11.1 # max velocity limit [m/s]
5+
46
normal:
57
min_acc: -1.0 # min deceleration [m/ss]
68
max_acc: 1.0 # max acceleration [m/ss]

planning/planning_validator/README.md

+22-12
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ The following features are supported for trajectory validation and can have thre
1818
- **Steering angle rate** : invalid if the expected steering rate value is too large
1919
- **Velocity deviation** : invalid if the planning velocity is too far from the ego velocity
2020
- **Distance deviation** : invalid if the ego is too far from the trajectory
21+
- **Longitudinal distance deviation** : invalid if the trajectory is too far from ego in longitudinal direction
22+
- **Forward trajectory length** : invalid if the trajectory length is not enough to stop within a given deceleration
2123

2224
The following features are to be implemented.
2325

@@ -63,15 +65,23 @@ The following parameters can be set for the `planning_validator`:
6365

6466
The input trajectory is detected as invalid if the index exceeds the following thresholds.
6567

66-
| Name | Type | Description | Default value |
67-
| :-------------------------------- | :----- | :----------------------------------------------------------------------------------------------------------------- | :------------ |
68-
| `thresholds.interval` | double | invalid threshold of the distance of two neighboring trajectory points [m] | 100.0 |
69-
| `thresholds.relative_angle` | double | invalid threshold of the relative angle of two neighboring trajectory points [rad] | 2.0 |
70-
| `thresholds.curvature` | double | invalid threshold of the curvature in each trajectory point [1/m] | 1.0 |
71-
| `thresholds.lateral_acc` | double | invalid threshold of the lateral acceleration in each trajectory point [m/ss] | 9.8 |
72-
| `thresholds.longitudinal_max_acc` | double | invalid threshold of the maximum longitudinal acceleration in each trajectory point [m/ss] | 9.8 |
73-
| `thresholds.longitudinal_min_acc` | double | invalid threshold of the minimum longitudinal deceleration in each trajectory point [m/ss] | -9.8 |
74-
| `thresholds.steering` | double | invalid threshold of the steering angle in each trajectory point [rad] | 1.414 |
75-
| `thresholds.steering_rate` | double | invalid threshold of the steering angle rate in each trajectory point [rad/s] | 10.0 |
76-
| `thresholds.velocity_deviation` | double | invalid threshold of the velocity deviation between the ego velocity and the trajectory point closest to ego [m/s] | 100.0 |
77-
| `thresholds.distance_deviation` | double | invalid threshold of the distance deviation between the ego position and the trajectory point closest to ego [m] | 100.0 |
68+
| Name | Type | Description | Default value |
69+
| :------------------------------------------- | :----- | :----------------------------------------------------------------------------------------------------------------- | :------------ |
70+
| `thresholds.interval` | double | invalid threshold of the distance of two neighboring trajectory points [m] | 100.0 |
71+
| `thresholds.relative_angle` | double | invalid threshold of the relative angle of two neighboring trajectory points [rad] | 2.0 |
72+
| `thresholds.curvature` | double | invalid threshold of the curvature in each trajectory point [1/m] | 1.0 |
73+
| `thresholds.lateral_acc` | double | invalid threshold of the lateral acceleration in each trajectory point [m/ss] | 9.8 |
74+
| `thresholds.longitudinal_max_acc` | double | invalid threshold of the maximum longitudinal acceleration in each trajectory point [m/ss] | 9.8 |
75+
| `thresholds.longitudinal_min_acc` | double | invalid threshold of the minimum longitudinal deceleration in each trajectory point [m/ss] | -9.8 |
76+
| `thresholds.steering` | double | invalid threshold of the steering angle in each trajectory point [rad] | 1.414 |
77+
| `thresholds.steering_rate` | double | invalid threshold of the steering angle rate in each trajectory point [rad/s] | 10.0 |
78+
| `thresholds.velocity_deviation` | double | invalid threshold of the velocity deviation between the ego velocity and the trajectory point closest to ego [m/s] | 100.0 |
79+
| `thresholds.distance_deviation` | double | invalid threshold of the distance deviation between the ego position and the trajectory point closest to ego [m] | 100.0 |
80+
| `parameters.longitudinal_distance_deviation` | double | invalid threshold of the longitudinal distance deviation between the ego position and the trajectory [m] | 2.0 |
81+
82+
#### Parameters
83+
84+
For parameters used e.g. to calculate threshold.
85+
86+
| `parameters.forward_trajectory_length_acceleration` | double | This value is used to calculate required trajectory length. | -5.0 |
87+
| `parameters.forward_trajectory_length_margin` | double | A margin of the required trajectory length not to raise an error when the ego slightly exceeds the trajectory end point. | 2.0 |

planning/planning_validator/config/planning_validator.param.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,14 @@
2626
steering_rate: 10.0
2727
velocity_deviation: 100.0
2828
distance_deviation: 100.0
29+
longitudinal_distance_deviation: 1.0
30+
31+
parameters:
32+
# The required trajectory length is calculated as the distance needed
33+
# to stop from the current speed at this deceleration.
34+
forward_trajectory_length_acceleration: -3.0
35+
36+
# An error is raised if the required trajectory length is less than this distance.
37+
# Setting it to 0 means an error will occur if even slightly exceeding the end of the path,
38+
# therefore, a certain margin is necessary.
39+
forward_trajectory_length_margin: 2.0

planning/planning_validator/include/planning_validator/planning_validator.hpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ using tier4_debug_msgs::msg::Float64Stamped;
4545

4646
struct ValidationParams
4747
{
48+
// thresholds
4849
double interval_threshold;
4950
double relative_angle_threshold;
5051
double curvature_threshold;
@@ -55,6 +56,11 @@ struct ValidationParams
5556
double steering_rate_threshold;
5657
double velocity_deviation_threshold;
5758
double distance_deviation_threshold;
59+
double longitudinal_distance_deviation_threshold;
60+
61+
// parameters
62+
double forward_trajectory_length_acceleration;
63+
double forward_trajectory_length_margin;
5864
};
5965

6066
class PlanningValidator : public rclcpp::Node
@@ -64,7 +70,7 @@ class PlanningValidator : public rclcpp::Node
6470

6571
void onTrajectory(const Trajectory::ConstSharedPtr msg);
6672

67-
bool checkValidSize(const Trajectory & trajectory) const;
73+
bool checkValidSize(const Trajectory & trajectory);
6874
bool checkValidFiniteValue(const Trajectory & trajectory);
6975
bool checkValidInterval(const Trajectory & trajectory);
7076
bool checkValidRelativeAngle(const Trajectory & trajectory);
@@ -76,6 +82,8 @@ class PlanningValidator : public rclcpp::Node
7682
bool checkValidSteeringRate(const Trajectory & trajectory);
7783
bool checkValidVelocityDeviation(const Trajectory & trajectory);
7884
bool checkValidDistanceDeviation(const Trajectory & trajectory);
85+
bool checkValidLongitudinalDistanceDeviation(const Trajectory & trajectory);
86+
bool checkValidForwardTrajectoryLength(const Trajectory & trajectory);
7987

8088
private:
8189
void setupDiag();

planning/planning_validator/msg/PlanningValidatorStatus.msg

+6
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ bool is_valid_steering
1313
bool is_valid_steering_rate
1414
bool is_valid_velocity_deviation
1515
bool is_valid_distance_deviation
16+
bool is_valid_longitudinal_distance_deviation
17+
bool is_valid_forward_trajectory_length
1618

1719
# values
20+
int64 trajectory_size
1821
float64 max_interval_distance
1922
float64 max_relative_angle
2023
float64 max_curvature
@@ -25,5 +28,8 @@ float64 max_steering
2528
float64 max_steering_rate
2629
float64 velocity_deviation
2730
float64 distance_deviation
31+
float64 longitudinal_distance_deviation
32+
float64 forward_trajectory_length_required
33+
float64 forward_trajectory_length_measured
2834

2935
int64 invalid_count

0 commit comments

Comments
 (0)