loaded_mpc.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // Created by zx on 22-12-1.
  3. //
  4. #ifndef LIO_LIVOX_CPP_MPC_LOADED_MPC_H_
  5. #define LIO_LIVOX_CPP_MPC_LOADED_MPC_H_
  6. #include <Eigen/Core>
  7. #include "trajectory.h"
  8. enum MpcError{
  9. success=0,
  10. no_solution=1,
  11. failed
  12. };
  13. class LoadedMPC
  14. {
  15. public:
  16. typedef struct {
  17. float shortest_radius;
  18. float dt;
  19. float acc_velocity;
  20. float acc_angular;
  21. }MPC_parameter;
  22. public:
  23. LoadedMPC(const Pose2d& obs,double obs_w,double obs_h,double min_velocity,double max_velocity);
  24. virtual ~LoadedMPC();
  25. virtual MpcError solve(Trajectory trajectory, Pose2d target,Eigen::VectorXd statu,MPC_parameter mpc_param,
  26. std::vector<double>& out,Trajectory& select_traj,Trajectory& optimize_trajectory);
  27. protected:
  28. /*
  29. * 根据当前点和轨迹,选择前方 point_num
  30. * point:当前点,target:目标点
  31. */
  32. static bool filte_Path(const Pose2d& point,Pose2d target,
  33. Trajectory trajectory,std::vector<Pose2d>& poses,int point_num=10);
  34. /*
  35. * 根据路径点,拟合曲线
  36. */
  37. static Eigen::VectorXd fit_path(const std::vector<Pose2d>& trajectory);
  38. Pose2d obs_relative_pose_; //障碍物相对小车的位姿
  39. double min_velocity_;
  40. double max_velocity_;
  41. double obs_w_;
  42. double obs_h_;
  43. };
  44. #endif //LIO_LIVOX_CPP_MPC_LOADED_MPC_H_