ROS_MASTER_URI set, but program gives related error.
Hello, I have ubuntu 14.04 , Ros indigo and Gazebo 2.2.6. I am running a gazebo_ros_control simulation, a simple robot with two movable joints. I can move the robot with rostopic commands. The problem is, that I am trying to publish messages to the topics from another program running in the same PC, but I get the following error:
ROS_MASTER_URI is not defined in the environment. Either type the following or (preferrably) add this to your ~/.bashrc
file in order set up your local machine as a ROS master:
export ROS_MASTER_URI=http://localhost:11311
then, type 'roscore' in another shell to actually launch the master program.
I have set ROS_MASTER_URI and ROS_IP to my .bashrc file and sourced it. I have tried setting ROS_MASTER_URI and ROS_HOSTNAME. I have tried setting all three of them. I have tried using "192.168.1.2 " instead of "localhost". I have tried to echo the variables and I get the expected result. Ι even tried to format my pc and reinstall everything, in case of broken packages. I always get the same error. What could be the problem?
edit: The output of env | grep -i ros | sort
ROS_ROOT=/opt/ros
ROS_PACKAGE_PATH=/home/sofia/catkin_ws/src:/home/sofia/catkin_ws/src:/opt/ros/indigo/share:/opt/ros/indigo/stacks
ROS_MASTER_URI=http://192.168.1.2:11311
LD_LIBRARY_PATH=/home/sofia/catkin_ws/devel/lib:/opt/ros/indigo/lib
CPATH=/home/sofia/catkin_ws/devel/include:/opt/ros/indigo/include
PATH=/opt/ros/bin:/opt/ros/indigo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
ROSLISP_PACKAGE_DIRECTORIES=/home/sofia/catkin_ws/devel/share/common-lisp
ROS_DISTRO=indigo
PYTHONPATH=/home/sofia/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/indigo/lib/python2.7/dist-packages
ROS_IP=192.168.1.2
PKG_CONFIG_PATH=/home/sofia/catkin_ws/devel/lib/pkgconfig:/opt/ros/indigo/lib/pkgconfig
CMAKE_PREFIX_PATH=/home/sofia/catkin_ws/devel:/opt/ros/indigo
ROS_ETC_DIR=/opt/ros/indigo/etc/ros
the lines I added to .bashrc
source /opt/ros/indigo/setup.bash
source ~/catkin_ws/devel/setup.bash
export GAZEBO_MODEL_PATH=/home/sofia/catkin_ws/src/
export GAZEBO_PLUGIN_PATH=$PWD:$GAZEBO_PLUGIN_PATH
export ROS_PACKAGE_PATH=/home/sofia/catkin_ws/src:$ROS_PACKAGE_PATH
export ROS_ROOT=/opt/ros
export PATH=$ROS_ROOT/bin:$PATH
export ROS_MASTER_URI=http://192.168.1.2:11311
export ROS_IP=192.168.1.2
export ROS_HOSTNAME=192.168.1.2
Edit2: The only reason I started changing ROS variables was the error I am getting by the program.
env | grep -i ros
output without exporting any ROS enviroment variables:
CMAKE_PREFIX_PATH=/home/sofia/catkin_ws/devel:/opt/ros/indigo
CPATH=/home/sofia/catkin_ws/devel/include:/opt/ros/indigo/include
LD_LIBRARY_PATH=/home/sofia/catkin_ws/devel/lib:/opt/ros/indigo/lib
PATH=/opt/ros/indigo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
PKG_CONFIG_PATH ...
Please add the output of
env | grep -i ros | sort
to your question (use the edit button/link for that), as well as all lines that you added to your.bashrc
to try and fix this.Ok, I edited my question. Thank you.
Just a test: comment the lines which
export
the following variables:ROS_PACKAGE_PATH
,ROS_ROOT
,PATH
,ROS_MASTER_URI
,ROS_IP
andROS_HOSTNAME
.For a single PC setup almost all of those should not be needed.
Then start a new terminal, remove the
build
anddevel
folders .... from your
~/catkin_ws
, runcatkin_make
(orcatkin build
) again, source~/catkin_ws/devel/setup.bash
and try to run your programs again.I'm curious to know why you decided to override
ROS_ROOT
andROS_PACKAGE_PATH
like that?Overriding
ROS_ROOT
like that is not a good idea.re: edit2: please don't post updates in comments. Edit your original question. I've merged your comments into your question, but please keep it in mind.
These values are what I would expect for a normal, single PC, ROS setup.
re: still getting error: do you get the error for all ros nodes? what about
talker
andlistener
from the ros_tutorials package?If those work, then I think we'll need to take a look at the code of the program / node you use to "publish messages to the topics from another program running in the same PC".
I just tested simple publisher and subscriber and they work. I will try to look at the code, which is not mine. I thought I had some problems with my configuration because the code does not produce errors to the person that wrote it.