Documente Academic
Documente Profesional
Documente Cultură
86 KenConley
ROS/Tutorials/NavigatingTheFilesystem
10/25/11 14:26:22
Note: This tutorial assumes that you have completed the previous tutorials: Installing and Configuring Your ROS Environment.
Contents 1. Quick Overview of Filesystem Concepts 2. Filesystem Tools 1. Using rospack and rosstack 2. Using roscd 3. Special cases for roscd 4. Using rosls 5. Tab Completion 3. Review
1/5
ROS/Tutorials/NavigatingTheFilesystem
10/25/11 14:26:22
Filesystem Tools
For ROS there is lots of code spread across many packages and stacks. Navigating with command-line tools such as ls and cd would be very tedious. This is why ROS provides its own tools to help you. Using rospack and rosstack rospack and rosstack are part of the rospack suite. These allow you to get information about packages and stacks. In this tutorial, we are only going to cover the find option, which returns the path to package or stack. Usage: $ rospack find [package_name] $ rosstack find [stack_name]
If, for example, you have used the binary install of ROS Electric on Ubuntu linux, you would see exactly: /opt/ros/electric/stacks/ros_comm/clients/cpp/roscpp
Using roscd roscd is part of the rosbash suite. It allows you to change directory (cd) directly to a package or a stack. Usage: $ roscd [locationname[/subdir]]
To verify that we have changed to the roscpp package directory. Now let's print the working directory using the Unix command pwd: $ pwd
You can see that YOUR_INSTALL_PATH/stacks/ros_comm/clients/cpp/roscpp is the same path that rospack find gave in the previous example. Note that roscd, like other ROS tools, will only find ROS packages that are below the directories listed in your $ROS_PACKAGE_PATH. To see what is in your $ROS_PACKAGE_PATH, type: 2/5
10/25/11 14:26:22
If you have not modified your $ROS_PACKAGE_PATH, you should see: YOUR_INSTALL_PATH/stacks
Similarly to other environment paths, you can add additional directories to your $ROS_PACKAGE_PATH, with each path separated by a colon ':'
Subdirectories
roscd can also move to a subdirectory of a package or stack. Try: $ roscd roscpp/include $ pwd
Special cases for roscd There are a few special places you can tell roscd to go, that are not a package or stack.
roscd with no arguments
roscd without an argument will take you to $ROS_ROOT. Try: $ roscd $ pwd
roscd log
roscd log will take you to the folder where ROS stores its log files. Note that if you have not run any ROS programs yet, this will yield an error saying that it does not yet exist. If you have run some ROS program before, try: $ roscd log
3/5
10/25/11 14:26:22
rosls is part of the rosbash suite. It allows you to ls directly in a package, stack, or common location by name rather than by package path. Usage: $ rosls [locationname[/subdir]]
Would return: add_two_ints_client listener listener_with_userdata srv add_two_ints_server listener_async_spin Makefile srv_gen add_two_ints_server_class listener_class manifest.xml talker anonymous_listener listener_multiple node_handle_namespaces time_api babbler listener_single_message notify_connect timers bin listener_threaded_spin parameters CMakeLists.txt listener_unreliable ROS_NOBUILD custom_callback_processing listener_with_tracked_object src
Tab Completion It can get tedious to type out an entire package name. In the previous example, roscpp_tutorials is a fairly long name. Luckily, some ROS tools support TAB completion. Start by typing: $ roscd roscpp_tut<<< now push the TAB key >>>
After pushing the TAB key, the command line should fill out the rest. $ roscd roscpp_tutorials/
This works because roscpp_tutorials is currently the only ROS package that starts with roscpp_tut. Now try typing: $ roscd tur<<< now push the TAB key >>>
After pushing the TAB key, the command line should fill out as much as possible: $ roscd turtle
However, in this case there are multiple packages that begin with turtle.
4/5
ROS/Tutorials/NavigatingTheFilesystem
10/25/11 14:26:22
Try typing TAB another time. This should display all the ROS packages that begin with turtle turtle_actionlib/ turtlesim/ turtle_tf/
Now type a s after turtle and then push TAB $ roscd turtles<<< now push the TAB key >>>
Since there is only one package that start with turtles, you should see: $ roscd turtlesim/
Review
You may have noticed a pattern with the naming of the ROS tools: rospack = ros + pack(age) rosstack = ros + stack roscd = ros + cd rosls = ros + ls This naming pattern holds for many of the ROS tools. Now that you can get around in ROS, let's create a new package.
5/5