trajectory.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // Created by zx on 22-12-1.
  3. //
  4. #ifndef LIO_LIVOX_CPP_MPC_TRAJECTORY_H_
  5. #define LIO_LIVOX_CPP_MPC_TRAJECTORY_H_
  6. #include "pose2d.h"
  7. #include <vector>
  8. #include <Eigen/Core>
  9. #include <Eigen/Dense>
  10. class Trajectory
  11. {
  12. public:
  13. Trajectory();
  14. Trajectory(const std::vector<Pose2d>& points);
  15. Trajectory(const Trajectory& other)= default;
  16. Trajectory& operator=(const Trajectory& other)= default;
  17. Pose2d& operator[](int index);
  18. Trajectory& operator+(const Trajectory& other);
  19. unsigned int size()const{return m_pose_vector.size();}
  20. void clear(){m_pose_vector.clear();}
  21. void push_point(const Pose2d& point);
  22. static Trajectory create_trajectory(const Pose2d& start,const Pose2d& end,int point_count=100);
  23. static Trajectory create_line_trajectory(const Pose2d& start,const Pose2d& end,float dt=0.2);
  24. static Trajectory path_smooth_slid(const std::vector<Pose2d>& path, int size = 5);
  25. protected:
  26. std::vector<Pose2d> m_pose_vector;
  27. };
  28. /*
  29. * 根据梯度和方向计算角度,x轴正,逆时针为正
  30. */
  31. double gradient2theta(double gradient,bool direction=true);
  32. double gen_axis_angle(const Pose2d& point1,const Pose2d& point2);
  33. /*
  34. * 计算曲线P 在(x1,x2)的线积分
  35. * 默认以 (x2-x1)/100 为步长
  36. */
  37. double integral_path(double x1,double x2,Eigen::MatrixXd P);
  38. #endif //LIO_LIVOX_CPP_MPC_TRAJECTORY_H_