I wanted to connect to the turtlesim tutorial example from the base workspace using a node I created in my own custom workspace, by following the topics of the turtlesim node like pose, cmd_vel, etc., that's what I did:
In a terminal I run the roscore command, the master node ran perfectly
In another terminal where I sourced the base workspace via the command $ source ~/base_catkin_ws/devel/setup.bash, I ran the turtlesim node with $ rosrun turtlesim turtlesim_node, and it did open the simulator just perfectly
I sourced my own workspace in another terminal to be able to run my node, using the command $ source ~/catkin_ws/devel/setup.bash
However, when I run my own node using rosrun, I get the following error:
Traceback (most recent call last):
File "/home/hesham/catkin_ws/src/turtle_bot/src/turtle_bot.py", line 4, in <module>
from turtlesim.msg import Pose
ModuleNotFoundError: No module named 'turtlesim'
For clarification, I had to import the turtlesim message from the base ROS workspace so that I can communicate with the turtlesim node, subscribing to its position.
I'm new to ROS, that's why I wrote every command I run considering this issue.
I tried to work around this issue, first I sourced the base workspace in this terminal too, so that the turtlesim module can be recognized, then I run my node simply with python command $ python3 turtle_bot.py, it did everything expected from the node, that's how I know nothing is wrong in the code itself.
I also know that if I joined my workspace to the base workspace everything will be fine, but my question is: Is there another way to do it?
I also want to state the following:
In a normal ROS distribution, I know that to setup the ROS environment I have to type $ source /opt/ros/noetic/setup.bash, and the output to $ echo $ROS_PACKAGE_PATH would be:
/opt/ros/noetic/share
However, in our case, we source the base workspace with $ source ~/base_catkin_ws/devel/setup.bash, but strangely enough for me, when I navigate the ROS_PACKAGE_PATH, I get the following:
I wanted to connect to the turtlesim tutorial example from the base workspace using a node I created in my own custom workspace, by following the topics of the turtlesim node like pose, cmd_vel, etc., that's what I did:
roscore
command, the master node ran perfectly$ source ~/base_catkin_ws/devel/setup.bash
, I ran the turtlesim node with$ rosrun turtlesim turtlesim_node
, and it did open the simulator just perfectly$ source ~/catkin_ws/devel/setup.bash
rosrun
, I get the following error:I tried to work around this issue, first I sourced the base workspace in this terminal too, so that the turtlesim module can be recognized, then I run my node simply with python command
$ python3 turtle_bot.py
, it did everything expected from the node, that's how I know nothing is wrong in the code itself. I also know that if I joined my workspace to the base workspace everything will be fine, but my question is: Is there another way to do it?I also want to state the following:
$ source /opt/ros/noetic/setup.bash
, and the output to$ echo $ROS_PACKAGE_PATH
would be:$ source ~/base_catkin_ws/devel/setup.bash
, but strangely enough for me, when I navigate the ROS_PACKAGE_PATH, I get the following:Is that ok?
so the workspace overlays the base ROS environment, however, in our case, the workspace is overridden, hence I get the following new ROS_PACKAGE_PATH:
Is there a solution for that? Is something wrong with my build? Thanks so much in advance!