ROS基础

ROS环境配置

查看ROS环境设置

printenv | grep ROS

ROS_ETC_DIR=/opt/ros/melodic/etc/ros
ROS_ROOT=/opt/ros/melodic/share/ros
ROS_MASTER_URI=http://localhost:11311
ROS_VERSION=1
ROS_PYTHON_VERSION=2
ROS_PACKAGE_PATH=/home/yottayuan/catkin_ws/src:/opt/ros/melodic/share
ROSLISP_PACKAGE_DIRECTORIES=/home/yottayuan/catkin_ws/devel/share/common-lisp
ROS_DISTRO=melodic

变量说明

ROS_ROOT: ROS核心包的安装位置
里面文件如下图:


ROS基础_第1张图片
ROS_ROOT文件夹内容.png

ROS_MASTER_URI:主节点地址
ROS_MASTER_URI 变量指示子节点去哪里连接主节点

将ROS环境加入.bashrc

code ~/.bashrc
source /opt/ros/melodic/setup.bash

创建ROS工作空间

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/
catkin_make

为了方便后面不用多次source devel/setup.bash
将source ~/catkin_ws/devel/setup.bash 写入.bashrc
重新执行printenv | grep ROS,
ROS_PACKAGE_PATH增加新创建的工作空间路径:
ROS_PACKAGE_PATH=/home/yottayuan/catkin_ws/src

工作空间

工作空间由4部分组成:
Source Space
Build Space
Development(Devel) Space
Install Space

ROS文件命令

rospack find
roscd
rosls

创建ROS包

cd ~/catkin_ws/src
catkin_create_pkg beginner_tutorials std_msgs rospy roscpp
ROS基础_第2张图片
创建ROS包

你可能感兴趣的:(ROS基础)