ros源码分析(1)—roscore概况

ros wiki tutorials中在安装好ros后,首先会让运行乌龟turtle的小例子,而其中首先就是让执行roscore命令。那么其内部原理到底是什么?后续将陆续分析。

roscore的wiki介绍,
roscore is a collection of nodes and programs that are pre-requisites of a ROS-based system. You must have a roscore running in order for ROS nodes to communicate. It is launched using the roscore command.

下面看看执行了roscore命令后发生了什么,roscore本身是个python脚本。

lyf@lyf:~$ which roscore
/opt/ros/hydro/bin/roscore
lyf@lyf:~$ file /opt/ros/hydro/bin/roscore
/opt/ros/hydro/bin/roscore: a /usr/bin/python script, ASCII text executable

命令执行后通过log可以看到执行过程中的一些主要步骤,

lyf@lyf:~$ roscore
#①首先是log的文件夹
... logging to /home/lyf/.ros/log/f67227ba-685e-11e7-a44d-08002734e31e/roslaunch-lyf-2382.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

#②启动了roslunch server
started roslaunch server http://lyf:48578/
ros_comm version 1.10.12


SUMMARY
========

PARAMETERS
 * /rosdistro
 * /rosversion

NODES
#③启动了两个进程,master,pid为2396,rosout-1,pid为2409
auto-starting new master
process[master]: started with pid [2396]
ROS_MASTER_URI=http://lyf:11311/

setting /run_id to f67227ba-685e-11e7-a44d-08002734e31e
process[rosout-1]: started with pid [2409]
started core service [/rosout]
  1. 首先是log的文件夹,log文件对阅读源代码的作用还是比较大;
  2. 启动了roslunch server,url为http://lyf:48578/
  3. 启动了两个进程,master,pid为2396,rosout-1,pid为2409

后续,将通过源代码分析该过程。roscore的源代码的git地址为https://github.com/ros/ros_comm.git

这里写图片描述

ros_comm中包含了ros很多的基础框架的组件,

ROS communications-related packages, including core client libraries (roscpp, rospy, roslisp) and graph introspection tools (rostopic, rosnode, rosservice, rosparam)

而roscore就在tools下的roslaunch中,

这里写图片描述

roslaunch脚本只有两句话,其实是导入了roslaunch包,执行了roslaunch.main()函数,所以后续先分析roslaunch package。

#ros_comm\tools\roslaunch\scripts\roslaunch
import roslaunch
roslaunch.main()
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值