0
$\begingroup$

Rosanswers logo

Hi I'm trying to learn the ROS tutorial --> Writing a Simple Publisher and Subscriber (C++) In terminal it can find: rosrun turtlesim turtlesim_node but not: rosrun beginner_tutorials talker It give the message: [rospack] Error: package 'beginner_tutorials' not found

I have tried to find a solution in this side but I'm not sure what should I set in .bashrc, this is what I have in my file:

source /opt/ros/indigo/setup.bash
export ROS_ROOT=/opt/ros
export PATH=$ROS_ROOT/bin:$PATH
export ROS_MASTER_URI=http://mypc:11311/
export PYTHONPATH=$PYTHONPATH:$ROS_ROOT/opt/ros/indigo/lib/python2.7/dist-packages/roslib
#export PYTHONPATH=$PYTHONPATH:$ROS_ROOT/core/roslib/src
export PATH=$PATH:/usr/local/smr/bin
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/smr/lib"
# vim editor
export EDITOR='nano -w'
#export EDITOR='emacs -nw' 

Originally posted by RosUser on ROS Answers with karma: 81 on 2016-01-22

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

In your .bashrc, you shouldn't need to be messing with the PATH, PYTHONPATH, or ROS_ROOT environment variables (at least as far as ROS is concerned). The setup.bash files should be managing your environment for you. To see this, comment out all of the ROS stuff in your bashrc and open a new terminal. The command env |grep ROS should show you that you have not environment variables with ROS in them. Now run source /opt/ros/indigo/setup.bash, and then re-run env |grep ROS. Now you should see a bunch of ROS variables set. Finally, try sourcing the setup.bash file in your workspace; something like source ~/catkin_ws/devel/setup.bash. If you re-run env |grep ROS, you'll see that this setup.bash file has modified the environment variables. Now the current terminal should be setup to use your workspace "overlayed" on the base ROS install. Further, if beginner_tutorials is in this workspace, rosrun should now be able to find it.

EDIT

It is completely up to you to decide how and when particular setup.bash scripts should be sourced. If you only have one workspace, and you want every terminal to be using this workspace then you could source this workspace's setup.bash script in your bashrc. In a different scenario, let's say you have many workspaces that are all used fairly often. The best option then might be to only source the /opt/ros/indigo/setup.bash in your bashrc (that way every terminal can use ROS command line tools), and select which workspace is active in each individual terminal by manually sourcing the correct workspace setup.bash file.

The setup.bash files are automatically created when you run catkin_make for the first time. The setup.bash file that gets created for a particular workspace will "overlay" that workspace on top of the current environment. Sourcing any workspace's setup.bash is sufficient to setup your environment in the same configuration that was defined with the workspace was initially built. All you need to do to switch workspaces is source the correct setup.bash

More about these concepts can be read in the Using a Workspace and Workspace Overlaying catkin tutorials.


Originally posted by jarvisschultz with karma: 9031 on 2016-01-22

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by RosUser on 2016-01-22:
I have changed my .bashrc file to: source /opt/ros/indigo/setup.bash export ROS_ROOT=/opt/ros/indigo/share/ros export PATH=$ROS_ROOT/bin:$PATH export ROS_MASTER_URI=http://mypc:11311/ export ROS_PACKAGE_PATH=/home/hjt/catkin_ws/src:/opt/ros/indigo/share:/opt/ros/indigo/stacks

Comment by RosUser on 2016-01-22:
Okay now it is working, by running each time: source ./devel/setup.bash in a new terminal. Can I avoid this or do I have to run: source ./devel/setup.bash every time I have new terminal ?

Ps. And I have already included: source /opt/ros/indigo/setup.bash in my .bashrc file !

Comment by jarvisschultz on 2016-01-22:
I edited my answer to provide some more information about when and where to source the setup.bash files.

Comment by RosUser on 2016-01-25:
Thanks it is working

$\endgroup$

Your Answer

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