小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
ros2 cartographer的纯定位问题
-
我已经用cartographer建图成功,效果也比较好,准备测试纯定位效果
cartographer_node = Node(
package='cartographer_ros',
executable='cartographer_node',
name='cartographer_node',
output='screen',
parameters=[{'use_sim_time': use_sim_time}],
arguments=['-configuration_directory', FindPackageShare('cartographer_ros').find('cartographer_ros') + '/configuration_files',
'-configuration_basename', 'backpack_2d_localization.lua',
'-load_state_filename', "/home/robot/workplace/src/sim/map/carmymap.pbstream"])cartographer_occupancy_grid_node = Node( package='cartographer_ros', executable='cartographer_occupancy_grid_node', name='cartographer_occupancy_grid_node', output='screen', parameters=[{'use_sim_time': use_sim_time}], arguments=['-resolution', resolution, '-publish_period_sec', publish_period_sec])
核心就是这两个节点的启用
启动这个launch时候, 一切正常,所有的配置文件已经找到运行信息如下
robot@robot-Aierxuan-Z-2:~$ ros2 launch sim slam_cartograph.py
[INFO] [launch]: All log files can be found below /home/robot/.ros/log/2023-07-23-09-57-49-080609-robot-Aierxuan-Z-2-115069
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [cartographer_node-1]: process started with pid [115071]
[cartographer_node-1] [INFO] [1690077469.212977034] [cartographer logger]: I0723 09:57:49.000000 115071 configuration_file_resolver.cc:41] Found '/home/robot/cartoros2_ws/install/cartographer_ros/share/cartographer_ros/configuration_files/backpack_2d_localization.lua' for 'backpack_2d_localization.lua'.
[cartographer_node-1] [INFO] [1690077469.213144433] [cartographer logger]: I0723 09:57:49.000000 115071 configuration_file_resolver.cc:41] Found '/home/robot/cartoros2_ws/install/cartographer_ros/share/cartographer_ros/configuration_files/backpack_2d.lua' for 'backpack_2d.lua'.
[cartographer_node-1] [INFO] [1690077469.213164052] [cartographer logger]: I0723 09:57:49.000000 115071 configuration_file_resolver.cc:41] Found '/home/robot/cartoros2_ws/install/cartographer_ros/share/cartographer_ros/configuration_files/backpack_2d.lua' for 'backpack_2d.lua'.
[cartographer_node-1] [INFO] [1690077469.213269827] [cartographer logger]: I0723 09:57:49.000000 115071 configuration_file_resolver.cc:41] Found '/home/robot/cartoros2_ws/install/cartographer/share/cartographer/configuration_files/map_builder.lua' for 'map_builder.lua'.
[cartographer_node-1] [INFO] [1690077469.213295524] [cartographer logger]: I0723 09:57:49.000000 115071 configuration_file_resolver.cc:41] Found '/home/robot/cartoros2_ws/install/cartographer/share/cartographer/configuration_files/map_builder.lua' for 'map_builder.lua'.
[cartographer_node-1] [INFO] [1690077469.213331591] [cartographer logger]: I0723 09:57:49.000000 115071 configuration_file_resolver.cc:41] Found '/home/robot/cartoros2_ws/install/cartographer/share/cartographer/configuration_files/pose_graph.lua' for 'pose_graph.lua'.
[cartographer_node-1] [INFO] [1690077469.213348503] [cartographer logger]: I0723 09:57:49.000000 115071 configuration_file_resolver.cc:41] Found '/home/robot/cartoros2_ws/install/cartographer/share/cartographer/configuration_files/pose_graph.lua' for 'pose_graph.lua'.
[cartographer_node-1] [INFO] [1690077469.213447624] [cartographer logger]: I0723 09:57:49.000000 115071 configuration_file_resolver.cc:41] Found '/home/robot/cartoros2_ws/install/cartographer/share/cartographer/configuration_files/trajectory_builder.lua' for 'trajectory_builder.lua'.
[cartographer_node-1] [INFO] [1690077469.213466345] [cartographer logger]: I0723 09:57:49.000000 115071 configuration_file_resolver.cc:41] Found '/home/robot/cartoros2_ws/install/cartographer/share/cartographer/configuration_files/trajectory_builder.lua' for 'trajectory_builder.lua'.
[cartographer_node-1] [INFO] [1690077469.213502791] [cartographer logger]: I0723 09:57:49.000000 115071 configuration_file_resolver.cc:41] Found '/home/robot/cartoros2_ws/install/cartographer/share/cartographer/configuration_files/trajectory_builder_2d.lua' for 'trajectory_builder_2d.lua'.
[cartographer_node-1] [INFO] [1690077469.213519681] [cartographer logger]: I0723 09:57:49.000000 115071 configuration_file_resolver.cc:41] Found '/home/robot/cartoros2_ws/install/cartographer/share/cartographer/configuration_files/trajectory_builder_2d.lua' for 'trajectory_builder_2d.lua'.
[cartographer_node-1] [INFO] [1690077469.213619420] [cartographer logger]: I0723 09:57:49.000000 115071 configuration_file_resolver.cc:41] Found '/home/robot/cartoros2_ws/install/cartographer/share/cartographer/configuration_files/trajectory_builder_3d.lua' for 'trajectory_builder_3d.lua'.
[cartographer_node-1] [INFO] [1690077469.213637912] [cartographer logger]: I0723 09:57:49.000000 115071 configuration_file_resolver.cc:41] Found '/home/robot/cartoros2_ws/install/cartographer/share/cartographer/configuration_files/trajectory_builder_3d.lua' for 'trajectory_builder_3d.lua'.
[cartographer_node-1] [INFO] [1690077469.217417262] [cartographer logger]: I0723 09:57:49.000000 115071 map_builder_bridge.cpp:117] Loading saved state '/home/robot/workplace/src/sim/map/carmymap.pbstream'...
[cartographer_node-1] [INFO] [1690077469.241519855] [cartographer logger]: I0723 09:57:49.000000 115071 map_builder_bridge.cpp:136] Added trajectory with ID '1'.但是当我打开gazebo模拟的时候 这定位launch却报错了 如下
Check failed: sensor_to_tracking->translation().norm() < 1e-5 The IMU frame must be colocated with the tracking frame. Transforming linear acceleration into the tracking frame will otherwise be imprecise.
[cartographer_node-1] [FATAL] [1690077559.159505788] [cartographer logger]: F0723 09:59:19.000000 115190 sensor_bridge.cpp:136] Check failed: sensor_to_tracking->translation().norm() < 1e-5 The IMU frame must be colocated with the tracking frame. Transforming linear acceleration into the tracking frame will otherwise be imprecise.
[cartographer_node-1] *** Check failure stack trace: ***
[cartographer_node-1] @ 0x7f2dca82b1c3 google::LogMessage::Fail()
[cartographer_node-1] @ 0x7f2dca83025b google::LogMessage::SendToLog()
[cartographer_node-1] @ 0x7f2dca82aebf google::LogMessage::Flush()
[cartographer_node-1] @ 0x7f2dca82b6ef google::LogMessageFatal::~LogMessageFatal()
[cartographer_node-1] @ 0x55cb8fab79eb cartographer_ros::SensorBridge::ToImuData()
[cartographer_node-1] @ 0x55cb8f8dec2d cartographer_ros::Node::HandleImuMessage()
[cartographer_node-1] @ 0x55cb8f8e0204 ZZN16cartographer_ros12_GLOBAL__N_120SubscribeWithHandlerIN11sensor_msgs3msg4Imu_ISaIvEEEEESt10shared_ptrIN6rclcpp16SubscriptionBaseEEMNS_4NodeEFviRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNT_14ConstSharedPtrEEiSJ_S7_INS8_4NodeEEPSB_ENKUlS7_IKS6_EE_clESU
[cartographer_node-1] @ 0x55cb8f8f1183 ZNSt17_Function_handlerIFvSt10shared_ptrIKN11sensor_msgs3msg4Imu_ISaIvEEEEEZN16cartographer_ros12_GLOBAL__N_120SubscribeWithHandlerIS5_EES0_IN6rclcpp16SubscriptionBaseEEMNS9_4NodeEFviRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNT_14ConstSharedPtrEEiSN_S0_INSC_4NodeEEPSF_EUlS7_E_E9_M_invokeERKSt9_Any_dataOS7
[cartographer_node-1] @ 0x55cb8fa88597 std::function<>::operator()()
[cartographer_node-1] @ 0x55cb8fa6becd ZZN6rclcpp23AnySubscriptionCallbackIN11sensor_msgs3msg4Imu_ISaIvEEES4_E8dispatchESt10shared_ptrIS5_ERKNS_11MessageInfoEENKUlOT_E_clIRSt8functionIFvS7_IKS5_EEEEEDaSD
[cartographer_node-1] @ 0x55cb8fa9332b ZSt13__invoke_implIvZN6rclcpp23AnySubscriptionCallbackIN11sensor_msgs3msg4Imu_ISaIvEEES5_E8dispatchESt10shared_ptrIS6_ERKNS0_11MessageInfoEEUlOT_E_JRSt8functionIFvS8_IKS6_EEEEESD_St14__invoke_otherOT0_DpOT1
[cartographer_node-1] @ 0x55cb8fa885da ZSt8__invokeIZN6rclcpp23AnySubscriptionCallbackIN11sensor_msgs3msg4Imu_ISaIvEEES5_E8dispatchESt10shared_ptrIS6_ERKNS0_11MessageInfoEEUlOT_E_JRSt8functionIFvS8_IKS6_EEEEENSt15__invoke_resultISD_JDpT0_EE4typeESE_DpOSN
[cartographer_node-1] @ 0x55cb8fa6bf58 ZNSt8__detail9__variant17__gen_vtable_implILb1ENS0_12_Multi_arrayIPFvOZN6rclcpp23AnySubscriptionCallbackIN11sensor_msgs3msg4Imu_ISaIvEEES8_E8dispatchESt10shared_ptrIS9_ERKNS3_11MessageInfoEEUlOT_E_RSt7variantIJSt8functionIFvRKS9_EESL_IFvSN_SF_EESL_IFvSt10unique_ptrIS9_St14default_deleteIS9_EEEESL_IFvSV_SF_EESL_IFvSB_ISM_EEESL_IFvS10_SF_EESL_IFvRKS10_EESL_IFvS16_SF_EESL_IFvSC_EESL_IFvSC_SF_EEEEEJEEESt5tupleIJS1G_EESt16integer_sequenceImJLm4EEEE19__visit_invoke_implESJ_S1G
[cartographer_node-1] @ 0x55cb8fa6bf9b ZNSt8__detail9__variant17__gen_vtable_implILb1ENS0_12_Multi_arrayIPFvOZN6rclcpp23AnySubscriptionCallbackIN11sensor_msgs3msg4Imu_ISaIvEEES8_E8dispatchESt10shared_ptrIS9_ERKNS3_11MessageInfoEEUlOT_E_RSt7variantIJSt8functionIFvRKS9_EESL_IFvSN_SF_EESL_IFvSt10unique_ptrIS9_St14default_deleteIS9_EEEESL_IFvSV_SF_EESL_IFvSB_ISM_EEESL_IFvS10_SF_EESL_IFvRKS10_EESL_IFvS16_SF_EESL_IFvSC_EESL_IFvSC_SF_EEEEEJEEESt5tupleIJS1G_EESt16integer_sequenceImJLm4EEEE17__do_visit_invokeESJ_S1G
[cartographer_node-1] @ 0x55cb8fa6bfde ZNSt8__detail9__variant17__gen_vtable_implILb1ENS0_12_Multi_arrayIPFvOZN6rclcpp23AnySubscriptionCallbackIN11sensor_msgs3msg4Imu_ISaIvEEES8_E8dispatchESt10shared_ptrIS9_ERKNS3_11MessageInfoEEUlOT_E_RSt7variantIJSt8functionIFvRKS9_EESL_IFvSN_SF_EESL_IFvSt10unique_ptrIS9_St14default_deleteIS9_EEEESL_IFvSV_SF_EESL_IFvSB_ISM_EEESL_IFvS10_SF_EESL_IFvRKS10_EESL_IFvS16_SF_EESL_IFvSC_EESL_IFvSC_SF_EEEEEJEEESt5tupleIJS1G_EESt16integer_sequenceImJLm4EEEE14__visit_invokeESJ_S1G
[cartographer_node-1] @ 0x55cb8fa6c865 ZSt10__do_visitILb0ELb1EZN6rclcpp23AnySubscriptionCallbackIN11sensor_msgs3msg4Imu_ISaIvEEES5_E8dispatchESt10shared_ptrIS6_ERKNS0_11MessageInfoEEUlOT_E_JRSt7variantIJSt8functionIFvRKS6_EESH_IFvSJ_SC_EESH_IFvSt10unique_ptrIS6_St14default_deleteIS6_EEEESH_IFvSR_SC_EESH_IFvS8_ISI_EEESH_IFvSW_SC_EESH_IFvRKSW_EESH_IFvS12_SC_EESH_IFvS9_EESH_IFvS9_SC_EEEEEEDcOT1_DpOT2
[cartographer_node-1] @ 0x55cb8fa6c8c6 ZSt5visitIZN6rclcpp23AnySubscriptionCallbackIN11sensor_msgs3msg4Imu_ISaIvEEES5_E8dispatchESt10shared_ptrIS6_ERKNS0_11MessageInfoEEUlOT_E_JRSt7variantIJSt8functionIFvRKS6_EESH_IFvSJ_SC_EESH_IFvSt10unique_ptrIS6_St14default_deleteIS6_EEEESH_IFvSR_SC_EESH_IFvS8_ISI_EEESH_IFvSW_SC_EESH_IFvRKSW_EESH_IFvS12_SC_EESH_IFvS9_EESH_IFvS9_SC_EEEEEEDcSE_DpOT0
[cartographer_node-1] @ 0x55cb8fa6c99f rclcpp::AnySubscriptionCallback<>::dispatch()
[cartographer_node-1] @ 0x55cb8fa5a73f rclcpp::Subscription<>::handle_message()
[cartographer_node-1] @ 0x7f2dcad7efa4 (unknown)
[cartographer_node-1] @ 0x7f2dcad7f874 rclcpp::Executor::execute_subscription()
[cartographer_node-1] @ 0x7f2dcad7ffa5 rclcpp::Executor::execute_any_executable()
[cartographer_node-1] @ 0x7f2dcad870bc rclcpp::executors::SingleThreadedExecutor::spin()
[cartographer_node-1] @ 0x7f2dcad85c78 rclcpp::spin()
[cartographer_node-1] @ 0x7f2dcad85f20 rclcpp::spin()
[cartographer_node-1] @ 0x55cb8f8cf493 cartographer_ros::(anonymous namespace)::Run()
[cartographer_node-1] @ 0x55cb8f8cf8a6 main
[cartographer_node-1] @ 0x7f2dc9da3083 __libc_start_main
[cartographer_node-1] @ 0x55cb8f8cf05e _start
[ERROR] [cartographer_node-1]: process has died [pid 115190, exit code -6, cmd '/home/robot/cartoros2_ws/install/cartographer_ros/lib/cartographer_ros/cartographer_node -configuration_directory /home/robot/cartoros2_ws/install/cartographer_ros/share/cartographer_ros/configuration_files -configuration_basename backpack_2d_localization.lua -load_state_filename /home/robot/workplace/src/sim/map/carmymap.pbstream --ros-args -r __node:=cartographer_node --params-file /tmp/launch_params_abvxa31b'].
robot@robot-Aierxuan-Z-2:~$这是什么错误引起的呢
-
我在继续测试的时候 发现应该是imu引起的,我思考后,觉得carto定位应该不需要imu数据 因为没有找到不使用imu数据的配置,所以我在urdf的gazebo列里面把imu的话题给改了,让cartograph找不到此数据,
实施以后,发现果然不报错了,但是开启gazebo模拟以后 cartograph的launch界面没有任何反应,一段时候后,开始输出等待imu数据的信息这难住了,还非得时候Imu数据? 如果我把话题名字改回来又继续报错
-
我想起来建图时候有一个配置参数
-- true改成false,不使用IMU数据,大家可以开启,然后对比下效果
TRAJECTORY_BUILDER_2D.use_imu_data = false于是我手动复制过去,果然不报错了
开启gazebo以后,cartographer 开始输出下列信息,貌似开始工作了_files/trajectory_builder_2d.lua' for 'trajectory_builder_2d.lua'.
[cartographer_node-1] [INFO] [1690079819.246484706] [cartographer logger]: I0723 10:36:59.000000 140706 configuration_file_resolver.cc:41] Found '/home/robot/cartoros2_ws/install/cartographer/share/cartographer/configuration_files/trajectory_builder_2d.lua' for 'trajectory_builder_2d.lua'.
[cartographer_node-1] [INFO] [1690079819.246615544] [cartographer logger]: I0723 10:36:59.000000 140706 configuration_file_resolver.cc:41] Found '/home/robot/cartoros2_ws/install/cartographer/share/cartographer/configuration_files/trajectory_builder_3d.lua' for 'trajectory_builder_3d.lua'.
[cartographer_node-1] [INFO] [1690079819.246635558] [cartographer logger]: I0723 10:36:59.000000 140706 configuration_file_resolver.cc:41] Found '/home/robot/cartoros2_ws/install/cartographer/share/cartographer/configuration_files/trajectory_builder_3d.lua' for 'trajectory_builder_3d.lua'.
[cartographer_node-1] [INFO] [1690079819.250542216] [cartographer logger]: I0723 10:36:59.000000 140706 map_builder_bridge.cpp:117] Loading saved state '/home/robot/workplace/src/sim/map/carmymap.pbstream'...
[cartographer_node-1] [INFO] [1690079819.275555344] [cartographer logger]: I0723 10:36:59.000000 140706 map_builder_bridge.cpp:136] Added trajectory with ID '1'.
[cartographer_node-1] [INFO] [1690079821.528053558] [cartographer logger]: I0723 10:37:01.000000 140706 ordered_multi_queue.cc:172] All sensor data for trajectory 1 is available starting at '621355968735980000'.
[cartographer_node-1] [INFO] [1690079822.553417390] [cartographer logger]: I0723 10:37:02.000000 140706 pose_graph_2d.cc:148] Inserted submap (1, 0).
[cartographer_node-1] [INFO] [1690079822.592126848] [cartographer logger]: I0723 10:37:02.000000 140730 constraint_builder_2d.cc:275] Node (1, 0) with 205 points on submap (0, 0) matches with score 86.9%.
[cartographer_node-1] [INFO] [1690079834.277510930] [cartographer logger]: I0723 10:37:14.000000 140706 collated_trajectory_builder.cc:81] scan rate: 10.00 Hz 1.00e-01 s +/- 1.09e-03 s (pulsed at 96.49% real time)但是当我打开了nav2的launch 屏蔽调amcl以后, 却发现没有代价地图的显示,而且也无法导航,