📖
Wiki
Back to my personal website
  • Home
  • Equipment and Devices
    • 3D Printer
    • Laser Cutter
    • Motion Capture System
    • Sensors
      • RGB-D Cameras
      • Velodyne LiDAR
      • Zed Camera
      • RealSense D435i
      • IMU
    • eGPU
    • Nvidia AGX Xavier
    • CPU Benchmark
    • Installation Checklist
  • Development
    • Linux
      • Shell
      • GDB
      • Git
      • Tmux
      • Network
      • Tricks
      • Debug FAQ
    • CMake
      • Catkin Tools
      • CMakeLists
      • CMake Variables
      • CMake Commands
      • CMake: find_package()
    • ROS
      • Gazebo
      • wstool
      • roslaunch
      • rosbag
      • multi-threaded spinner
    • ROS2
      • Convert ROS1 bag to ROS2 bag
    • C++
      • C++ 11
      • C++ Examples
      • C++ Debug
      • Factory Method
      • Timing
    • Google Tools
      • GLog
      • GFlags
      • GTest
      • Style Guide
      • Clang Format
    • PCL
      • Point Type
      • Methods
      • Architecture
      • Code Explained
    • Open3D
      • Python API
      • Registration
      • Visualization
      • Tools
    • OpenCV
      • Documentation
      • Modules
    • Other Libraries
      • Eigen
      • Ceres
      • g2o
      • GTSAM
    • Website
  • Algorithm
    • SLAM
      • K-D Tree
      • Octree
      • Bag of Words
      • Distance Measures
      • Coordinate Systems
      • LOAM
      • Iterative Closest Point
      • Generalized ICP
      • Mahalanobis Distance
    • Computer Science
      • Computational Model
      • Sorting
      • Analysis
      • Complexity Classes (P, NP)
      • Divide and Conquer
      • Greedy Algorithm
      • Dynamic Programming
      • Tree
      • Graph
    • Computer Vision
      • Camera Models
      • Distortion
      • Motion Models
      • Shutter
      • Image Sensors
      • Epipolar Geometry
      • Multiple-View Geometry
    • Datasets
      • RGB-D Datasets
      • Point Cloud Datasets
      • LiDAR SLAM Datasets
  • Math
    • Optimization
      • Convex Optimization
      • Descent Methods
    • Probability
      • Moment
      • Covariance Matrix
      • Stochastic Process
    • Topology
      • References
      • Concepts
      • Topological Spaces
      • Representation of Rotations
      • Representation of 3-sphere
    • Algebra
      • Linear Algebra
      • Matrix Factorization
      • Condition Number
      • Matrix Lie Group
    • Differential Geometry
      • Manifold
      • Submanifold
      • Quotient Manifolds
      • Tangent Space
  • Quadrotor
    • PX4 Development
    • Companion Computer
    • Drone Hardware
    • Propeller Lock
    • Debug
  • Favorites
    • Bookmarks
Powered by GitBook
On this page
  • Environment Variables in Linux
  • Where ROS commands are installed?
  • How could ROS auto-complete the package name?

Was this helpful?

  1. Development
  2. ROS

roslaunch

PreviouswstoolNextrosbag

Last updated 5 years ago

Was this helpful?

This note is trying to answer the following two questions.

  • What happens after I type roslaunch in the terminal?

  • How could the Linux know the commands and help me auto-complete it?

We will introduce some basics about environment variables in Linux and the concept of search path.

Environment Variables in Linux

First of all, no matter what kind of command you type in the terminal, it must exist in one of the directories indicated in the PATH environment variable. This is where the Linux terminal will search first. For example, ls cat commands are in /bin directory; python command is under directory/usr/bin.

To auto-complete, the system must know all possible commands given the existing characters you type in the terminal. This is somehow like to complete a English word given the first X characters, where you can search in a dictionary for all possible solutions. Likewise, Linux can search all executables in the directories listed in PATH env. Once it finds there is a unique solution, it will help you complete it.

To find the exact path for each command you type in, you can use which command. For example, if you trywhich python in the terminal, it will return to you the search result of the command python. You can also do this for the which command itself. Try it.

user@hostname$ which python
/usr/bin/python

Where ROS commands are installed?

Next, we will talk about how ROS handles the search path.

For all ROS-related commands, in order to run in the terminal, it has to be an Linux executable. This is an universal rule in Linux with no exceptions. Note that the first directory listed in PATH env is /opt/ros/kinetic/bin. You got it! This is where all the ROS commands exist. Open the folder and you will find python scripts like roslaunch, rqt_graph, etc.

Go ahead and open the roslaunch script. What? Only two lines of code?

#!/usr/bin/python

# Software License
# etc...

import roslaunch
roslaunch.main()

Yes, it is. roslaunch was installed as a Python 2.7 library in the system.

Then the following question is, how could python know where to import roslaunch?

Check the first directory in the PYTHONPATH env!

/home/hteng/catkin_ws/devel/lib/python2.7/dist-packages

Here we go! Open this folder and you will see all the ROS-related python programs.

How could ROS auto-complete the package name?

The third environment variable we would like to talk about is the ROS_PACKAGE_PATH. This is where ROS will search when you are typing a package name right after roslaunch and rosrun.

roslaunch turtlebot_br    [press Tab, then it becomes]
roslaunch turtlebot_bringup

How could ROS know all the possible package names? I believe now you can guess the answer. Yes, it will search all the directories listed in the ROS_PACKAGE_PATH.

That's all for today! Have fun!

Three important PATH env in ROS