Search code examples
ros

How to run or launch a ros node without keeping the souce code


What I wanted

I want to reduce my docker image size through removing a cloned source code from my workspace in 'src' directory according to this suggestion. For that matter, I have just deployed my source code using the following commands:

    # install package
   sudo catkin config --install
   catkin_make
   catkin_make install

The problem

As a result, install directory generate with many other library folders. I then navigated in to /share/ folder and tried to roslaunch one of my launch file. This is the error that I got:

ERROR: cannot launch node of type [oxford_gps_eth/gps_node]: oxford_gps_eth
ROS path [0]=/opt/ros/melodic/share/ros
ROS path [1]=/home/ubuntu/catkin_ws/src
ROS path [2]=/opt/ros/melodic/share

No processes to monitor shutting down processing monitor...

Expectation

I was able to launch my node, even being in /install/share/ directory without removing the cloned source code in 'src' directory. I wanted to launch my nodes after building and remove my source code so that I can utilize my image.


Solution

  • You have to source install/setup.bash. This script will setup your environmental variables such as PYHONPATH and is what roslaunch uses to find packages.