Apollo代码学习:MPC与LQR控制器比较分析

5星 · 超过95%的资源 需积分: 5 62 下载量 2 浏览量 更新于2024-08-05 5 收藏 1.15MB PDF 举报
"这篇文档是关于开发者在Apollo项目中对MPC(模型预测控制)与LQR(线性二次调节器)两种控制策略的比较分析。作者吕伊鹏通过探讨这两种控制方法在自动驾驶领域的应用,深入浅出地阐述了它们的异同点,旨在为学习者提供帮助。文档引用了多部专业书籍和在线资源作为参考,涵盖了正定矩阵、车辆运动学模型、对角矩阵和半正定矩阵等关键概念。" 在自动驾驶领域,控制算法的选择对于系统的性能至关重要。LQR和MPC都是控制理论中的重要组成部分,但它们的应用场景和优化目标有所不同。 LQR(线性二次调节器)是一种经典的状态反馈控制器设计方法,适用于线性系统。它基于状态空间模型,通过最小化一个二次型的目标函数来寻求最优控制输入。该目标函数包含了两个权矩阵Q和R,分别对应状态误差和控制输入的权重,以平衡控制性能和输入力度。LQR的优势在于其简单且易于实现,能提供全局最优解,但它的决策仅基于当前状态,不考虑未来的影响。 相比之下,MPC(模型预测控制)则更注重未来的状态预测和优化。MPC在每次迭代时都会预测系统在未来一段时间内的行为,考虑到状态和控制输入的约束,然后求解一段有限时间内的最优控制序列。尽管MPC在计算上比LQR复杂,但它可以处理非线性系统,并能更好地应对动态环境和约束条件。 在Apollo项目中,MPC和LQR都用作控制器,但它们在状态方程、状态变量和目标函数的定义上存在共通性。例如,两者都需要车辆运动学模型来描述系统的动态行为。然而,MPC的优化目标通常不仅限于当前时刻,而是考虑整个预测时间段内的性能,这使得MPC在处理延迟、预测未来行为以及应对不确定性方面更具优势。 在实际应用中,选择LQR还是MPC往往取决于具体任务的需求。LQR适用于系统简单、实时性要求高的情况,而MPC则适合那些需要预见性控制和复杂约束条件的系统。通过比较这两种方法,开发者可以根据项目特点和需求来优化控制系统的设计。 总结来说,LQR和MPC都是控制理论的重要工具,它们在自动驾驶中发挥着关键作用。LQR以其简洁和效率见长,而MPC则以其前瞻性和灵活性著称。理解这两种方法的原理和差异,对于开发高效、可靠的自动驾驶系统至关重要。

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 上传

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 上传

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 上传