96SEO 2026-02-20 03:39 11
lgsvl_msgs/VehicleControlData.h

目标点处的切线与全局坐标系的x轴之间的夹角目标航向角double
std::shared_ptrLateralControlError
public:MPCController();~MPCController();void
ComputeLongitudinalErrors(const
QueryNearestPointByPosition(const
全局规划路径中的所有点std::vectorTrajectoryPoint
方向盘的转角到轮胎转动角度之间的比值系数Eigen::MatrixXd
matrix_a_coeff_;Eigen::MatrixXd
steer_single_direction_max_degree_
wheel_single_direction_max_degree_
MPCController::~MPCController()
MPCController::LoadControlConf()
传动比steer_single_direction_max_degree_
方向盘的最大转角角度wheel_single_direction_max_degree_
steer_single_direction_max_degree_
Matrix::Zero(basic_state_size_,
basic_state_size_);matrix_a_(0,
Matrix::Zero(basic_state_size_,
basic_state_size_);matrix_a_coeff_(1,
Matrix::Zero(basic_state_size_,
Matrix::Zero(basic_state_size_,
Matrix::Zero(basic_state_size_,
Matrix::Zero(basic_state_size_,
Matrix::Zero(basic_state_size_,
basic_state_size_);matrix_q_(0,
MPCController::Wheel2SteerPct(const
wheel_single_direction_max_degree_
MPCController::ComputeControlCommand(const
所有轨迹点全局规划器提供的全局路径trajectory_points_
planning_published_trajectory.trajectory_points;//
x_0均为误差量UpdateState(localization);//
解释因为矩阵Ad的计算涉及到车速vx所以每往后走一个时间步都要同步更新一下系统横向动力学模型中的Ad矩阵UpdateMatrix(localization);//
Matrix::Zero(basic_state_size_,
横向误差横向误差变化率航向误差航向误差变化率纵向位置误差纵向速度误差Matrix
lower_state_bound(basic_state_size_,
upper_state_bound(basic_state_size_,
std::numeric_limitsdouble::max();lower_state_bound
control_cmd.at(0);control_matrix(1,
MPCController::UpdateState(const
智能指针std::shared_ptrLateralControlError
std::make_sharedLateralControlError();//
中ComputeErrors(vehicle_state.x,
vehicle_state.angular_velocity,
lat_con_err-lateral_error_rate;
lat_con_err-heading_error_rate;
MPCController::UpdateMatrix(const
std::max(vehicle_state.velocity,
Matrix::Identity(matrix_a_.cols(),
MPCController::ComputeErrors(const
查询距离车辆当前位置最近的路径点作为目标点TrajectoryPoint
std::cos(target_point.heading);const
std::sin(target_point.heading);double
横向误差使用的是车身坐标系和全局坐标系的变换公式计算的double
纵向速度误差lat_con_err-lateral_error
lateral_error;lat_con_err-heading_error
heading_error;lat_con_err-lateral_error_rate
lateral_error_dot;lat_con_err-heading_error_rate
MPCController::QueryNearestPointByPosition(const
PointDistanceSquare(trajectory_points_.front(),
PointDistanceSquare(trajectory_points_[i],
CalculateKernel(std::vectorc_float
CalculateEqualityConstraint(std::vectorc_float
因为这俩都是稀疏矩阵而且很大如果直接存储太消耗资源所以使用列压缩的方式转化为了3个特征数组
定值matrix_initial_x_(matrix_initial_x),
非定值matrix_u_lower_(matrix_u_lower),
定值matrix_u_upper_(matrix_u_upper),
定值matrix_x_lower_(matrix_x_lower),
定值matrix_x_upper_(matrix_x_upper),
定值恒定为0max_iteration_(max_iter),
horizon_(horizon),eps_abs_(eps_abs)
MpcOsqp::CalculateKernel(std::vectorc_float
非零元素值)std::vectorstd::vectorstd::pairc_int,
代表按列columns.resize(num_param_);//
state_total_dim].emplace_back(i
作用用来计数遍历到当前列不包含该列时累计的非零元素的数量int
按列P_indptr-emplace_back(ind_p);for
对P_data-emplace_back(row_data_pair.second);P_indices-emplace_back(row_data_pair.first);ind_p;}}P_indptr-emplace_back(ind_p);
Eigen::VectorXd::Zero(state_dim_
MpcOsqp::CalculateEqualityConstraint(std::vectorc_float
Eigen::MatrixXd::Identity(control_dim_,
Eigen::MatrixXd::Zero(state_dim_
Eigen::MatrixXd::Identity(state_dim_
Eigen::MatrixXd::Identity(num_param_,
num_param_);matrix_constraint.block(state_dim_
表示为按列压缩格式std::vectorstd::vectorstd::pairc_int,
columns;columns.resize(num_param_
(std::fabs(matrix_constraint(j,
{A_indptr-emplace_back(ind_A);for
{A_data-emplace_back(row_data_pair.second);A_indices-emplace_back(row_data_pair.first);ind_A;}}A_indptr-emplace_back(ind_A);
MpcOsqp::CalculateConstraintVectors()
Eigen::MatrixXd::Zero(state_dim_
Eigen::MatrixXd::Zero(state_dim_
{lowerInequality.block(control_dim_
matrix_u_lower_;upperInequality.block(control_dim_
{lowerInequality.block(state_dim_
matrix_x_lower_;upperInequality.block(state_dim_
Eigen::MatrixXd::Zero(state_dim_
upperEquality;lowerEquality.block(0,
matrix_initial_x_;upperEquality
*(c_malloc(sizeof(OSQPSettings)));//
{osqp_set_default_settings(settings);settings-polish
true;settings-scaled_termination
库中的一个结构体用于存储二次规划QP问题的输入数据OSQPData
*(c_malloc(sizeof(OSQPData)));size_t
个特征数组CalculateEqualityConstraint(A_data,
{c_free(data-A);c_free(data-P);c_free(data);
MpcOsqp::Solve(std::vectordouble*
{CalculateGradient();CalculateConstraintVectors();OSQPData*
求解器的工作空间包括定义问题、设置参数、执行求解等功能这里创建了一个名为
求解器的工作空间的函数这个函数的作用是根据传入的数据(data)和设置(settings)来设置和配置
求解器来解决已经设置好的凸二次规划问题osqp_solve(osqp_workspace)
求解器工作空间来执行求解操作osqp_solve(osqp_workspace);//
osqp_workspace-info-status_val;if
{osqp_cleanup(osqp_workspace);FreeData(data);c_free(settings);return
nullptr表示求解器没有成功生成解osqp_cleanup(osqp_workspace);FreeData(data);c_free(settings);return
清理内存osqp_cleanup(osqp_workspace);FreeData(data);c_free(settings);return
ComputePathProfile(std::vectordouble*
dkappas);private:std::vectorstd::pairdouble,
ReferenceLine::ReferenceLine(const
函数作用由于全局路径规划期仅仅给出了全局路径信息即所有点的xy坐标而没有任何关于这条全局路径的其他几何信息如每个路径点的
而我们在局部规划中使用的参考线其实是和全局路径重合的也就是说参考线上的所有路径点就是全局路径的所有路径点
但是要注意我们需要的参考线不能仅仅只有每个路径点的坐标还需要有每个路径点的各个几何信息如
因此我们直接计算全局路径中每个路径点的几何信息然后汇总到一起就是我们需要的参考线信息
ReferenceLine::ComputePathProfile(std::vectordouble*
到达该点时所累积的路径长度起点到该点的几何路径长度kappas-clear();
1].second);}dxs.push_back(x_delta);dys.push_back(y_delta);}//
{headings-push_back(std::atan2(dys[i],
0.0;accumulated_s-push_back(distance);
ny));accumulated_s-push_back(end_segment_s
1));}x_over_s_first_derivatives.push_back(xds);y_over_s_first_derivatives.push_back(yds);}//
1));}x_over_s_second_derivatives.push_back(xdds);y_over_s_second_derivatives.push_back(ydds);}//
x_over_s_first_derivatives[i];double
y_over_s_first_derivatives[i];double
x_over_s_second_derivatives[i];double
y_over_s_second_derivatives[i];double
注2这里对曲率的计算使用的是精确公式而代码中我们在进行动力学建模计算连续误差型状态空间方程的状态量x时如航向误差变化率则是将曲率视为了半径的倒数这是一种对曲率的估算方式kappas-push_back(kappa);}//
1));}dkappas-push_back(dkappa);}return
角速度绕z轴转动的角速度vehicle_state_.angular_velocity
加速度线性加速度vehicle_state_.acceleration
{vehicle_state_.planning_init_x
msg-pose.pose.position.x;vehicle_state_.planning_init_y
msg-pose.pose.position.y;first_record_
msg-pose.pose.position.x;vehicle_state_.y
msg-pose.pose.position.y;vehicle_state_.last_velocity
vehicle_state_.velocity;vehicle_state_.last_v_time
vehicle_state_.cur_v_time;vehicle_state_.last_v_err
类型的变量用于存储姿态信息的四元数表示tf::Quaternion
消息中的姿态信息msg-pose.pose.orientation转换为
库中的四元数表示tf::quaternionMsgToTF(msg-pose.pose.orientation,
的对应成员变量中tf::Matrix3x3(q).getRPY(vehicle_state_.roll,
vehicle_state_.yaw);vehicle_state_.heading
vehicle_state_.yaw;vehicle_state_.velocity
std::sqrt(msg-twist.twist.linear.x
msg-twist.twist.linear.y);vehicle_state_.cur_v_err
infile;infile.open(src/mpc_control/data/reference_line.txt);
将文件流对象与文件连接起来assert(infile.is_open());
若失败则输出错误消息并终止程序运行std::vectorstd::pairdouble,
std::atof(y.c_str());xy_points.push_back(std::make_pair(pt_x,
补全每个参考点的信息当前只有每个参考点的位置坐标std::vectordouble
accumulated_s;std::vectordouble
dkappas;std::unique_ptrshenlan::control::ReferenceLine
std::make_uniqueshenlan::control::ReferenceLine(xy_points);reference_line-ComputePathProfile(headings,
planning_published_trajectory;for
xy_points[i].first;trajectory_pt.y
xy_points[i].second;trajectory_pt.v
headings[i];trajectory_pt.kappa
kappas[i];planning_published_trajectory.trajectory_points.push_back(trajectory_pt);}//
提供的一个宏用于打印消息到ROS的日志系统中这里表示节点初始化完成ROS_INFO(init
条待发布的消息超过这个数量后新的消息将被丢弃ros::Publisher
nh.advertiselgsvl_msgs::VehicleControlData(/vehicle_cmd,
nh.advertiselgsvl_msgs::VehicleControlData(/acc_pub_cmd,
cmd;std::unique_ptrshenlan::control::MPCController
std::make_uniqueshenlan::control::MPCController();mpc_controller-Init();lgsvl_msgs::VehicleControlData
control_cmd;lgsvl_msgs::VehicleControlData
{mpc_controller-ComputeControlCommand(vehicle_state_,
endl;control_cmd.acceleration_pct
cmd.acc;control_cmd.target_gear
lgsvl_msgs::VehicleControlData::GEAR_DRIVE;control_cmd.target_wheel_angle
-cmd.steer_target;control_pub.publish(control_cmd);control_cmd_pub.acceleration_pct
vehicle_state_.acceleration;acc_pub.publish(control_cmd_pub);ros::spinOnce();loop_rate.sleep();}return
作为专业的SEO优化服务提供商,我们致力于通过科学、系统的搜索引擎优化策略,帮助企业在百度、Google等搜索引擎中获得更高的排名和流量。我们的服务涵盖网站结构优化、内容优化、技术SEO和链接建设等多个维度。
| 服务项目 | 基础套餐 | 标准套餐 | 高级定制 |
|---|---|---|---|
| 关键词优化数量 | 10-20个核心词 | 30-50个核心词+长尾词 | 80-150个全方位覆盖 |
| 内容优化 | 基础页面优化 | 全站内容优化+每月5篇原创 | 个性化内容策略+每月15篇原创 |
| 技术SEO | 基本技术检查 | 全面技术优化+移动适配 | 深度技术重构+性能优化 |
| 外链建设 | 每月5-10条 | 每月20-30条高质量外链 | 每月50+条多渠道外链 |
| 数据报告 | 月度基础报告 | 双周详细报告+分析 | 每周深度报告+策略调整 |
| 效果保障 | 3-6个月见效 | 2-4个月见效 | 1-3个月快速见效 |
我们的SEO优化服务遵循科学严谨的流程,确保每一步都基于数据分析和行业最佳实践:
全面检测网站技术问题、内容质量、竞争对手情况,制定个性化优化方案。
基于用户搜索意图和商业目标,制定全面的关键词矩阵和布局策略。
解决网站技术问题,优化网站结构,提升页面速度和移动端体验。
创作高质量原创内容,优化现有页面,建立内容更新机制。
获取高质量外部链接,建立品牌在线影响力,提升网站权威度。
持续监控排名、流量和转化数据,根据效果调整优化策略。
基于我们服务的客户数据统计,平均优化效果如下:
我们坚信,真正的SEO优化不仅仅是追求排名,而是通过提供优质内容、优化用户体验、建立网站权威,最终实现可持续的业务增长。我们的目标是与客户建立长期合作关系,共同成长。
Demand feedback