|
@@ -9,6 +9,8 @@
|
|
|
#include <decition/adc_controller/base_controller.h>
|
|
|
#include <decition/adc_tools/transfer.h>
|
|
|
|
|
|
+#include <common/car_status.h>
|
|
|
+
|
|
|
#ifdef USEAUTOWAREMPC
|
|
|
#include "mpc_lateral_controller/mpc_trajectory.hpp"
|
|
|
#include "mpc_lateral_controller/mpc.hpp"
|
|
@@ -34,7 +36,7 @@ public:
|
|
|
// rclcpp::Logger logger = rclcpp::get_logger("mpc_test_logger");
|
|
|
|
|
|
// Vehicle model parameters
|
|
|
- double wheelbase = 2.7;
|
|
|
+ double wheelbase = 2.9;
|
|
|
double steer_limit = 1.0;
|
|
|
double steer_tau = 0.1;
|
|
|
double mass_fl = 600.0;
|
|
@@ -46,13 +48,13 @@ public:
|
|
|
|
|
|
// Filters parameter
|
|
|
double steering_lpf_cutoff_hz = 3.0;
|
|
|
- double error_deriv_lpf_cutoff_hz = 5.0;
|
|
|
+ double error_deriv_lpf_cutoff_hz = 15.0;
|
|
|
|
|
|
// Test Parameters
|
|
|
- double admissible_position_error = 5.0;
|
|
|
+ double admissible_position_error = 15.0;//5.0;
|
|
|
double admissible_yaw_error_rad = M_PI_2;
|
|
|
double steer_lim = 0.610865; // 35 degrees
|
|
|
- double steer_rate_lim = 2.61799; // 150 degrees
|
|
|
+ double steer_rate_lim = 5.3; //2.61799; // 150 degrees
|
|
|
double ctrl_period = 0.03;
|
|
|
|
|
|
bool use_steer_prediction = true;
|
|
@@ -61,6 +63,7 @@ public:
|
|
|
|
|
|
MPC mmpc;
|
|
|
|
|
|
+
|
|
|
void SetUp()
|
|
|
{
|
|
|
param.prediction_horizon = 50;
|
|
@@ -98,6 +101,12 @@ public:
|
|
|
trajectory_param.enable_path_smoothing = true;
|
|
|
trajectory_param.extend_trajectory_for_end_yaw_control = true;
|
|
|
|
|
|
+ dummy_straight_trajectory.push_back(0,0.0,0.0,0.0,1.0,0,0,0);
|
|
|
+ dummy_straight_trajectory.push_back(1,0.1,0.0,0.0,1.0,0,0,0);
|
|
|
+ dummy_straight_trajectory.push_back(2,0.2,0.0,0.0,1.0,0,0,0);
|
|
|
+ dummy_straight_trajectory.push_back(3,0.3,0.0,0.0,1.0,0,0,0);
|
|
|
+ dummy_straight_trajectory.push_back(4,0.4,0.0,0.0,1.0,0,0,0);
|
|
|
+
|
|
|
|
|
|
|
|
|
neutral_steer.steering_tire_angle = 0.0;
|
|
@@ -126,6 +135,7 @@ public:
|
|
|
{
|
|
|
SetUp();
|
|
|
|
|
|
+ wheelbase = ServiceCarStatus.mfWheelBase;
|
|
|
std::shared_ptr<VehicleModelInterface> vehicle_model_ptr =
|
|
|
std::make_shared<KinematicsBicycleModel>(wheelbase, steer_limit, steer_tau);
|
|
|
mmpc.setVehicleModel(vehicle_model_ptr);
|
|
@@ -137,6 +147,23 @@ public:
|
|
|
|
|
|
std::cout<<" haveVehicleModel : "<<mmpc.hasVehicleModel()<<std::endl;
|
|
|
std::cout<<" haveQPSolver : "<<mmpc.hasQPSolver()<<std::endl;
|
|
|
+
|
|
|
+
|
|
|
+ const auto current_kinematics =
|
|
|
+ makeOdometry(pose_zero, 0.0);
|
|
|
+ mmpc.setReferenceTrajectory(dummy_straight_trajectory, trajectory_param, current_kinematics);
|
|
|
+
|
|
|
+ // Calculate MPC
|
|
|
+ ADCAckermannLateralCommand ctrl_cmd;
|
|
|
+ MPCTrajectory pred_traj;
|
|
|
+ const auto odom = makeOdometry(pose_zero, default_velocity);
|
|
|
+ bool bcalc = mmpc.calculateMPC(neutral_steer, odom, ctrl_cmd, pred_traj);
|
|
|
+
|
|
|
+
|
|
|
+ if(bcalc)
|
|
|
+ {
|
|
|
+ std::cout<<"test ok."<<std::endl;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
iv::ADCOdometry makeOdometry(const iv::ADCPose & pose, const double velocity)
|
|
@@ -152,14 +179,14 @@ public:
|
|
|
{
|
|
|
// Init trajectory
|
|
|
const auto current_kinematics =
|
|
|
- makeOdometry(pose_zero, 0.0);
|
|
|
+ makeOdometry(pose_zero, 1.0);
|
|
|
mmpc.setReferenceTrajectory(traj, trajectory_param, current_kinematics);
|
|
|
}
|
|
|
|
|
|
- bool calculateMPC(const iv::ADCSteeringReport & current_steer,
|
|
|
+ bool calculateMPC(const iv::ADCSteeringReport & current_steer,double fvel,
|
|
|
ADCAckermannLateralCommand & ctrl_cmd, MPCTrajectory & predicted_trajectory)
|
|
|
{
|
|
|
- const auto odom = makeOdometry(pose_zero, default_velocity);
|
|
|
+ const auto odom = makeOdometry(pose_zero, fvel);
|
|
|
bool bcalc = mmpc.calculateMPC(current_steer, odom, ctrl_cmd, predicted_trajectory);
|
|
|
return bcalc;
|
|
|
}
|