
Hi Everyone,
I have read/tried various solutions in an attempt to debug ROS in VS Code without any luck. Can I please get some help in solving this mystery?
My workspace runs fine from when I run from an Ubuntu terminal prompt and from an IDE terminal prompt. source devel/setup.bash rosrun location tagsub.py
My env: Ubuntu 16.04 VS Code IDE ROS extension installed
My ROS package: Name: location Simple pub/sub with a custom message
From an Ubuntu terminal prompt I go to my workspace root, and start code. In VS Code terminal (which is on my workspace root), run catkin build then roscore. In the lower left corner of IDE, ROS Master now has a check mark.
I then created a launch configuration by:
clicking on the debug icon on the left most part of the IDE
clicking on the gear icon on the upper left section of the IDE, this opens a new launch.json file
click on the the button Add Configuration...(in the lower right of the window). This pulls up a window of choices
choose {} ROS : rosrun
Here is my launch entry:
{ "request": "launch", "type": "ros", "command": "rosrun", "name": "rosrun", "package": "location", "target": "tagsub.py", "debugSettings": "debugSettings" }Click on my source file tagsub.py file tag in the editer window
Press F5
The debug process starts and get this error: Exception has occurred: str
'No module named rospy'
File "/home/zzfl0b/location/src/location/scripts/tagsub.py", line 3, in <module>
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
In IDE terminal pip list | grep ros returns:
gazebo-ros 2.5.17
rosbag 1.12.13
rosboost-cfg 1.14.3
rosclean 1.14.3
roscreate 1.14.3
rosgraph 1.12.13
roslaunch 1.12.13
roslib 1.14.3
roslint 0.11.0
roslz4 1.12.13
rosmake 1.14.3
rosmaster 1.12.13
rosmsg 1.12.13
rosnode 1.12.13
rosparam 1.12.13
rospy 1.12.13
rosservice 1.12.13
rostest 1.12.13
rostopic 1.12.13
rosunit 1.14.3
roswtf 1.12.13
smach-ros 2.0.1
tf2-ros 0.5.17
Also from an IDE terminal prompt,
$ env | grep ros:
ROS_ROOT=/opt/ros/kinetic/share/ros
ROS_PACKAGE_PATH=/home/jeff/location/src/roscpp:/home/jeff/location/src/rospy:/home/jeff/location/src/std_msgs:/home/jeff/location/src/location:/opt/ros/kinetic/share
LD_LIBRARY_PATH=/home/jeff/location/devel/lib:/opt/ros/kinetic/lib:/opt/ros/kinetic/lib/x86_64-linux-gnu:/usr/local/cuda/lib64:/usr/local/cuda/lib64
PATH=/opt/ros/kinetic/bin:/usr/local/cuda/bin:/usr/local/cuda/bin:/home/jeff/bin:/home/jeff/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PYTHONPATH=/home/jeff/location/devel/lib/python2.7/dist-packages:/opt/ros/kinetic/lib/python2.7/dist-packages
PKG_CONFIG_PATH=/home/jeff/location/devel/lib/pkgconfig:/opt/ros/kinetic/lib/pkgconfig:/opt/ros/kinetic/lib/x86_64-linux-gnu/pkgconfig
CMAKE_PREFIX_PATH=/home/jeff/location/devel:/opt/ros/kinetic
ROS_ETC_DIR=/opt/ros/kinetic/etc/ros
Thank you for your help.
Originally posted by JeffBlumenthal on ROS Answers with karma: 23 on 2018-08-20
Post score: 2
Original comments
Comment by Choco93 on 2018-08-21:
you need to setup your environment for debugging and source that path, then run your package and link it from VSCode
Comment by JeffBlumenthal on 2018-08-21:
@Choco93, can you please be more specific on how to do this? I have also tried running source devel/setup.bash from a launch pretask and it still is not working. Thank you.