Ask Your Question

graeme's profile - activity

2020-09-19 14:53:46 -0600 received badge  Popular Question (source)
2020-09-19 14:53:46 -0600 received badge  Famous Question (source)
2020-09-19 14:53:46 -0600 received badge  Notable Question (source)
2020-07-10 12:15:44 -0600 received badge  Editor (source)
2020-07-10 12:15:44 -0600 edited answer Module Import Problem. (ModuleNotFoundError: No module named 'foo.msg'; 'foo' is not a package

For anyone else running into this problem. My solution was PATH based. The module search paths were not identical. It

2020-07-10 12:14:21 -0600 marked best answer Module Import Problem. (ModuleNotFoundError: No module named 'foo.msg'; 'foo' is not a package

I am trying to compile a two variable simple message. When I include the message from the python command line it works:

pi@ws:~/ros_ws $ python3
Python 3.7.3 (default, Dec 20 2019, 18:57:59) 
[GCC 8.3.0] on linux>>> from ws_gps_manager.msg import gpsframe2
>>> a=gpsframe2()
>>> a
gps_lat: 0.0
gps_long: 0.0
>>>

However when I run it from inside the ros package I get an error:

pi@ws:~/ros_ws $ /home/pi/ros_ws/src/ws_gps_manager/scripts/ws_gps_manager.py
3.7.3 (default, Dec 20 2019, 18:57:59) 
[GCC 8.3.0]
['/home/pi/ros_ws/src/ws_gps_manager/scripts', '/home/pi/ros_ws/devel/lib/python3/dist-packages', '/home/pi/ros_catkin_ws/install/lib/python3/dist-packages', '/home/pi/.local/lib/python3.7/site-packages', '/usr/lib/python37.zip', '/usr/lib/python3.7', '/usr/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/dist-packages', '/usr/lib/python3/dist-packages']
3.7.3 (default, Dec 20 2019, 18:57:59) 
Traceback (most recent call last):
  File "/home/pi/ros_ws/src/ws_gps_manager/scripts/ws_gps_manager.py", line 19, in <module>
    from ws_gps_manager.msg import gpsframe2
  File "/home/pi/ros_ws/src/ws_gps_manager/scripts/ws_gps_manager.py", line 19, in <module>
    from ws_gps_manager.msg import gpsframe2
ModuleNotFoundError: No module named 'ws_gps_manager.msg'; 'ws_gps_manager' is not a package

I have correctly modified my CMakefile.txt and package.xmlas described here: http://wiki.ros.org/ROS/Tutorials/Cre... (I also copied a working CMake and package file from a completely different project and got the same result) The rest of the code works perfectly as long as I don't use that custom msg.

catkin_make install compiles cleanly.

The pertinent part at the top of the python script is as follows:

#!/usr/bin/env python3
import sys
print(sys.version)
print(sys.path)
import rospy
from std_msgs.msg import String,Float64
from ws_gps_manager.msg import gpsframe2

The contents of the msg file is:

float64 gps_lat
float64 gps_long

Showing that the script and the command line are executing the same version of python and they have the same package path.

 /usr/bin/env python3 returns Python3.7.3

So my question: Why does the include work from the command line, but not from the rosrun or direct execution of the script using the shebang?? The paths are the same, the module is the same, the compile completes.

(I'm on melodic)

2020-07-10 12:14:21 -0600 received badge  Scholar (source)
2020-07-10 12:14:10 -0600 received badge  Rapid Responder (source)
2020-07-10 12:14:10 -0600 answered a question Module Import Problem. (ModuleNotFoundError: No module named 'foo.msg'; 'foo' is not a package

For anyone else running into this problem. My solution was PATH based. It seems that the script is adding its own dire

2020-07-09 20:48:46 -0600 edited question Module Import Problem. (ModuleNotFoundError: No module named 'foo.msg'; 'foo' is not a package

Module Import Problem. (ModuleNotFoundError: No module named 'foo.msg'; 'foo' is not a package I am trying to compile a

2020-07-09 20:46:56 -0600 asked a question Module Import Problem. (ModuleNotFoundError: No module named 'foo.msg'; 'foo' is not a package

Module Import Problem. (ModuleNotFoundError: No module named 'foo.msg'; 'foo' is not a package I am trying to compile a

2019-03-01 12:40:32 -0600 marked best answer OpenCV difference between roslaunch and rosrun
OS: Ubuntu 16.04.2 LTS Xenial
ROS: Kinetic.
OPenCV: 3.2.0-dev
Python 2.7.12
ROS_ROOT=/opt/ros/kinetic/share/ros
ROS_PACKAGE_PATH=/home/odroid/ros_ws/src:/opt/ros/kinetic/share
ROS_MASTER_URI=http://localhost:11311
ROSLISP_PACKAGE_DIRECTORIES=/home/odroid/ros_ws/devel/share/common-lisp
ROS_DISTRO=kinetic
ROS_ETC_DIR=/opt/ros/kinetic/etc/ros

If I run a python script through a launch file, OpenCV cannot open a camera, but running it manually openCV works fine.

Here’s the bare bones Code Snippet where it works/fails.

 print cv2.__version__
   camera=cv2.VideoCapture("/dev/video8")
   print camera
   if not camera.isOpened():
       camera=None
       print "No camera"
   return camera

Here’s the line from the launch file:

<node name="whisker_sensor" pkg="ros_whisker_sensor" type="whisker_sensor.py" respawn="false" output="screen"/>

Here’s the output of the screen dump from that launch:

….
process[whisker_sensor-10]: started with pid [32257]
3.2.0-dev
<VideoCapture 0xb6d487b0>
No camera
….

Notice it sets up a camera Object, but it fails to open.

However if I kill the specific node and then re-run it manually from a rosrun command: like this:

odroid@fish01:~$ rosnode kill /whisker_sensor ; rosrun ros_whisker_sensor whisker_sensor.py
killing /whisker_sensor
killed
3.2.0-dev
<VideoCapture 0xb6d017b0>
136 0.723058982284
136 0.723058982284
134 0.731470868094

It passes the isOpened() check and starts dumping the data I’m looking for from a processed image.

Does anyone have any thoughts as to why camera.isOpened() fails under a roslaunch but works under a rosrun? Is there any way I can get more informative information out of the camera function? I have a feeling its a path or library issue, but I can't figure out what's different between the launch file and run approaches.

2018-04-05 02:44:08 -0600 received badge  Famous Question (source)
2018-01-31 15:40:42 -0600 answered a question OpenCV difference between roslaunch and rosrun

I ended up installing usb_cam as suggested,(I'm going to use it eventually) but in the process discovered the solution f

2018-01-27 11:57:44 -0600 received badge  Notable Question (source)
2018-01-25 23:39:21 -0600 received badge  Student (source)
2018-01-25 23:37:33 -0600 received badge  Popular Question (source)
2018-01-25 15:22:22 -0600 asked a question OpenCV difference between roslaunch and rosrun

OpenCV difference between roslaunch and rosrun OS: Ubuntu 16.04.2 LTS Xenial ROS: Kinetic. OPenCV: 3.2.0-dev Python 2.7.

2018-01-25 15:22:00 -0600 asked a question OpenCV roslaunch vs rosrun problem.

OpenCV roslaunch vs rosrun problem. OS: Ubuntu 16.04.2 LTS Xenial ROS: Kinetic. OPenCV: 3.2.0-dev Python 2.7.12 ROS_ROOT