ROS 环境变量-----简介


1 ROS必须的环境变量

   执行命令: source /opt/ros/ROSDISTRO/setup.bash (Replace ROSDISTRO with the desired ROS distribution, e.g. indigo.)可以完成设置。

   当然通常是添加该命令到~/.bashrc,系统启动自动设置这些必须的环境变量。

注意:1)如果执行source /opt/ros/<distro>/setup.bash,它会撤销已有设置的改变(换句话如果先source自己工作空间的setup.bash,再source  opt安装的setup.bash, 自己工作空间的一些设置,比如ROS_PACKAGE_PATH就会被撤销);

       2)如果再执行catkin_init_workspace , catkin_make后会有source /home/<user>/catkin_ws/devel/setup.bash执行,之前的设置(opt那边的ROS setup)会自动追加到home下的setup里。

1.1 ROS_ROOT

ROS_ROOT sets the location where the ROS core packages are installed.

export ROS_ROOT=/home/user/ros/ros
export PATH=$ROS_ROOT/bin:$PATH

注意:该包给出ROS 核心通讯组件的路径


1.2 ROS_MASTER_URI

ROS_MASTER_URI is a required setting that tells nodes where they can locate the master. It should be set to the XML-RPC URI of the master. Great care should be taken when usinglocalhost, as that can lead to unintended behaviors with remotely launched nodes.

export ROS_MASTER_URI=http://mia:11311/

注意:它给出ROS MASTER的URI,一般是本机上,11311端口。

1.3 PYTHONPATH

ROS requires that your PYTHONPATH be updated,even if you don't program in Python! Many ROS infrastructure tools rely on Python and need access to the roslib package for bootstrapping.

export PYTHONPATH=$PYTHONPATH:$ROS_ROOT/core/roslib/src

注意:这个是python寻找package时的路径,如果有误的话,import ROS相关的包就会找不到


2 PATH相关环境变量

2.1 ROS_PACKAGE_PATH

ROS_PACKAGE_PATH is an optional, but very common environment variable that allows you to add more ROS packages from source to your environment.ROS_PACKAGE_PATH can be composed of one or more paths separated by your standard OS path separator (e.g. ':' on Unix-like systems). Theseordered paths tell the ROS system where to search for more ROS packages. If there are multiple packages of the same name, ROS will choose the one that appears onROS_PACKAGE_PATH first.

export ROS_PACKAGE_PATH=/home/user/ros/ros-pkg:/another/path

Note that each entry in ROS_PACKAGE_PATH is searched recursively--all ROS packages below the named path will be found.

With the introduction of catkin, ROS_PACKAGE_PATH becomes obsolete, and will be kept only for backwards compatibility with rosbuild packages.

注意:这个环境变量主要影响ROS文件系统工具查找ros package,对于自建的catkin_ws如果 不把它的路径加入到该环境变量的话,无法通过ROS命令行工具以及roslaunch 来运行或者调用catkin_ws里面的包。

2.2 PATH

这个是通用Linux系统命令行中执行命令查找路径使用。但是对于ROS来讲,如果PATH 中没有你ROS相关的目录的话,也没有没办法使用ROS命令行工具。可以作为check考虑点

3 ROS系统生成数据相关环境变量

3.1 ROS_HOME

By default, ROS writes data to ~/.ros. This location can be changed by settingROS_HOME. You can also change the location of certain individual directories in~/.ros (e.g. ROS_TEST_RESULTS_DIR,ROS_LOG_DIR).

3.2 ROS_LOG_DIR

By default, ROS writes internal log files to ROS_HOME/log. If this location is not writable to ROS, or if you wish for log files to be written elsewhere, set ROS_LOG_DIR to that path.

3.3 ROS_TEST_RESULTS_DIR

Directory that test results should be written to.

4 ROS Bash相关环境变量

4.1 ROS_LOCATIONS

ROS_LOCATIONS is an optional environment variable that provides keyed names for useful locations. It is a: separated list of key-location pairs. Each key-location pair is separated by an=. For example:

export ROS_LOCATIONS="rospkg=/path/to/rospkg:stairpkg=/path/to/stairpkg"

These keys can then be used in tools such as roscd.

4.2 ROS_WORKSPACE

ROS_WORKSPACE is introduced by the rosinstall / rosws tools, it is set by setup.sh that is generated by these tools when creating a workspace. It points to the folder of the workspace and is used by the rosws command as a default target of the command.

The roscd tool in fuerte was also changed to use that variable when called without arguments. Previously it had defaulted to change toROS_ROOT.

5 ROS Node环境变量

5.1 ROS_IP/ROS_HOSTNAME

ROS_IP and ROS_HOSTNAME are optional environment variable that sets the declared network address of a ROSNode or tool. The options are mutually exclusive, if both are set ROS_HOSTNAME will take precedence. Use ROS_IP if you are specifying an IP address, and ROS_HOSTNAME if you are specifying a host name. When a ROS component reports a URI to the master or other components, this value will be used. This setting is only needed in situations where you have multiple addresses for a computer and need to force ROS to a particular one.

With the exception of 'localhost', it does not affect the actual bound address as ROS components bind to all available network interfaces. If the value is set to localhost, the ROS component will bind only to the loopback interface. This will prevent remote components from being able to talk to your local component.

注意:常用于多机通讯中表明自己所在网咯位置,ROS_IPROS_HOSTNAME设置好一个即可。

5.2 ROS_NAMESPACE

ROS_NAMESPACE lets you push down a Node into a namespace. All of the names in the Node will be resolved relative to this value, including remapped names.

注意:表示本机的namespace,本机node中的name都会有这个namespace前缀。

5.3 ROSCONSOLE_CONFIG_FILE

This is a roscpp-specific environment variable. rosconsole lets you define your own configuration file that will be used by log4cxx, defined by the ROSCONSOLE_CONFIG_FILE environment variable. Anything defined in this config file will override the default config file.

See http://ros.org/doc/api/rosconsole/html/index.html for more information.

5.4 Console Output Formatting

rosconsole allows you to specify how you'd like its output to show up in the console output through theROSCONSOLE_FORMAT environment variable. The default is equivalent to:

export ROSCONSOLE_FORMAT='[${severity}] [${time}]: ${message}'

See http://ros.org/doc/api/rosconsole/html/index.html for more information on this package in general. You can see the list of parsed format stringsin the source code.

.5 .5 ROS_PYTHON_LOG_CONFIG_FILE

This is specific to rospy, rosmaster,roslaunch, and rostest. For these tools, you can define your own Python logging configuration file to use instead of the default config file, which is stored in$ROS_ROOT/config/python_logging.conf.

For more information, see the Python logging documentation:

http://docs.python.org/library/logging.html

6 Build系统环境变量

In order to understand these environment variables better, please see the section on theROS Build System.

6.1 ROS_BOOST_ROOT

ROS_BOOST_ROOT is an optional environment variable that lets you override where to search for boost. IfROS_BOOST_ROOT is not set it defaults to using ROS_BINDEPS_PATH

6.2 ROS_PARALLEL_JOBS

The value of this variable, if set, is passed to make when building packages. The idea is to let you exploit a multi-processor machine. For example, if you have 8 processors / cores and want to run as many parallel jobs as possible, as long as the system load is less than 8, by limiting the jobs to 8 you prevent overshoot at startup time:

export ROS_PARALLEL_JOBS='-j8 -l8'

Alternatively, you could use the -j flag with an argument to run up to 8 jobs in parallel, independent of system load:

export ROS_PARALLEL_JOBS=-j8

We strongly recommend using the -l flag to set a system load-dependent limit on parallelism. Excessive parallelism in a large build can exhaust system memory.

What system load is acceptable to you depends on how many cores you have:http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages

So 8 might be suitable for a machine with 8 cores.

6.3 ROS_LANG_DISABLE

A colon-separated list of package names for message generators / client libraries that should be disabled. Message-generation will not happen for languages in this list.

For packages build with catkin you need to list the names of the message generators which should be ignored, e.g.:

export ROS_LANG_DISABLE=genlisp

For packages build with rosbuild you need to list the names of the message generatorsas well as the client libraries which should be ignored, e.g.:

export ROS_LANG_DISABLE=genlisp:roslisp

When ignoring message generators with rosbuild the CMake configure step will show a warning that the client library (e.g.roslisp) is not a known message generator. This warning can safely be ignored.

Note that before disabling a language, you should first be very sure that none of the code you're using requires that language's bindings.

6.4 ROS_OS_OVERRIDE

Format: "OS_NAME:OS_VERSION_STRING" This will force it to detect Ubuntu Lucid:

export ROS_OS_OVERRIDE=ubuntu:10.04

If defined, this will override the autodetection of an OS. This can be useful when debugging rosdep dependencies on alien platforms, when platforms are actually very similar and might need be forced, or of course if the autodetection is failing.


6.5

6.5 Other Build envs

$CPATH  $CMAKE_PREFIX_PATH  $LD_LIBRARY_PATH  $PKG_CONFIG_PATH


  • 3
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值