root@robot:~# export ROS_WORKSPACE=~/ros_workspace
root@robot:~# rosws init ~/ros_workspace /opt/ros/fuerte
Error: There already is a workspace config file .rosinstall at "/home/robot/ros_workspace". Use rosws install/modify.
root@robot:~# source ~/ros_workspace/setup.bash
root@robot:~# roscd
root@robot:~/ros_workspace# mkdir ~/ros_workspace/robot_vision
root@robot:~/ros_workspace# rosws set ~/ros_workspace/robot_vision
Add new elements:
robot_vision
Continue: (y)es, (n)o: y
Overwriting /home/robot/ros_workspace/.rosinstall
Do not forget to do ...
$ source /home/robot/ros_workspace/setup.sh
... in every open terminal.
root@robot:~/ros_workspace# source /home/robot/ros_workspace/setup.sh
source /home/robot/ros_workspace/setup.sh
//////////////////////////////////////////////////////////////////////
ROS 工作目录的设置(待完善,仅供参考)
ROS 安装完成后,按照网站的学校步骤,下一步就是进行基本命令的熟悉和Package的创建等入门动作,其中包括Pack的创建和搜索等。
但是运行roscd时,会提示没有设置的错误信息:No ROS_WORKSPACE set. Please set ROS_WORKSPACE to use roscd with no arguments.。。原来在安装ros系统后需要设置工作目录,这个步骤在一个比较隐蔽的地方,因此,没有发现,主要步骤如下:
To install rosws, install the Debian packagepython-rosinstall:
sudo apt-get install python-rosinstall
rosws is a tool that provides a uniform interface to various version control systems such as SVN, Git and Mercurial and for managing all packages installed in a ROS overlay. An extensive tutorial on rosws can be found here.
The following command creates a new overlay in ~/fuerte_workspace:
rosws init ~/fuerte_workspace /opt/ros/fuerte
This command creates the files setup.bash,setup.sh,setup.zsh and the hidden file.rosinstall in the directory~/fuerte_workspace. To use this new overlay, it is enough to just call:
source ~/fuerte_workspace/setup.bash (每次重新打开命令行时要运行此命令,设置工作目录,不知道怎么解决)
It is very common to replace the line source /opt/ros/fuerte/setup.bash to source the setup.bash in~/fuerte_workspace.
The overlay now includes all packages that were installed in /opt/ros/fuerte.
New packages need to be put in a path that is in the variable ROS_PACKAGE_PATH. All directories that are managed by rosws, i.e. that have been added using rosws are automatically added to theROS_PACKAGE_PATH when the filesetup.bash of the corresponding workspace is sourced. Although new packages should always be put in repositories that have been installed using rosws, it can be very convenient to have a sandbox directory where for instance packages created during the tutorials can be put without requiring any additional rosws commands. For that we create a new directory sandbox and add it to the.rosinstall file:
mkdir ~/fuerte_workspace/sandbox rosws set ~/fuerte_workspace/sandbox
Now, it is necessary to re-source ~/fuerte_workspace/setup.bash to make sure that the updatedROS_PACKAGE_PATH is used.
Development normally happens in repositories and when installing packages from source, they normally need to be checked out from a repository and added to theROS_PACKAGE_PATH. This can easily be done using rosws. For instance, the following commands add the development version of the stackturtlebot which is a Mercurial repository:
rosws set turtlebot --hg https://kforge.ros.org/turtlebot/turtlebot rosws update turtlebot
After re-sourcing setup.bash the new overlayed stackturtlebot should be in your package path, i.e.roscd turtlebot should switch to the directory~/fuerte_workspace/turtlebot.
If a stack is already installed in /opt/ros/fuerte, installing it using rosws will shadow the existing stack, i.e. instead of the system installation, the stack in~/fuerte_workspace will be used. That way, it is possible to edit existing packages by cloning them in the overlay.
Very often, users need to install a stack from source that is known to the ROS wiki indexer. In that case, a stack can be found using roslocate. For instance, executing
roslocate info turtlebot
prints a rosinstall file that can be directly used by rosws. To add the stackturtlebot to the current overlay and check it out, the following command can be used:
roslocate info turtlebot | rosws merge - rosws update
rosws allows to update only a single repository or all repositories:
rosws update turtlebot
updates only the stack turtlebot while
rosws updateupdates all repositories.
其中6和7 出现了错误,大致的看了下,是由于编码方式的原因,这个工具应该是使用Python编写的,由于对Python不是很熟悉,因此没有解决(希望解决的大侠能够告知,感激不尽),但是不影响接下来的操作。
接下来运行roscd,进入到工作目录下,然后运行命令
roscreate-pkg beginner_tutorials std_msgs rospy roscpp创建一个包。
$ rospack profile $ rospack find beginner_tutorials运行这两条命令,如果能够找到,测成功,否则的话可能是因为路径的原因,将我们的工作目录添加到包路径中,设置包路径的方法,
export ROS_PACKAGE_PATH=/opt/ros/fuerte/stacks:/opt/ros/fuerte/share/:/opt/ros/fuerte/share/ros:/home/lestat/fuerte_workspace/ 多个路径用 “:”分割,这里我们添加了路径///////////////////////////////////////////////////////////////////////////////////////////home/lestat/fuerte_workspace/再次运行find命令,成功。
按照上述方式设置的包路径在当前用户退出后就会失效,下次需要重新设置,为了让此路径长期有效,将其添加到~/.bashrc文件中。
echo "export ROS_PACKAGE_PATH=groovy_workspace:$ROS_PACKAGE_PATH" >> ~/.bashrc
echo "export ROS_WORKSPACE=groovy_workspace" >> ~/.bashrc
. ~/.bashrc