@@ -65,13 +65,25 @@ class PidLongitudinalController : public trajectory_follower::LongitudinalContro
65
65
double vel{0.0 };
66
66
double acc{0.0 };
67
67
};
68
-
68
+ struct StateAfterDelay
69
+ {
70
+ StateAfterDelay (const double velocity, const double acceleration, const double distance)
71
+ : vel(velocity), acc(acceleration), running_distance(distance)
72
+ {
73
+ }
74
+ double vel{0.0 };
75
+ double acc{0.0 };
76
+ double running_distance{0.0 };
77
+ };
69
78
enum class Shift { Forward = 0 , Reverse };
70
79
71
80
struct ControlData
72
81
{
73
82
bool is_far_from_trajectory{false };
83
+ autoware_auto_planning_msgs::msg::Trajectory interpolated_traj{};
74
84
size_t nearest_idx{0 }; // nearest_idx = 0 when nearest_idx is not found with findNearestIdx
85
+ size_t target_idx{0 };
86
+ StateAfterDelay state_after_delay{0.0 , 0.0 , 0.0 };
75
87
Motion current_motion{};
76
88
Shift shift{Shift::Forward}; // shift is used only to calculate the sign of pitch compensation
77
89
double stop_dist{0.0 }; // signed distance that is positive when car is before the stopline
@@ -179,7 +191,8 @@ class PidLongitudinalController : public trajectory_follower::LongitudinalContro
179
191
double m_min_jerk;
180
192
181
193
// slope compensation
182
- bool m_use_traj_for_pitch;
194
+ bool m_enable_adaptive_trajectory;
195
+ double m_adaptive_trajectory_velocity_th;
183
196
std::shared_ptr<LowpassFilter1d> m_lpf_pitch{nullptr };
184
197
double m_max_pitch_rad;
185
198
double m_min_pitch_rad;
@@ -271,11 +284,9 @@ class PidLongitudinalController : public trajectory_follower::LongitudinalContro
271
284
272
285
/* *
273
286
* @brief calculate control command based on the current control state
274
- * @param [in] current_pose current ego pose
275
287
* @param [in] control_data control data
276
288
*/
277
- Motion calcCtrlCmd (
278
- const geometry_msgs::msg::Pose & current_pose, const ControlData & control_data);
289
+ Motion calcCtrlCmd (const ControlData & control_data);
279
290
280
291
/* *
281
292
* @brief publish control command
@@ -304,9 +315,9 @@ class PidLongitudinalController : public trajectory_follower::LongitudinalContro
304
315
305
316
/* *
306
317
* @brief calculate direction (forward or backward) that vehicle moves
307
- * @param [in] nearest_idx nearest index on trajectory to vehicle
318
+ * @param [in] control_data data for control calculation
308
319
*/
309
- enum Shift getCurrentShift (const size_t nearest_idx ) const ;
320
+ enum Shift getCurrentShift (const ControlData & control_data ) const ;
310
321
311
322
/* *
312
323
* @brief filter acceleration command with limitation of acceleration and jerk, and slope
@@ -336,16 +347,16 @@ class PidLongitudinalController : public trajectory_follower::LongitudinalContro
336
347
* @param [in] motion delay compensated target motion
337
348
*/
338
349
Motion keepBrakeBeforeStop (
339
- const autoware_auto_planning_msgs::msg::Trajectory & traj, const Motion & target_motion,
340
- const size_t nearest_idx) const ;
350
+ const ControlData & control_data, const Motion & target_motion, const size_t nearest_idx) const ;
341
351
342
352
/* *
343
353
* @brief interpolate trajectory point that is nearest to vehicle
344
354
* @param [in] traj reference trajectory
345
355
* @param [in] point vehicle position
346
356
* @param [in] nearest_idx index of the trajectory point nearest to the vehicle position
347
357
*/
348
- autoware_auto_planning_msgs::msg::TrajectoryPoint calcInterpolatedTargetValue (
358
+ std::pair<autoware_auto_planning_msgs::msg::TrajectoryPoint, size_t >
359
+ calcInterpolatedTrajPointAndSegment (
349
360
const autoware_auto_planning_msgs::msg::Trajectory & traj,
350
361
const geometry_msgs::msg::Pose & pose) const ;
351
362
@@ -354,18 +365,14 @@ class PidLongitudinalController : public trajectory_follower::LongitudinalContro
354
365
* @param [in] current_motion current velocity and acceleration of the vehicle
355
366
* @param [in] delay_compensation_time predicted time delay
356
367
*/
357
- double predictedVelocityInTargetPoint (
368
+ StateAfterDelay predictedStateAfterDelay (
358
369
const Motion current_motion, const double delay_compensation_time) const ;
359
370
360
371
/* *
361
372
* @brief calculate velocity feedback with feed forward and pid controller
362
- * @param [in] target_motion reference velocity and acceleration. This acceleration will be used
363
- * as feed forward.
364
- * @param [in] dt time step to use
365
- * @param [in] current_vel current velocity of the vehicle
373
+ * @param [in] control_data data for control calculation
366
374
*/
367
- double applyVelocityFeedback (
368
- const Motion target_motion, const double dt, const double current_vel, const Shift & shift);
375
+ double applyVelocityFeedback (const ControlData & control_data);
369
376
370
377
/* *
371
378
* @brief update variables for debugging about pitch
@@ -378,12 +385,9 @@ class PidLongitudinalController : public trajectory_follower::LongitudinalContro
378
385
/* *
379
386
* @brief update variables for velocity and acceleration
380
387
* @param [in] ctrl_cmd latest calculated control command
381
- * @param [in] current_pose current pose of the vehicle
382
388
* @param [in] control_data data for control calculation
383
389
*/
384
- void updateDebugVelAcc (
385
- const Motion & ctrl_cmd, const geometry_msgs::msg::Pose & current_pose,
386
- const ControlData & control_data);
390
+ void updateDebugVelAcc (const ControlData & control_data);
387
391
};
388
392
} // namespace autoware::motion::control::pid_longitudinal_controller
389
393
0 commit comments