Apollo控制算法深入解析:LQR最优控制

需积分: 5 30 下载量 199 浏览量 更新于2024-08-05 收藏 843KB PDF 举报
"这篇文档详细介绍了Apollo控制算法中的LQR(Linear Quadratic Regulator),这是一种在自动驾驶领域广泛应用的控制策略。作者是社区开发者卜大鹏,他深入浅出地阐述了LQR的基本理论和推导过程,特别是如何应用于Apollo系统的横向控制。" LQR理论是一种在控制系统设计中广泛使用的最优控制方法,它源于现代控制理论,尤其适用于状态空间表示的线性系统。LQR的目标是找到一个最优的状态反馈控制器,以最小化一个二次型的性能指标,通常表现为系统的状态偏差和控制输入的能量之和。这一最优控制策略能够确保系统的稳定性,并且使得控制代价尽可能小。 在自动驾驶场景中,LQR被用于精确地控制车辆的行驶方向,这包括对横向误差、横向误差变化率、朝向误差以及朝向误差变化率的控制。这些状态变量构成了状态集合X,而车辆可以通过调整转向、加速和制动等控制输入U来影响这些状态。 LQR的设计涉及到权矩阵Q和R的选择,它们分别对应于状态误差和控制输入的权重。Q矩阵决定了系统对状态偏离期望值的敏感程度,R矩阵则反映了对控制输入大小的惩罚。通过调整这两个矩阵,设计师可以平衡控制精度和控制成本。 文档中提到的离散线性系统是LQR理论的基础,其目标是找到一个控制序列,使得系统的状态能以最小的代价转移到期望的最终状态。代价函数J包含了状态x和控制u的二次项,以及到达最终状态的控制序列的总代价。通过对J进行优化,可以找到最佳的控制策略。 动态规划算法在这里发挥了关键作用,通过反向传播的方式,从最终状态开始向前计算每个时间步的最优控制。这涉及到一个递推关系,即当前最优控制的确定依赖于下一个时间步的最优控制。这个关系可以表示为动态规划的Bellman方程,从而将原问题转化为一系列子问题,逐步求解最优控制序列。 通过计算代价函数J的梯度并使其等于零,可以解出控制输入的最优值,这通常是通过求解黎卡提方程来实现的。黎卡提方程是一个与状态空间模型相关的线性常微分方程,它的解可以给出最优控制律的系数矩阵K。 总而言之,Apollo控制算法中的LQR策略是一个精心设计的状态反馈控制方案,它利用现代控制理论中的最优控制原理,结合动态规划方法,以最小化总体成本为目标,实现对自动驾驶车辆的精确控制。这一策略不仅考虑了系统的稳定性,还兼顾了控制效率,是自动驾驶技术中的核心算法之一。

root@in_dev_docker:/apollo# bash scripts/msf_create_lossless_map.sh /apollo/hdmap/pcd_apollo/ 50 /apollo/hdmap/ /apollo/bazel-bin WARNING: Logging before InitGoogleLogging() is written to STDERR E0715 22:08:35.399576 6436 lossless_map_creator.cc:162] num_trials = 1 Pcd folders are as follows: /apollo/hdmap/pcd_apollo/ Resolution: 0.125 Dataset: /apollo/hdmap/pcd_apollo Dataset: /apollo/hdmap/pcd_apollo/ Loaded the map configuration from: /apollo/hdmap//lossless_map/config.xml. Saved the map configuration to: /apollo/hdmap//lossless_map/config.xml. Saved the map configuration to: /apollo/hdmap//lossless_map/config.xml. E0715 22:08:35.767315 6436 lossless_map_creator.cc:264] ieout_poses = 1706 Failed to find match for field 'intensity'. Failed to find match for field 'timestamp'. E0715 22:08:35.769896 6436 velodyne_utility.cc:46] Un-organized-point-cloud E0715 22:08:35.781770 6436 lossless_map_creator.cc:275] Loaded 245443D Points at Trial: 0 Frame: 0. F0715 22:08:35.781791 6436 base_map_node_index.cc:101] Check failed: false *** Check failure stack trace: *** scripts/msf_create_lossless_map.sh: line 11: 6436 Aborted (core dumped) $APOLLO_BIN_PREFIX/modules/localization/msf/local_tool/map_creation/lossless_map_creator --use_plane_inliers_only true --pcd_folders $1 --pose_files $2 --map_folder $IN_FOLDER --zone_id $ZONE_ID --coordinate_type UTM --map_resolution_type single root@in_dev_docker:/apollo# bash scripts/msf_create_lossless_map.sh /apollo/hdmap/pcd_apollo/ 50 /apollo/hdmap/

2023-07-16 上传

def main(args, rest_args): cfg = Config(path=args.cfg) model = cfg.model model.eval() if args.quant_config: quant_config = get_qat_config(args.quant_config) cfg.model.build_slim_model(quant_config['quant_config']) if args.model is not None: load_pretrained_model(model, args.model) arg_dict = {} if not hasattr(model.export, 'arg_dict') else model.export.arg_dict args = parse_model_args(arg_dict) kwargs = {key[2:]: getattr(args, key[2:]) for key in arg_dict} model.export(args.save_dir, name=args.save_name, **kwargs) if args.export_for_apollo: if not isinstance(model, BaseDetectionModel): logger.error('Model {} does not support Apollo yet!'.format( model.class.name)) else: generate_apollo_deploy_file(cfg, args.save_dir) if name == 'main': args, rest_args = parse_normal_args() main(args, rest_args)这段代码中哪几句代码是def main(args, rest_args): cfg = Config(path=args.cfg) model = cfg.model model.eval() if args.quant_config: quant_config = get_qat_config(args.quant_config) cfg.model.build_slim_model(quant_config['quant_config']) if args.model is not None: load_pretrained_model(model, args.model) arg_dict = {} if not hasattr(model.export, 'arg_dict') else model.export.arg_dict args = parse_model_args(arg_dict) kwargs = {key[2:]: getattr(args, key[2:]) for key in arg_dict} model.export(args.save_dir, name=args.save_name, **kwargs) if args.export_for_apollo: if not isinstance(model, BaseDetectionModel): logger.error('Model {} does not support Apollo yet!'.format( model.class.name)) else: generate_apollo_deploy_file(cfg, args.save_dir) if name == 'main': args, rest_args = parse_normal_args() main(args, rest_args)这段代码中哪几句代码是def main(args, rest_args): cfg = Config(path=args.cfg) model = cfg.model model.eval() if args.quant_config: quant_config = get_qat_config(args.quant_config) cfg.model.build_slim_model(quant_config['quant_config']) if args.model is not None: load_pretrained_model(model, args.model) arg_dict = {} if not hasattr(model.export, 'arg_dict') else model.export.arg_dict args = parse_model_args(arg_dict) kwargs = {key[2:]: getattr(args, key[2:]) for key in arg_dict} model.export(args.save_dir, name=args.save_name, **kwargs) if args.export_for_apollo: if not isinstance(model, BaseDetectionModel): logger.error('Model {} does not support Apollo yet!'.format( model.class.name)) else: generate_apollo_deploy_file(cfg, args.save_dir) if name == 'main': args, rest_args = parse_normal_args() main(args, rest_args)这段代码中哪几句是将训练时保存的动态图模型文件导出成推理引擎能够加载的静态图模型文件

2023-05-28 上传
2023-07-16 上传
2023-06-08 上传

In file included from /home/acceler/code/apollo_ros/apollo_ros/src/apollo.ros-1.0.0-master/apollo_common/include/apollo_common/apollo_app.h:46:0, from /home/acceler/code/apollo_ros/apollo_ros/src/apollo.ros-1.0.0-master/apollo_common/src/apollo_app.cc:33: /home/acceler/code/apollo_ros/apollo_ros/src/apollo.ros-1.0.0-master/apollo_common/include/apollo_common/log.h:40:10: fatal error: glog/logging.h: No such file or directory #include <glog/logging.h> ^~~~~~~~~~~~~~~~ compilation terminated. apollo.ros-1.0.0-master/apollo_common/CMakeFiles/apollo_common.dir/build.make:62: recipe for target 'apollo.ros-1.0.0-master/apollo_common/CMakeFiles/apollo_common.dir/src/apollo_app.cc.o' failed make[2]: *** [apollo.ros-1.0.0-master/apollo_common/CMakeFiles/apollo_common.dir/src/apollo_app.cc.o] Error 1 make[2]: *** Waiting for unfinished jobs.... In file included from /home/acceler/code/apollo_ros/apollo_ros/src/apollo.ros-1.0.0-master/apollo_common/include/apollo_common/adapters/adapter_manager.h:48:0, from /home/acceler/code/apollo_ros/apollo_ros/src/apollo.ros-1.0.0-master/apollo_common/src/adapters/adapter_manager.cc:33: /home/acceler/code/apollo_ros/apollo_ros/src/apollo.ros-1.0.0-master/apollo_common/include/apollo_common/adapters/adapter.h:49:10: fatal error: glog/logging.h: No such file or directory #include <glog/logging.h> ^~~~~~~~~~~~~~~~ compilation terminated. apollo.ros-1.0.0-master/apollo_common/CMakeFiles/apollo_common.dir/build.make:110: recipe for target 'apollo.ros-1.0.0-master/apollo_common/CMakeFiles/apollo_common.dir/src/adapters/adapter_manager.cc.o' failed make[2]: *** [apollo.ros-1.0.0-master/apollo_common/CMakeFiles/apollo_common.dir/src/adapters/adapter_manager.cc.o] Error 1 CMakeFiles/Makefile2:3894: recipe for target 'apollo.ros-1.0.0-master/apollo_common/CMakeFiles/apollo_common.dir/all' failed make[1]: *** [apollo.ros-1.0.0-master/apollo_common/CMakeFiles/apollo_common.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... [ 54%] Linking CXX executable /home/acceler/code/apollo_ros/apollo_ros/devel/lib/IntegratedNavigation/IntegratedNavigation_node [ 54%] Built target IntegratedNavigation_node [ 55%] Linking CXX executable /home/acceler/code/apollo_ros/apollo_ros/devel/lib/TimeSynchronierProcess/timeSynchronierProcess_node [ 55%] Built target timeSynchronierProcess_node Makefile:140: recipe for target 'all' failed make: *** [all] Error 2 Invoking "make -j4 -l4" failed

2023-07-23 上传