ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

paths for the package to ros envrionment variables, not found

asked 2018-01-11 09:00:14 -0500

finch1 gravatar image

Hi, have a package with one cpp file, worked great. added another cpp file and built the workspace, now rosrun can't locate the package any more. when creating the package I have implemented this command echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc , and have tried rospack profile which didn't list the path. why does this happen please?

edit retag flag offensive close merge delete

Comments

Please edit your question to provide more information. There's not enough here to reproduce your problem. Please provide the full context of commands you're running with their outputs and any debugging commands you're trying as well.

tfoote gravatar image tfoote  ( 2018-01-11 19:54:31 -0500 )edit

Hi tfoote, There is not much I can add.
1. (terminal 1) catkin_make <- builds 100%
2. (terminal 2) roscore
3. (terminal 3) rosrun package_name <- double tab doesn't resolve path

finch1 gravatar image finch1  ( 2018-01-12 02:31:41 -0500 )edit

Do you do a source ~/catkin_ws/devel/setup.bash after step 1? Your .bashrc is only evaluated when you open a new terminal, there is no magic there that makes bash update itself if/when you run catkin_make.

Without the source step, rosrun can't find your package.

gvdhoorn gravatar image gvdhoorn  ( 2018-01-12 03:02:13 -0500 )edit

Hi gvdhoorn, so how come turtlesim works fine all the time?
Isn't this the magic trick: echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc that makes bash update itself evertime catkin is run ?

finch1 gravatar image finch1  ( 2018-01-12 03:14:25 -0500 )edit

No. Again: .bashrc is only evaluated (ie: read) when you start a new instance of bash. That is typically only when you start a new terminal.

See What is the purpose of .bashrc and how does it work? for some more info on that.

gvdhoorn gravatar image gvdhoorn  ( 2018-01-12 03:36:30 -0500 )edit

how come turtlesim works fine all the time?

technical but: because the turtlesim packages were already present on the ROS_PACKAGE_PATH when you started your bash session.

Either in your catkin_ws or in /opt/ros/$distro.

gvdhoorn gravatar image gvdhoorn  ( 2018-01-12 03:38:53 -0500 )edit

And just to clarify: this is a "Linux thing", not something specific to ROS.

gvdhoorn gravatar image gvdhoorn  ( 2018-01-12 03:39:24 -0500 )edit

If you can confirm that things work after you source the setup.bash after you built your workspace, I'll write an answer.

gvdhoorn gravatar image gvdhoorn  ( 2018-01-12 03:40:01 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-01-12 04:11:28 -0500

gvdhoorn gravatar image

updated 2018-01-12 04:16:57 -0500

I had my VM paused from yesterday, turned PC on, resumed VM, opened one terminal, typed roscore, opened another one, typed rosrun package_name, hit tab key twice and the exe appeared.

Every time you open a new terminal, a new bash session is started.

if you have your .bashrc setup to do source ~/catkin_ws/devel/setup.bash for you, then new terminals will cause your workspace to be sourced.

If you add a package, build your workspace, then don't source it, the package will not be found.

If you now open a new terminal - as you say you did - that terminal will start a new bash session, causing your workspace to be sourced. And as the new package has now been built, it will be added to the appropriate environment variables and can then be found - in the new terminals - by rosrun and roslaunch.

For already open terminals (really: bash sessions), just source ~/catkin_ws/devel/setup.bash yourself, and new packages should now be found.


Edit: some related questions:

  • #q269784: setup.bash every time?
  • #q229365: Do I really need to $ source ~/catkin_ws/devel/setup.bash ?
  • #q200174: How to aviod running the command "source devel/setup.bash"
  • #q188309: What does source command actually do?
edit flag offensive delete link more

Comments

Thanks gvdhoorn, in my .bashrc, at the very bottom, I can see the source link to the package, as you're describing. In case this happenes again, I'm more than happy to write how I fixed the issue. But from what I understood, as long as the .bashrc has the source link, there shouldn't be any issues.

finch1 gravatar image finch1  ( 2018-01-12 04:22:17 -0500 )edit

in my .bashrc [..] I can see the source link to the package

Just to be extra clear: the source line points to the devel space, not to any package.

It can't, because package directories do not contain the necessary files.

gvdhoorn gravatar image gvdhoorn  ( 2018-01-12 04:25:19 -0500 )edit

Additionally: I only wrote about bash, but the same holds for other shells.

gvdhoorn gravatar image gvdhoorn  ( 2018-01-12 04:25:48 -0500 )edit

Thanks for the helpful links. I asked the question as this happened to me already, so yeah, thanks for your detailed explenation. still getting my head around things.

finch1 gravatar image finch1  ( 2018-01-12 04:40:06 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2018-01-11 09:00:14 -0500

Seen: 153 times

Last updated: Jan 12 '18