0
$\begingroup$

Rosanswers logo

Novice question:

I've created a custom message, package, etc as the official tutorial does. But when i do:

$ rosrun pkg_test1 pkg_test1_node

it gives me: [rospack] Error: package 'pkg_test1' not found

Indeed, if i do: $ source ~/catkin_ws/devel/setup.bash the problem is fixed. But do i really need to do that every time i want to use my custom programs? Is there any simple way to mantain them in the ROS path (i think that is what i am doing when i call these commands).

Thanks in advance.


Originally posted by thepirate16 on ROS Answers with karma: 101 on 2016-03-17

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Yes, you really do need to source a setup.bash file in every single terminal that you want to use ROS in. These scripts control many important ROS environment variables and non-ROS environment variables (PYTHONPATH, CMAKE_PREFIX_PATH, etc.). The setup.bash scripts provide a convenient way to control which version of ROS is "active" and which workspaces are "active" (see page on overlaying workspaces).

If you want every terminal to automatically "source" a particular setup.bash script, you could put that command in your ~/.bashrc. See the Environment Setup section of the ROS installation instructions.


Originally posted by jarvisschultz with karma: 9031 on 2016-03-17

This answer was ACCEPTED on the original site

Post score: 6


Original comments

Comment by thepirate16 on 2016-03-17:
Ok! Now i understand it! Thanks for the reply!

Comment by cartucho on 2020-03-25:
Shouldn't source /opt/ros/kinetic/setup.bash be enough? Do I really need to do source ~/catkin_ws/devel/setup.bash every single time that I want to use my custom packages?

Comment by gvdhoorn on 2020-03-25:
@cartucho: no, it cannot be enough.

/opt/ros/kinetic/setup.bash only "knows about" the packages installed under /opt/ros/kinetic. It contains no references to your own, custom packages in your catkin_ws. So if you source /opt/ros/kinetic/setup.bash, you only get access to the packages installed there.

What you don't need to do is source both the setup.bash in /opt/ros/kinetic and your catkin_ws. Just sourceing your catkin_ws should be sufficient to get you access to both sets of packages (provided you have setup your own workspace correctly).

Comment by cartucho on 2020-03-25:
thank you @gvdhoorn it worked!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.