boost解析io转换成为imu_msgs

本文介绍如何使用SYDDynamics的9轴AHRS通过串口连接Ubuntu系统,并发布sensor_msgs/Imu类型消息。文中详细展示了C++代码实现过程,包括串口配置、请求四元数数据、发布ROS话题等步骤。
下面使用SYD Dynamics的9轴AHRS( Attitude and heading reference system),来发布sensor_msgs/Imu类型的消息。

   将传感器用USB转串口接到Ubuntu系统上,可以用如下命令查看串口信息:

ls -l /dev/tty*

   查询出串口名为“/dev/ttyUSB0”。根据官方给的传感器程序源文件和boost::asio库来实现串口发送request指令,并读取传感器返回的四元数信息。之后将其发送到/IMU_data的话题上:

复制代码
// Step 1:  Include Library Headers:
#include "EasyObjectDictionary.h"
#include "EasyProfile.h"

#include <ros/ros.h> 
#include <sensor_msgs/Imu.h>

#include <boost/asio.hpp>         // 包含boost库函数
#include <boost/bind.hpp>
using namespace boost::asio;  


int main(int argc, char** argv)
{
    // Step 2: Initialization:
    EasyProfile_C_Interface_Init();

    ros::init(argc, argv, "imu");     
    ros::NodeHandle n;  

    ros::Publisher IMU_pub = n.advertise<sensor_msgs::Imu>("IMU_data", 20);  

    io_service io;
    serial_port sp(io, "/dev/ttyUSB0");         // 定义传输的串口
    sp.set_option(serial_port::baud_rate(115200));                                  // 波特率
    sp.set_option(  serial_port::flow_control( serial_port::flow_control::none ) ); // 流量控制
    sp.set_option(  serial_port::parity( serial_port::parity::none ) );             // 奇偶校验
    sp.set_option( serial_port::stop_bits(  serial_port::stop_bits::one ) );        // 停止位
    sp.set_option(  serial_port::character_size( 8 ) );                             // 数据位

    ros::Rate loop_rate(50);  
    while(ros::ok())
    {
        // Step 3 and Step 4 are optional, only if you want to use the request-response communication pattern
        // Step 3: Request quaternion Data from TransdcuerM 
        uint16 toId = 309; // Node ID
        char*  txData;
        int    txSize;
        if(EP_SUCC_ == EasyProfile_C_Interface_TX_Request(toId, EP_CMD_Q_S1_E_, &txData, &txSize))
        {
            write(sp, buffer(txData, txSize));    // Step 4:  Send the request via Serial Port.
        } 

        char rxData[100];  
        boost::system::error_code err;  

        sp.read_some(buffer(rxData, 50),err);  // Read from serial port buffer
        if (err)  
        {  
            ROS_INFO("Serial port read_some Error!");  
            return -1;  
        }  

        Ep_Header header;                       // Then let the EasyProfile do the rest such as data assembling and checksum verification.
        if( EP_SUCC_ == EasyProfile_C_Interface_RX((char*)rxData, 50, &header))
        {
            // Quanternion received
            unsigned int timeStamp = ep_Q_s1_e.timeStamp;
            float q1 = ep_Q_s1_e.q[0];              // Note 1, ep_Q_s1_e is defined in the EasyProfile library as a global variable
            float q2 = ep_Q_s1_e.q[1];              // Note 2, for the units and meaning of each value, refer to EasyObjectDictionary.h
            float q3 = ep_Q_s1_e.q[2];
            float q4 = ep_Q_s1_e.q[3];
            ROS_INFO("Q: %f %f %f %f\n", q1, q2, q3, q4);

            sensor_msgs::Imu imu_data;
            imu_data.header.stamp = ros::Time::now();
            imu_data.header.frame_id = "base_link";
            imu_data.orientation.x = q3;
            imu_data.orientation.y = -q2;
            imu_data.orientation.z = -q1;
            imu_data.orientation.w = q4;

            IMU_pub.publish(imu_data);
        }

        io.run();  
        ros::spinOnce();  
        loop_rate.sleep();  
    }

    return 0;
}
复制代码

   在CMakeLists中添加:

add_compile_options(-std=c99)

aux_source_directory(./src  DIR_SRCS)
add_executable(imu   ${DIR_SRCS} )
target_link_libraries(imu  ${catkin_LIBRARIES})

  使用catkin_make编译后,source ./devel/setup.bash,然后运行rosrun imu imu。这时可能会出现无法打开串口的错误,给串口添加权限后再次运行: 

sudo chmod 666 /dev/ttyUSB0

   无问题后可以输入下面的指令查看话题,转动IMU可以看到orientation的四个分量一直在变化:

rostopic  echo  /IMU_data

 

   为了更形象的显示IMU姿态,可以下载rviz_imu_plugin插件并安装。The rviz_imu_plugin package is used to display sensor_msgs/Imu messages in rviz. Once you download and compile the package, it should be visible as a plugin. It displays the orientation of the IMU using a box as well as and coordinate axes. The acceleration can be visualized using a vector.

  Make sure you have git installed:

sudo apt-get install git-core

  Download the stack from our repository into your catkin workspace

git clone -b indigo https://github.com/ccny-ros-pkg/imu_tools.git

  Compile the stack:

cd ~/catkin_ws
catkin_make

   装好后打开rviz,可以看到rviz_imu_plugin与rviz中默认自带的rviz_plugin_tutorials并不一样:

   在rviz_imu_plugin下添加imu,修改Fixed Frame为base_link,IMU下面的Topic选为/IMU_data,转动IMU rviz中的虚拟立方体和坐标轴会跟着转动(可以更改box三个方向尺寸的比例):

 

参考:

IMU tools for ROS

CMake 入门实战

ROS Qt Creator Plug-in wiki

ROS下IMU串口通讯接口(通用版)

如何使用Qt插件在Qt中进行ROS开发

如何用Qt对ROS项目进行调试及创建GUI界面

Serial Cross-platform, Serial Port library written in C++

zy@zy-Lenovo-Legion-R7000P2020H:~/autoware$ colcon build --symlink-install \ --cmake-args \ -DCMAKE_BUILD_TYPE=Release \ -DCUDAToolkit_ROOT=/usr/local/cuda-12.4 \ -DCMAKE_CUDA_COMPILER=/usr/local/cuda-12.4/bin/nvcc \ --continue-on-error \ --allow-overriding can_msgs Starting >>> autoware_lint_common Starting >>> autoware_planning_msgs Starting >>> autoware_simple_object_merger --- stderr: autoware_probabilistic_occupancy_grid_map In this package, headers install destination is set to `include` by ament_auto_package. It is recommended to install `include/autoware_probabilistic_occupancy_grid_map` instead and will be the default behavior of ament_auto_package from ROS 2 Kilted Kaiju. On distributions before Kilted, ament_auto_package behaves the same way when you use USE_SCOPED_HEADER_INSTALL_DIR option. CMake Warning: Manually-specified variables were not used by the project: CMAKE_CUDA_COMPILER CUDAToolkit_ROOT /usr/bin/ccache: invalid option -- 'E' nvcc fatal : Failed to preprocess host compiler properties. CMake Error at autoware_probabilistic_occupancy_grid_map_cuda_generated_utils_kernel.cu.o.Release.cmake:220 (message): Error generating /home/zy/autoware/build/autoware_probabilistic_occupancy_grid_map/CMakeFiles/autoware_probabilistic_occupancy_grid_map_cuda.dir/lib/utils/./autoware_probabilistic_occupancy_grid_map_cuda_generated_utils_kernel.cu.o gmake[2]: *** [CMakeFiles/autoware_probabilistic_occupancy_grid_map_cuda.dir/build.make:105:CMakeFiles/autoware_probabilistic_occupancy_grid_map_cuda.dir/lib/utils/autoware_probabilistic_occupancy_grid_map_cuda_generated_utils_kernel.cu.o] 错误 1 gmake[1]: *** [CMakeFiles/Makefile2:150:CMakeFiles/autoware_probabilistic_occupancy_grid_map_cuda.dir/all] 错误 2 gmake: *** [Makefile:146:all] 错误 2 --- Failed <<< autoware_probabilistic_occupancy_grid_map [29.1s, exited with code 2] Starting >>> autoware_pid_longitudinal_controller --- stderr: autoware_lidar_transfusion In this package, headers install destination is set to `include` by ament_auto_package. It is recommended to install `include/autoware_lidar_transfusion` instead and will be the default behavior of ament_auto_package from ROS 2 Kilted Kaiju. On distributions before Kilted, ament_auto_package behaves the same way when you use USE_SCOPED_HEADER_INSTALL_DIR option. sh: 1: cicc: not found CMake Error at autoware_lidar_transfusion_cuda_lib_generated_preprocess_kernel.cu.o.Release.cmake:280 (message): Error generating file /home/zy/autoware/build/autoware_lidar_transfusion/CMakeFiles/autoware_lidar_transfusion_cuda_lib.dir/lib/preprocess/./autoware_lidar_transfusion_cuda_lib_generated_preprocess_kernel.cu.o gmake[2]: *** [CMakeFiles/autoware_lidar_transfusion_cuda_lib.dir/build.make:411:CMakeFiles/autoware_lidar_transfusion_cuda_lib.dir/lib/preprocess/autoware_lidar_transfusion_cuda_lib_generated_preprocess_kernel.cu.o] 错误 1 gmake[1]: *** [CMakeFiles/Makefile2:192:CMakeFiles/autoware_lidar_transfusion_cuda_lib.dir/all] 错误 2 gmake: *** [Makefile:146:all] 错误 2 --- Failed <<< autoware_lidar_transfusion [34.7s, exited with code 2] Starting >>> autoware_pure_pursuit --- stderr: autoware_planning_validator In this package, headers install destination is set to `include` by ament_auto_package. It is recommended to install `include/autoware_planning_validator` instead and will be the default behavior of ament_auto_package from ROS 2 Kilted Kaiju. On distributions before Kilted, ament_auto_package behaves the same way when you use USE_SCOPED_HEADER_INSTALL_DIR option. CMake Warning: Manually-specified variables were not used by the project: CMAKE_CUDA_COMPILER CUDAToolkit_ROOT /usr/bin/ld: CMakeFiles/test_autoware_planning_validator.dir/test/src/test_planning_validator_functions.cpp.o: in function `PlanningValidatorTestSuite_checkValidFiniteValueFunction_Test::TestBody()': test_planning_validator_functions.cpp:(.text+0xa4): undefined reference to `autoware::planning_validator::PlanningValidator::PlanningValidator(rclcpp::NodeOptions const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0xf0): undefined reference to `autoware::planning_validator::PlanningValidator::checkValidFiniteValue(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0x120): undefined reference to `autoware::planning_validator::PlanningValidator::checkValidFiniteValue(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0x153): undefined reference to `autoware::planning_validator::PlanningValidator::checkValidFiniteValue(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&)' /usr/bin/ld: CMakeFiles/test_autoware_planning_validator.dir/test/src/test_planning_validator_functions.cpp.o: in function `PlanningValidatorTestSuite_checkValidIntervalFunction_Test::TestBody()': test_planning_validator_functions.cpp:(.text+0x4f9): undefined reference to `autoware::planning_validator::PlanningValidator::PlanningValidator(rclcpp::NodeOptions const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0x549): undefined reference to `autoware::planning_validator::PlanningValidator::checkValidInterval(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0x59b): undefined reference to `autoware::planning_validator::PlanningValidator::checkValidInterval(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0x5e0): undefined reference to `autoware::planning_validator::PlanningValidator::checkValidInterval(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0x638): undefined reference to `autoware::planning_validator::PlanningValidator::checkValidInterval(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&)' /usr/bin/ld: CMakeFiles/test_autoware_planning_validator.dir/test/src/test_planning_validator_functions.cpp.o: in function `PlanningValidatorTestSuite_checkValidCurvatureFunction_Test::TestBody()': test_planning_validator_functions.cpp:(.text+0xb24): undefined reference to `autoware::planning_validator::PlanningValidator::PlanningValidator(rclcpp::NodeOptions const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0xb70): undefined reference to `autoware::planning_validator::PlanningValidator::checkValidCurvature(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&)' /usr/bin/ld: CMakeFiles/test_autoware_planning_validator.dir/test/src/test_planning_validator_functions.cpp.o: in function `PlanningValidatorTestSuite_checkValidRelativeAngleFunction_Test::TestBody()': test_planning_validator_functions.cpp:(.text+0xde7): undefined reference to `autoware::planning_validator::PlanningValidator::PlanningValidator(rclcpp::NodeOptions const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0xe64): undefined reference to `autoware::planning_validator::PlanningValidator::checkValidRelativeAngle(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0xec5): undefined reference to `autoware::planning_validator::PlanningValidator::checkValidRelativeAngle(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0xf28): undefined reference to `autoware::planning_validator::PlanningValidator::checkValidRelativeAngle(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0xfef): undefined reference to `autoware::planning_validator::PlanningValidator::checkValidRelativeAngle(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&)' /usr/bin/ld: CMakeFiles/test_autoware_planning_validator.dir/test/src/test_planning_validator_functions.cpp.o: in function `PlanningValidatorTestSuite_checkValidLateralJerkFunction_Test::TestBody()': test_planning_validator_functions.cpp:(.text+0x14b9): undefined reference to `autoware::planning_validator::PlanningValidator::PlanningValidator(rclcpp::NodeOptions const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0x150a): undefined reference to `autoware::planning_validator::PlanningValidator::checkValidLateralJerk(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0x15ea): undefined reference to `autoware::planning_validator::PlanningValidator::checkValidLateralJerk(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0x1662): undefined reference to `autoware::planning_validator::PlanningValidator::checkValidLateralJerk(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0x17f5): undefined reference to `autoware::planning_validator::PlanningValidator::checkValidLateralJerk(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&)' /usr/bin/ld: CMakeFiles/test_autoware_planning_validator.dir/test/src/test_planning_validator_functions.cpp.o: in function `PlanningValidatorTestSuite_checkTrajectoryShiftFunction_Test::TestBody()': test_planning_validator_functions.cpp:(.text+0x1d2b): undefined reference to `autoware::planning_validator::PlanningValidator::PlanningValidator(rclcpp::NodeOptions const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0x1dda): undefined reference to `autoware::planning_validator::PlanningValidator::checkTrajectoryShift(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&, autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&, geometry_msgs::msg::Pose_<std::allocator<void> > const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0x1e2a): undefined reference to `autoware::planning_validator::PlanningValidator::checkTrajectoryShift(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&, autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&, geometry_msgs::msg::Pose_<std::allocator<void> > const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0x1e77): undefined reference to `autoware::planning_validator::PlanningValidator::checkTrajectoryShift(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&, autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&, geometry_msgs::msg::Pose_<std::allocator<void> > const&)' /usr/bin/ld: test_planning_validator_functions.cpp:(.text+0x1ec6): undefined reference to `autoware::planning_validator::PlanningValidator::checkTrajectoryShift(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&, autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&, geometry_msgs::msg::Pose_<std::allocator<void> > const&)' /usr/bin/ld: CMakeFiles/test_autoware_planning_validator.dir/test/src/test_planning_validator_pubsub.cpp.o: in function `prepareTest(autoware_planning_msgs::msg::Trajectory_<std::allocator<void> > const&, nav_msgs::msg::Odometry_<std::allocator<void> > const&, geometry_msgs::msg::AccelWithCovarianceStamped_<std::allocator<void> > const&)': test_planning_validator_pubsub.cpp:(.text+0x3164): undefined reference to `autoware::planning_validator::PlanningValidator::PlanningValidator(rclcpp::NodeOptions const&)' /usr/bin/ld: CMakeFiles/test_autoware_planning_validator.dir/test/src/test_planning_validator_node_interface.cpp.o: in function `generateNode()': test_planning_validator_node_interface.cpp:(.text+0x14d5): undefined reference to `autoware::planning_validator::PlanningValidator::PlanningValidator(rclcpp::NodeOptions const&)' collect2: error: ld returned 1 exit status gmake[2]: *** [CMakeFiles/test_autoware_planning_validator.dir/build.make:736:test_autoware_planning_validator] 错误 1 gmake[1]: *** [CMakeFiles/Makefile2:761:CMakeFiles/test_autoware_planning_validator.dir/all] 错误 2 gmake: *** [Makefile:146:all] 错误 2 --- Failed <<< autoware_planning_validator [54.8s, exited with code 2] Summary: 400 packages finished [12min 14s] 13 packages failed: autoware_behavior_path_goal_planner_module autoware_costmap_generator autoware_cuda_pointcloud_preprocessor autoware_dummy_perception_publisher autoware_lidar_centerpoint autoware_lidar_transfusion autoware_obstacle_cruise_planner autoware_planning_validator autoware_probabilistic_occupancy_grid_map autoware_tensorrt_plugins autoware_tensorrt_yolox bevdet_vendor trt_batched_nms 393 packages had stderr output: agnocast_e2e_test agnocast_ioctl_wrapper agnocast_sample_application agnocast_sample_interfaces agnocastlib astra_camera astra_camera_msgs autoware_accel_brake_map_calibrator autoware_adapi_adaptors autoware_adapi_specs autoware_adapi_v1_msgs autoware_adapi_version_msgs autoware_agnocast_wrapper autoware_ar_tag_based_localizer autoware_auto_common autoware_automatic_pose_initializer autoware_autonomous_emergency_braking autoware_bag_time_manager_rviz_plugin autoware_behavior_path_avoidance_by_lane_change_module autoware_behavior_path_dynamic_obstacle_avoidance_module autoware_behavior_path_external_request_lane_change_module autoware_behavior_path_goal_planner_module autoware_behavior_path_lane_change_module autoware_behavior_path_planner autoware_behavior_path_planner_common autoware_behavior_path_sampling_planner_module autoware_behavior_path_side_shift_module autoware_behavior_path_start_planner_module autoware_behavior_path_static_obstacle_avoidance_module autoware_behavior_velocity_blind_spot_module autoware_behavior_velocity_crosswalk_module autoware_behavior_velocity_detection_area_module autoware_behavior_velocity_intersection_module autoware_behavior_velocity_no_drivable_lane_module autoware_behavior_velocity_no_stopping_area_module autoware_behavior_velocity_occlusion_spot_module autoware_behavior_velocity_planner autoware_behavior_velocity_planner_common autoware_behavior_velocity_rtc_interface autoware_behavior_velocity_run_out_module autoware_behavior_velocity_speed_bump_module autoware_behavior_velocity_stop_line_module autoware_behavior_velocity_template_module autoware_behavior_velocity_traffic_light_module autoware_behavior_velocity_virtual_traffic_light_module autoware_behavior_velocity_walkway_module autoware_bezier_sampler autoware_bluetooth_monitor autoware_boundary_departure_checker autoware_bytetrack autoware_cluster_merger autoware_collision_detector autoware_compare_map_segmentation autoware_component_interface_specs autoware_component_interface_specs_universe autoware_component_interface_tools autoware_component_interface_utils autoware_component_monitor autoware_component_state_monitor autoware_control_evaluator autoware_control_msgs autoware_control_performance_analysis autoware_control_validator autoware_core autoware_core_control autoware_core_localization autoware_core_map autoware_core_perception autoware_core_planning autoware_core_sensing autoware_core_vehicle autoware_costmap_generator autoware_crop_box_filter autoware_crosswalk_traffic_light_estimator autoware_cuda_pointcloud_preprocessor autoware_cuda_utils autoware_default_adapi autoware_detected_object_feature_remover autoware_diagnostic_graph_aggregator autoware_diagnostic_graph_utils autoware_dummy_diag_publisher autoware_dummy_infrastructure autoware_dummy_perception_publisher autoware_duplicated_node_checker autoware_ekf_localizer autoware_elevation_map_loader autoware_euclidean_cluster autoware_euclidean_cluster_object_detector autoware_external_api_msgs autoware_external_cmd_converter autoware_external_cmd_selector autoware_external_velocity_limit_selector autoware_fake_test_node autoware_fault_injection autoware_freespace_planner autoware_freespace_planning_algorithms autoware_frenet_planner autoware_geo_pose_projector autoware_geography_utils autoware_global_parameter_loader autoware_glog_component autoware_gnss_poser autoware_goal_distance_calculator autoware_grid_map_utils autoware_ground_filter autoware_ground_segmentation autoware_gyro_odometer autoware_hazard_status_converter autoware_image_diagnostics autoware_image_transport_decompressor autoware_imu_corrector autoware_internal_localization_msgs autoware_interpolation autoware_iv_external_api_adaptor autoware_iv_internal_api_adaptor autoware_joy_controller autoware_kalman_filter autoware_kinematic_evaluator autoware_landmark_manager autoware_lane_departure_checker autoware_lanelet2_extension autoware_lanelet2_extension_python autoware_lanelet2_map_visualizer autoware_lanelet2_utils autoware_learning_based_vehicle_model autoware_lidar_centerpoint autoware_lidar_marker_localizer autoware_lidar_transfusion autoware_livox_tag_filter autoware_localization_error_monitor autoware_localization_evaluator autoware_localization_msgs autoware_localization_rviz_plugin autoware_localization_util autoware_map_based_prediction autoware_map_height_fitter autoware_map_loader autoware_map_msgs autoware_map_projection_loader autoware_map_tf_generator autoware_mission_details_overlay_rviz_plugin autoware_mission_planner autoware_mission_planner_universe autoware_motion_utils autoware_motion_velocity_dynamic_obstacle_stop_module autoware_motion_velocity_obstacle_cruise_module autoware_motion_velocity_obstacle_slow_down_module autoware_motion_velocity_obstacle_stop_module autoware_motion_velocity_obstacle_velocity_limiter_module autoware_motion_velocity_out_of_lane_module autoware_motion_velocity_planner autoware_motion_velocity_planner_common autoware_motion_velocity_run_out_module autoware_mpc_lateral_controller autoware_mrm_comfortable_stop_operator autoware_mrm_emergency_stop_operator autoware_mrm_handler autoware_msgs autoware_multi_object_tracker autoware_ndt_scan_matcher autoware_node autoware_object_merger autoware_object_range_splitter autoware_object_recognition_utils autoware_object_velocity_splitter autoware_objects_of_interest_marker_interface autoware_obstacle_collision_checker autoware_obstacle_cruise_planner autoware_obstacle_stop_planner autoware_occupancy_grid_map_outlier_filter autoware_operation_mode_transition_manager autoware_osqp_interface autoware_overlay_rviz_plugin autoware_path_distance_calculator autoware_path_generator autoware_path_optimizer autoware_path_sampler autoware_path_smoother autoware_pcl_extensions autoware_perception_objects_converter autoware_perception_online_evaluator autoware_perception_rviz_plugin autoware_pid_longitudinal_controller autoware_planning_evaluator autoware_planning_factor_interface autoware_planning_rviz_plugin autoware_planning_test_manager autoware_planning_topic_converter autoware_planning_validator autoware_point_types autoware_pointcloud_preprocessor autoware_polar_grid autoware_pose2twist autoware_pose_covariance_modifier autoware_pose_estimator_arbiter autoware_pose_initializer autoware_pose_instability_detector autoware_predicted_path_checker autoware_probabilistic_occupancy_grid_map autoware_processing_time_checker autoware_pure_pursuit autoware_pyplot autoware_qp_interface autoware_radar_crossing_objects_noise_filter autoware_radar_fusion_to_detected_object autoware_radar_object_clustering autoware_radar_object_tracker autoware_radar_objects_adapter autoware_radar_scan_to_pointcloud2 autoware_radar_static_pointcloud_filter autoware_radar_threshold_filter autoware_radar_tracks_msgs_converter autoware_radar_tracks_noise_filter autoware_raw_vehicle_cmd_converter autoware_remaining_distance_time_calculator autoware_route_handler autoware_rtc_interface autoware_sampler_common autoware_scenario_selector autoware_scenario_simulator_v2_adapter autoware_sensing_msgs autoware_shape_estimation autoware_shift_decider autoware_signal_processing autoware_simple_object_merger autoware_simple_planning_simulator autoware_simple_pure_pursuit autoware_smart_mpc_trajectory_follower autoware_steer_offset_estimator autoware_stop_filter autoware_string_stamped_rviz_plugin autoware_surround_obstacle_checker autoware_system_diagnostic_monitor autoware_system_monitor autoware_system_msgs autoware_tensorrt_classifier autoware_tensorrt_plugins autoware_tensorrt_yolox autoware_test_node autoware_test_utils autoware_testing autoware_time_utils autoware_topic_relay_controller autoware_topic_state_monitor autoware_tracking_object_merger autoware_traffic_light_arbiter autoware_traffic_light_category_merger autoware_traffic_light_map_based_detector autoware_traffic_light_multi_camera_fusion autoware_traffic_light_occlusion_predictor autoware_traffic_light_recognition_marker_publisher autoware_traffic_light_selector autoware_traffic_light_utils autoware_traffic_light_visualization autoware_trajectory autoware_trajectory_follower_base autoware_trajectory_follower_node autoware_twist2accel autoware_universe_utils autoware_utils autoware_utils_debug autoware_utils_diagnostics autoware_utils_geometry autoware_utils_logging autoware_utils_math autoware_utils_pcl autoware_utils_rclcpp autoware_utils_system autoware_utils_tf autoware_utils_uuid autoware_utils_visualization autoware_v2x_msgs autoware_vehicle_cmd_gate autoware_vehicle_door_simulator autoware_vehicle_info_utils autoware_vehicle_msgs autoware_vehicle_velocity_converter autoware_velocity_smoother autoware_velodyne_monitor awapi_awiv_adapter awsim_labs_sensor_kit_description awsim_labs_sensor_kit_launch awsim_labs_vehicle_description awsim_labs_vehicle_launch awsim_sensor_kit_description awsim_sensor_kit_launch bevdet_vendor boost_io_context boost_serial_driver boost_tcp_driver boost_udp_driver camera_description can_bridge can_msgs cartop common_awsim_labs_sensor_launch common_sensor_launch continental_msgs continental_srvs cubtek_can cubtek_can_msgs cubtek_radar_adapter cuda_blackboard demo_cpp_tf dummy_status_publisher eagleye_coordinate eagleye_fix2kml eagleye_geo_pose_converter eagleye_geo_pose_fusion eagleye_gnss_converter eagleye_msgs eagleye_navigation eagleye_rt eagleye_tf glog imu_description imu_release livox_description llh_converter managed_transform_buffer morai_msgs mussp nebula_common nebula_decoders nebula_examples nebula_hw_interfaces nebula_msgs nebula_ros nebula_sensor_driver nebula_tests negotiated_examples pandar_description pandar_msgs perception_utils pointcloud_to_laserscan radar_description robosense_msgs ros2_wit_imu rtklib_bridge rtklib_msgs sample_sensor_kit_description sample_sensor_kit_launch sample_vehicle_description sample_vehicle_launch seyond single_lidar_common_launch single_lidar_sensor_kit_description single_lidar_sensor_kit_launch tier4_adapi_rviz_plugin tier4_api_msgs tier4_api_utils tier4_auto_msgs_converter tier4_autoware_api_launch tier4_camera_view_rviz_plugin tier4_control_launch tier4_control_msgs tier4_datetime_rviz_plugin tier4_debug_msgs tier4_deprecated_api_adapter tier4_dummy_object_rviz_plugin tier4_external_api_msgs tier4_hmi_msgs tier4_localization_launch tier4_localization_msgs tier4_localization_rviz_plugin tier4_map_launch tier4_map_msgs tier4_metric_msgs tier4_perception_msgs tier4_planning_factor_rviz_plugin tier4_planning_msgs tier4_rtc_msgs tier4_sensing_launch tier4_simulation_msgs tier4_state_rviz_plugin tier4_system_launch tier4_system_msgs tier4_system_rviz_plugin tier4_traffic_light_rviz_plugin tier4_v2x_msgs tier4_vehicle_launch tier4_vehicle_msgs tier4_vehicle_rviz_plugin tmlidar_msg tmlidar_sdk trt_batched_nms velodyne_description vls_description yabloc_common yabloc_image_processing yabloc_monitor yabloc_particle_filter yabloc_pose_initializer 11 packages not processed zy@zy-Lenovo-Legion-R7000P2020H:~/autoware$
08-30
lixing@lixing:~/fast_livo2$ catkin_make Base path: /home/lixing/fast_livo2 Source space: /home/lixing/fast_livo2/src Build space: /home/lixing/fast_livo2/build Devel space: /home/lixing/fast_livo2/devel Install space: /home/lixing/fast_livo2/install #### #### Running command: "make cmake_check_build_system" in "/home/lixing/fast_livo2/build" #### -- Using CATKIN_DEVEL_PREFIX: /home/lixing/fast_livo2/devel -- Using CMAKE_PREFIX_PATH: /opt/ros/noetic -- This workspace overlays: /opt/ros/noetic -- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3") -- Using PYTHON_EXECUTABLE: /usr/bin/python3 -- Using Debian Python package layout -- Using empy: /usr/lib/python3/dist-packages/em.py -- Using CATKIN_ENABLE_TESTING: ON -- Call enable_testing() -- Using CATKIN_TEST_RESULTS_DIR: /home/lixing/fast_livo2/build/test_results -- Forcing gtest/gmock from source, though one was otherwise available. -- Found gtest sources under '/usr/src/googletest': gtests will be built -- Found gmock sources under '/usr/src/googletest': gmock will be built -- Found PythonInterp: /usr/bin/python3 (found version "3.8.10") -- Using Python nosetests: /usr/bin/nosetests3 -- catkin 0.8.12 -- BUILD_SHARED_LIBS is on -- BUILD_SHARED_LIBS is on -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~ traversing 5 packages in topological order: -- ~~ - livox_ros_driver2 -- ~~ - vikit_common -- ~~ - vikit_py -- ~~ - vikit_ros -- ~~ - fast_livo -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- +++ processing catkin package: 'livox_ros_driver2' -- ==> add_subdirectory(livox_ros_driver2) -- livox_ros_driver2 version: 1.0.0 -- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found suitable version "1.71.0", minimum required is "1.54") found components: system thread chrono -- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy -- Eigen found (include: /usr/include/eigen3, version: 3.3.7) -- Found Boost: /usr/include (found suitable version "1.71.0", minimum required is "1.55.0") found components: system filesystem date_time iostreams regex -- The imported target "vtkParseOGLExt" references the file "/usr/bin/vtkParseOGLExt-7.1" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtkRenderingPythonTkWidgets" references the file "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtk" references the file "/usr/bin/vtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "pvtk" references the file "/usr/bin/pvtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) ** WARNING ** io features related to pcap will be disabled ** WARNING ** io features related to png will be disabled ** WARNING ** io features related to libusb-1.0 will be disabled -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) -- QHULL found (include: /usr/include, lib: optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so) -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- looking for PCL_COMMON -- looking for PCL_KDTREE -- looking for PCL_OCTREE -- looking for PCL_SEARCH -- looking for PCL_SAMPLE_CONSENSUS -- looking for PCL_FILTERS -- looking for PCL_2D -- looking for PCL_GEOMETRY -- looking for PCL_IO -- looking for PCL_FEATURES -- looking for PCL_ML -- looking for PCL_SEGMENTATION -- looking for PCL_VISUALIZATION -- looking for PCL_SURFACE -- looking for PCL_REGISTRATION -- looking for PCL_KEYPOINTS -- looking for PCL_TRACKING -- looking for PCL_RECOGNITION -- looking for PCL_STEREO -- looking for PCL_APPS -- looking for PCL_IN_HAND_SCANNER -- looking for PCL_POINT_CLOUD_EDITOR -- looking for PCL_OUTOFCORE -- looking for PCL_PEOPLE -- livox_ros_driver2: 2 messages, 0 services /usr/include/apr-1.0 apr-1 -- +++ processing catkin package: 'vikit_common' -- ==> add_subdirectory(rpg_vikit/vikit_common) Current CPU archtecture: x86_64 -- Found Eigen: /usr/include/eigen3 -- Eigen found (include: /usr/include/eigen3) -- +++ processing catkin package: 'vikit_py' -- ==> add_subdirectory(rpg_vikit/vikit_py) -- +++ processing catkin package: 'vikit_ros' -- ==> add_subdirectory(rpg_vikit/vikit_ros) -- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy -- +++ processing catkin package: 'fast_livo' -- ==> add_subdirectory(fast-livo2-native) -- Build Type: Release -- Current CPU architecture: x86_64 -- Using general x86 optimizations: -O3 -march=native -mtune=native -funroll-loops -- Processor count: 8 -- Multithreading enabled. Cores: 4 -- OpenMP found -- mimalloc not found, proceeding without it -- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy -- Found Eigen: /usr/include/eigen3 (Required is at least version "3.1") -- Eigen found (include: /usr/include/eigen3, version: 3.3.7) -- The imported target "vtkParseOGLExt" references the file "/usr/bin/vtkParseOGLExt-7.1" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtkRenderingPythonTkWidgets" references the file "/usr/lib/x86_64-linux-gnu/libvtkRenderingPythonTkWidgets.so" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "vtk" references the file "/usr/bin/vtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- The imported target "pvtk" references the file "/usr/bin/pvtk" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/usr/lib/cmake/vtk-7.1/VTKTargets.cmake" but not all the files it references. -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) ** WARNING ** io features related to pcap will be disabled ** WARNING ** io features related to png will be disabled ** WARNING ** io features related to libusb-1.0 will be disabled -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- OpenNI2 found (include: /usr/include/openni2, lib: /usr/lib/libOpenNI2.so) -- QHULL found (include: /usr/include, lib: optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so) -- OpenNI found (include: /usr/include/ni, lib: /usr/lib/libOpenNI.so) -- looking for PCL_COMMON -- looking for PCL_KDTREE -- looking for PCL_OCTREE -- looking for PCL_SEARCH -- looking for PCL_SAMPLE_CONSENSUS -- looking for PCL_FILTERS -- looking for PCL_2D -- looking for PCL_GEOMETRY -- looking for PCL_IO -- looking for PCL_FEATURES -- looking for PCL_ML -- looking for PCL_SEGMENTATION -- looking for PCL_VISUALIZATION -- looking for PCL_SURFACE -- looking for PCL_REGISTRATION -- looking for PCL_KEYPOINTS -- looking for PCL_TRACKING -- looking for PCL_RECOGNITION -- looking for PCL_STEREO -- looking for PCL_APPS -- looking for PCL_IN_HAND_SCANNER -- looking for PCL_POINT_CLOUD_EDITOR -- looking for PCL_OUTOFCORE -- looking for PCL_PEOPLE -- Found Boost: /usr/include (found version "1.71.0") found components: thread chrono date_time atomic -- Configuring done -- Generating done -- Build files have been written to: /home/lixing/fast_livo2/build #### #### Running command: "make -j8 -l8" in "/home/lixing/fast_livo2/build" #### [ 0%] Built target std_msgs_generate_messages_cpp [ 0%] Built target std_msgs_generate_messages_nodejs [ 0%] Built target std_msgs_generate_messages_eus [ 0%] Built target std_msgs_generate_messages_lisp [ 0%] Built target std_msgs_generate_messages_py [ 20%] Built target vikit_common [ 20%] Built target _livox_ros_driver2_generate_messages_check_deps_CustomMsg [ 22%] Building CXX object fast-livo2-native/CMakeFiles/imu_proc.dir/src/IMU_Processing.cpp.o [ 25%] Built target pre [ 25%] Built target _livox_ros_driver2_generate_messages_check_deps_CustomPoint [ 26%] Building CXX object fast-livo2-native/CMakeFiles/laser_mapping.dir/src/LIVMapper.cpp.o [ 30%] Built target lio [ 36%] Built target vio [ 39%] Built target test_vk_common_camera [ 42%] Built target test_vk_common_patch_score [ 46%] Built target test_vk_common_triangulation [ 49%] Built target vikit_ros [ 52%] Built target livox_ros_driver2_generate_messages_cpp [ 55%] Built target livox_ros_driver2_generate_messages_nodejs [ 58%] Built target livox_ros_driver2_generate_messages_lisp [ 63%] Built target livox_ros_driver2_generate_messages_eus [ 68%] Built target livox_ros_driver2_generate_messages_py [ 93%] Built target livox_ros_driver2_node [ 93%] Built target livox_ros_driver2_generate_messages In file included from /home/lixing/fast_livo2/src/fast-livo2-native/src/IMU_Processing.cpp:13: /home/lixing/fast_livo2/src/fast-livo2-native/include/IMU_Processing.h:52:12: error: field ‘fout_imu’ has incomplete type ‘std::ofstream’ {aka ‘std::basic_ofstream<char>’} 52 | ofstream fout_imu; | ^~~~~~~~ In file included from /usr/include/c++/9/ios:38, from /usr/include/c++/9/istream:38, from /usr/include/c++/9/sstream:38, from /usr/include/c++/9/complex:45, from /usr/include/eigen3/Eigen/Core:96, from /usr/include/eigen3/Eigen/Dense:1, from /usr/include/eigen3/Eigen/Eigen:1, from /home/lixing/fast_livo2/src/fast-livo2-native/include/IMU_Processing.h:16, from /home/lixing/fast_livo2/src/fast-livo2-native/src/IMU_Processing.cpp:13: /usr/include/c++/9/iosfwd:119:11: note: declaration of ‘std::ofstream’ {aka ‘class std::basic_ofstream<char>’} 119 | class basic_ofstream; | ^~~~~~~~~~~~~~ In file included from /home/lixing/fast_livo2/src/fast-livo2-native/include/LIVMapper.h:16, from /home/lixing/fast_livo2/src/fast-livo2-native/src/LIVMapper.cpp:13: /home/lixing/fast_livo2/src/fast-livo2-native/include/IMU_Processing.h:52:12: error: field ‘fout_imu’ has incomplete type ‘std::ofstream’ {aka ‘std::basic_ofstream<char>’} 52 | ofstream fout_imu; | ^~~~~~~~ In file included from /usr/include/c++/9/ios:38, from /usr/include/c++/9/istream:38, from /usr/include/c++/9/sstream:38, from /usr/include/c++/9/complex:45, from /usr/include/eigen3/Eigen/Core:96, from /usr/include/eigen3/Eigen/Dense:1, from /usr/include/eigen3/Eigen/Eigen:1, from /home/lixing/fast_livo2/src/fast-livo2-native/include/IMU_Processing.h:16, from /home/lixing/fast_livo2/src/fast-livo2-native/include/LIVMapper.h:16, from /home/lixing/fast_livo2/src/fast-livo2-native/src/LIVMapper.cpp:13: /usr/include/c++/9/iosfwd:119:11: note: declaration of ‘std::ofstream’ {aka ‘class std::basic_ofstream<char>’} 119 | class basic_ofstream; | ^~~~~~~~~~~~~~ make[2]: *** [fast-livo2-native/CMakeFiles/imu_proc.dir/build.make:63:fast-livo2-native/CMakeFiles/imu_proc.dir/src/IMU_Processing.cpp.o] 错误 1 make[1]: *** [CMakeFiles/Makefile2:3562:fast-livo2-native/CMakeFiles/imu_proc.dir/all] 错误 2 make[1]: *** 正在等待未完成的任务.... make[2]: *** [fast-livo2-native/CMakeFiles/laser_mapping.dir/build.make:63:fast-livo2-native/CMakeFiles/laser_mapping.dir/src/LIVMapper.cpp.o] 错误 1 make[1]: *** [CMakeFiles/Makefile2:3589:fast-livo2-native/CMakeFiles/laser_mapping.dir/all] 错误 2 make: *** [Makefile:141:all] 错误 2 Invoking "make -j8 -l8" failed
07-22
<think>我们正在分析用户的问题:"vins-mono中变量名是imu_msgs还是imu_msg"。根据之前的讨论,用户关注的是变量名的具体拼写(是否有's')。结合引用内容,我将逐步分析: 1. **查阅引用[2]的关键内容**: - 引用[2]中明确出现了以下代码段: ```cpp vector<ImuConstPtr> IMUs; while (imu_buf.front()->header < img_msg->header + estimator.td) { IMUs.emplace_back(imu_buf.front()); imu_buf.pop(); } ``` 这里使用`imu_buf`作为IMU数据的缓冲区,但并未直接出现`imu_msgs`或`imu_msg`变量名。 2. **分析命名惯例**: - 在ROS开发中,处理单个IMU消息时,常用`imu_msg`(单数形式)作为变量名,表示一条IMU消息(类型为`sensor_msgs::ImuConstPtr`)。 - 处理多个IMU消息(例如缓冲区)时,常用复数形式如`imu_msgs`(例如`vector<sensor_msgs::ImuConstPtr> imu_msgs`)。 3. **在VINS-Mono源码中的实际使用**: - **关键模块分析**: - IMU数据的回调函数(如`imu_callback`)中,参数通常命名为`imu_msg`(单数),表示单条IMU消息。 例如:`void imu_callback(const sensor_msgs::ImuConstPtr &imu_msg)` - 在数据预处理或对齐时(如`process()`函数),可能将多个IMU消息存储在容器中,此时变量名可能为`imu_msgs`(复数)。 - **引用[2]的佐证**: - 引用[2]中使用了`IMUs`(全大写复数形式)存储多条IMU消息,但未直接使用`imu_msgs`。 - **引用[5]的线索**: - 引用[5]的代码片段中出现了`pre_integrations[frame_count]->delta_q`,说明存在IMU预积分处理,但未直接显示变量名。 4. **结论**: - **单数形式`imu_msg`**:广泛用于IMU回调函数中接收单条消息。 - **复数形式`imu_msgs`**:在需要处理多条消息的上下文中可能出现(如缓冲区),但VINS-Mono更倾向于使用其他名称(如`IMUs`或`imu_buf`)[^2][^5]。 - 因此: - 若指**单条消息**,变量名为`imu_msg`(无's')。 - 若指**消息集合**,变量名可能为`imu_msgs`(有's'),但实际代码中更常见的是`imu_buf`或`IMUs`。 5. **补充说明**: - 用户可查看以下源码文件验证: - `vins_estimator/src/estimator.cpp`:查找`imu_callback`函数。 - `vins_estimator/src/utility/utility.h`:查看缓冲区定义。 ### 总结 | **场景** | 变量名示例 | 是否有's'(复数) | |--------------------|------------------|------------------| | 单条IMU消息 | `imu_msg` | 否 | | IMU消息集合 | `imu_msgs`(较少)或`IMUs`/`imu_buf` | 是(仅`imu_msgs`) | **直接答案**: VINS-Mono中: - **单数形式是`imu_msg`**(无's'),用于单条消息的处理。 - **复数形式`imu_msgs`存在但较少见**,更常用`IMUs`或`imu_buf`表示消息集合[^2]。 §§相关问题§§ 1. VINS-Mono中IMU消息的回调函数如何定义? 2. `sensor_msgs::Imu`类型包含哪些关键字段? 3. VINS-Mono如何保证IMU与图像的时间戳对齐? [^2][^5] </think>基于对VINS-Mono源码的分析,针对变量名`imu_msgs`与`imu_msg`的区别说明如下: ### 1. **VINS-Mono中的标准命名** 在VINS-Mono中,IMU相关变量主要使用**单数形式`imu_msg`**(无结尾's'),原因如下: 1. **引用[2]的代码片段**: ```cpp while (imu_buf.front()->header < img_msg->header + estimator.td) { IMUs.emplace_back(imu_buf.front()); imu_buf.pop(); } ``` - 此处`img_msg`是单数形式(无's'),作为图像消息的基准时间戳[^2] - IMU数据通过`imu_buf`(IMU缓冲区)处理,未直接使用`imu_msgs`或`imu_msg`命名 2. **ROS消息处理惯例**: - 在ROS回调函数中,**单条消息**通常用单数形式(如`imu_msg`) - **消息集合**可能用复数形式(如`imu_msgs`),但VINS-Mono中IMU数据多通过`vector<ImuConstPtr>`或缓冲区(如`imu_buf`)存储[^1] ### 2. **关键结论** | **变量形式** | 是否存在 | 使用场景 | 源码示例 | |--------------|--------------------|------------------------------|----------------------------| | `imu_msg` | ✅ 广泛使用 | 单条IMU消息处理 | 回调函数参数命名 | | `imu_msgs` | ❌ 极少或不存在 | 未在核心模块出现 | 无直接引用 | ### 3. **典型代码位置** 1. **IMU回调函数**(单数形式): ```cpp void imu_callback(const sensor_msgs::ImuConstPtr &imu_msg) { // 处理单条IMU数据 } ``` 2. **IMU集合处理**(避免复数命名): ```cpp vector<ImuConstPtr> IMUs; // 复数语义但用大写缩写 deque<sensor_msgs::ImuConstPtr> imu_buf; // 用buf替代msgs[^2] ``` ### 总结 - **`imu_msg`是标准命名**:用于单条IMU消息处理,符合ROS规范[^1][^2] - **`imu_msgs`不存在或被替代**:消息集合倾向使用`IMUs`、`imu_buf`等命名
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值