cartographer_ros 代码分析1

本文深入解析CartographerROS的运行机制,包括代码结构、关键函数流程及传感器数据处理过程,揭示了从ROS节点到Cartographer底层算法的桥梁构建。

cartographer ROS代码为两大部分:cartographer和cartographer_ros。
cartographer主要负责处理来自雷达、IMU、里程计的数据并基于这些数据进行地图的构建,是cartographer理论的底层实现。
cartographer_ros 则基于ros的通信机制获取传感器的数据并将它们转换成cartographer中定义的格式传递给cartographer处理,与此同时也将cartographer的处理结果发布用于显示或保存,是基于cartographer的上层应用

1. node_main.cc 中

main(int argc, char** argv)
    cartographer_ros::Run();
        1. LoadOptions 加载配置文件
        2. Node node(node_options, &tf_buffer);
        //启动轨迹
        3.node.StartTrajectoryWithDefaultTopics(trajectory_options);


 2. node.cc 中

 //构造函数
 Node::Node(const NodeOptions& node_options, tf2_ros::Buffer* const tf_buffer): node_options_(node_options),
            map_builder_bridge_(node_options_, tf_buffer)
{
    //submap发布器,往kSubmapListTopic 发布
    //::cartographer_ros_msgs::SubmapList 消息
    submap_list_publisher_
    
    //路径发布器,向kTrajectoryNodeListTopic这个Topic上发布了
    //一个::visualization_msgs::MarkerArray型的message
    trajectory_node_list_publisher_
    
    //请求子图submap服务
    kSubmapQueryServiceName
    
    //定时器,发布获取子图
      wall_timers_.push_back(node_handle_.createWallTimer(
      ::ros::WallDuration(node_options_.submap_publish_period_sec),
      &Node::PublishSubmapList, this));
    
}

 

//启动轨迹
StartTrajectoryWithDefaultTopics
{
    AddTrajectory(options, DefaultSensorTopics());
}  

 

int Node::AddTrajectory(const TrajectoryOptions& options,
             const cartographer_ros_msgs::SensorTopics& topics)
{
    //调用map_builder_bridge_中的AddTrajectory来处理,再次会调用到
    //map_builder_.AddTrajectoryBuilder,最终调用到cartographer底层算法的
  const int trajectory_id =
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值