Apollo CyberRT调度器:实时并行计算的关键

需积分: 5 15 下载量 157 浏览量 更新于2024-08-05 收藏 1.28MB PDF 举报
"Apollo Cyber调度器是百度Apollo自动驾驶平台中的关键组件,主要负责计算任务的实时并行处理。它作为一个独立的模块,是Apollo CyberRT框架的核心,将原本需要在内核空间进行的调度工作转移到了用户空间,简化了算法开发者的任务,使他们能够专注于算法本身的实现,而无需关注并发控制、同步以及资源调度等底层细节。 CyberRT Scheduler的设计特点包括: 1. 绑定线程与CPU:通过pthread_setschedparam和pthread_setaffinity_np等接口,Scheduler能够将Native Thread绑定到特定的CPU核心上,实现Per-CPU Per-Thread,优化性能。 2. Processor概念:在CyberRT中,封装了Native Thread的类被称为Processor,它类似操作系统的物理CPU。 3. 上下文切换:CyberRT Scheduler利用栈上下文切换,使得由上层空间创建的Coroutine(协程)能够在Processor上按序执行,类似于内核调度线程到CPU。 4. Run Queue设计:借鉴内核调度器的Run Queue Per-Processor模式,CyberRT Scheduler也采用了相似的设计,能够针对各个Processor进行调度。 新调度模型的优势在于可以根据自动驾驶算法任务的特性进行定制化资源分配和优先级设置。例如,算法任务可以构成有向无环图(DAG),调度器可以将有依赖关系的任务安排在同一个或相邻的CPU上,提高缓存局部性,减少通信延迟,从而提升整体计算效率和系统响应速度。 Apollo Cyber调度器的这种设计方法不仅提高了计算任务的并行执行效率,还降低了系统复杂性,对于实现高效、可靠的自动驾驶系统至关重要。通过这种方式,开发者能够更加专注于自动驾驶的核心算法,而无需担忧底层的系统优化问题,这极大地推动了自动驾驶技术的研发进程。"

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/

189 浏览量
192 浏览量

在ros项目中添加发送websocket wss消息的功能,修改如下代码并在CmakeLists.txt中添加依赖,实现将serialized_data发送到wss://autopilot-test.t3go.cn:443/api/v1/vehicle/push/message/LFB1FV696M2L43840。main.cpp:#include "ros/ros.h" #include "std_msgs/String.h" #include <boost/thread/locks.hpp> #include <boost/thread/shared_mutex.hpp> #include "third_party/apollo/proto/perception/perception_obstacle.pb.h" #include "t3_perception.pb.h" apollo::perception::PerceptionObstacles perception_obstacles_; void perceptionCallback(const std_msgs::String& msg) { ROS_WARN("t3 perceptionCallback parse"); if (perception_obstacles_.ParseFromString(msg.data)) { double timestamp = perception_obstacles_.header().timestamp_sec(); ROS_INFO("t3 perceptionCallback timestamp %f count:%d", timestamp, perception_obstacles_.perception_obstacle().size()); std::string data; perception_obstacles_.SerializeToString(&data); VehData veh_data; veh_data.set_messagetype(5); veh_data.set_messagedes("PerceptionObstacles"); veh_data.set_contents(data); std::string serialized_data; veh_data.SerializeToString(&serialized_data); } else { ROS_ERROR("t3 perceptionCallback parse fail!"); } } int main(int argc, char **argv) { ros::init(argc, argv, "listener"); ros::NodeHandle n; ros::Subscriber sub = n.subscribe("/perception_node/perception_objects", 1000, perceptionCallback); ros::spin(); return 0; }CMakeLists.txt:cmake_minimum_required(VERSION 3.0.2) project(t3) find_package(catkin REQUIRED COMPONENTS roscpp rospy pcl_ros std_msgs third_party ) find_package(Protobuf REQUIRED) include_directories(${Protobuf_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}/..) find_package(Boost REQUIRED) include_directories(${Boost_INCLUDE_DIRS}) set(ixwebsocket_INCLUDE_DIR "/usr/local/include/ixwebsocket") set(ixwebsocket_LIBRARIES "/usr/local/lib/libixwebsocket.a") include_directories(${ixwebsocket_INCLUDE_DIR}) include_directories(${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_INCLUDE_DESTINATION}/${PROJECT_NAME}) include_directories(${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_INCLUDE_DESTINATION}/smartview) catkin_package(INCLUDE_DIRS ${PROJECT_INCLUDE_DIRS} DEPENDS ${GFLAGS_LIBRARIES} ) include_directories( ${catkin_INCLUDE_DIRS} ${PROTOBUF_INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/.. ) add_executable(${PROJECT_NAME}_node src/main.cpp ) add_dependencies(${PROJECT_NAME}_node ${catkin_EXPORTED_TARGETS}) target_link_libraries(${PROJECT_NAME}_node ${catkin_LIBRARIES} ${PROTOBUF_LIBRARIES} smartview_proto ) install(TARGETS ${PROJECT_NAME}_node ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} )

116 浏览量

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)这段代码中哪几句是将训练时保存的动态图模型文件导出成推理引擎能够加载的静态图模型文件

158 浏览量
162 浏览量