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

Po-Jen Lai's profile - activity

2020-01-05 14:13:43 -0500 marked best answer How to store the depth data from kinect(/camera/depth_registrered/image_raw) as gray scale image?

I want to get the depth data from kinect by receiving sensor_msgs/Image from topic /camera/depth_registrered/image_raw(reference), I use cv_bridge to store the data to a gray scale image.

I use this snippet of code to receive sensor_msgs/Image from topic /camera/depth_registrered/image_raw, change it to gray scale image by cvBridge, and then store the image to a jpeg file.

#!/usr/bin/env python
import roslib
roslib.load_manifest('store_stereo_image')
import sys 
import rospy
import cv
from std_msgs.msg import String
from sensor_msgs.msg import Image
from cv_bridge import CvBridge, CvBridgeError

class image_converter:

  def __init__(self):
    self.bridge = CvBridge()
    self.image_sub = rospy.Subscriber("/camera/depth_registered/image_raw",Image,self.callback)

  def callback(self,data):
    try:
        cv_image = self.bridge.imgmsg_to_cv(data, "mono8")
        cv.SaveImage("depth_camera_msg.jpg", cv_image)
        print "image saved!"
    except CvBridgeError, e:
      print e

def main(args):
  ic = image_converter()
  rospy.init_node('image_converter', anonymous=True)
  try:
    rospy.spin()
  except KeyboardInterrupt:
    print "Shutting down"

if __name__ == '__main__':
    main(sys.argv)

This is the jpeg file I stored, I suppose the value in this picture should vary from 0 to 255. However, I found the values in this picture are either 0 or 255(only black and white).

image description

I use rostopic echo /camera/depth_registered/image_raw to check, I found that the data it published vary from 0~255, but I don't know why the image is only black and white~

Did I miss something? Thanks in advance.

---EDIT---

Thanks to DamienJadeDuff's comment, I learned that the raw data from msg sensor_msgs/Image is uint8, and the data contained in /camera/depth_registered/image_raw is uint16 depths in mm. Does this means depth data is retrieved from combining two uint8 data?

2019-06-12 22:44:34 -0500 received badge  Great Question (source)
2019-01-18 02:25:43 -0500 received badge  Nice Question (source)
2018-01-28 13:19:33 -0500 received badge  Famous Question (source)
2017-10-31 09:01:41 -0500 received badge  Notable Question (source)
2017-10-31 00:38:01 -0500 marked best answer Import error: No module named 'glob'

Dear all, I got an import error from executing roslaunch pr2_gazebo pr2_no_controllers.launch:

ros@ros-K401UB:~/research/gps$ roslaunch pr2_gazebo pr2_no_controllers.launch 
... logging to /home/ros/.ros/log/751a586e-bd85-11e7-a646-9c5c8ed99f00/roslaunch-ros-K401UB-4556.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

Traceback (most recent call last):
  File "/opt/ros/indigo/share/xacro/xacro.py", line 60, in <module>
    import xacro
  File "/opt/ros/indigo/lib/python2.7/dist-packages/xacro/__init__.py", line 36, in <module>
    import glob
ModuleNotFoundError: No module named 'glob'

while processing /opt/ros/indigo/share/pr2_description/robots/upload_pr2.launch:
Invalid <param> tag: Cannot load command parameter [robot_description]: command [/opt/ros/indigo/share/xacro/xacro.py '/opt/ros/indigo/share/pr2_description/robots/pr2.urdf.xacro'] returned with code [1]. 

Param xml is <param command="$(find xacro)/xacro.py '$(find pr2_description)/robots/pr2.urdf.xacro'" name="robot_description"/>
The traceback for the exception was written to the log file

However, I can import glob in python2.7:

ros@ros-K401UB:~/research/gps$ python2.7
Python 2.7.6 (default, Oct 26 2016, 20:30:19) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import glob
>>>

Also, I can locate it under /usr/lib/python2.7:

ros@ros-K401UB:/usr/lib/python2.7$ ls | grep glo
glob.py
glob.pyc

Thus, I guess that the problem occurs because the python executable which runs xacro.py can't locate the module glob in its path. So I tried to append /usr/lib/python2.7 to my PYTHONPATH, but this doesn't work.

Does anyone know how to solve this issue? Thanks for any suggestion : )

P.S. I am using Ubuntu 14.04+ROS Indigo, and my python -m site output this:

ros@ros-K401UB:~/research/gps$ python -m site
sys.path = [
    '/home/ros/research/gps',
    '/home/ros/research/tool/rllab',
    '/opt/ros/indigo/lib/python2.7/dist-packages',
    '/usr/lib/python2.7/dist-packages',
    '/home/ros/miniconda3/lib/python36.zip',
    '/home/ros/miniconda3/lib/python3.6',
    '/home/ros/miniconda3/lib/python3.6/lib-dynload',
    '/home/ros/miniconda3/lib/python3.6/site-packages',
    '/home/ros/code/gym',
    '/home/ros/miniconda3/lib/python3.6/site-packages/setuptools-27.2.0-py3.6.egg',
]
USER_BASE: '/home/ros/.local' (exists)
USER_SITE: '/home/ros/.local/lib/python3.6/site-packages' (doesn't exist)
ENABLE_USER_SITE: True

Reference:

  1. http://forum.erlerobotics.com/t/solve...
  2. https://stackoverflow.com/questions/4...
2017-10-30 20:25:45 -0500 received badge  Popular Question (source)
2017-10-30 20:10:23 -0500 edited answer Import error: No module named 'glob'

Based on the advice from jarvisschultz & bpinaya, I removed the miniconda/anaconda part in ~/.basrc: # added by Min

2017-10-30 20:09:49 -0500 answered a question Import error: No module named 'glob'

Based on the advice from jarvisschultz & bpinaya, I removed the miniconda/anaconda part in ~/.basrc: # added by Min

2017-10-30 20:09:11 -0500 commented question Import error: No module named 'glob'

Thanks to both of you jarvisschultz & bpinaya!!! The problem is caused by miniconda, I'll leave the result in the an

2017-10-30 10:35:05 -0500 edited question Import error: No module named 'glob'

Import error: No module named 'glob' Dear all, I got an import error from executing roslaunch pr2_gazebo pr2_no_controll

2017-10-30 10:34:22 -0500 asked a question Import error: No module named 'glob'

Import error: No module named 'glob' Dear all, I got an import error from executing roslaunch pr2_gazebo pr2_no_controll

2017-08-20 09:23:21 -0500 commented question How to stop moving of turtlebot on ROS Hydro Gazebo?

Hi! I cannot reproduce your problem. There seems no turtlebot_empty_world.launch in turtlebot_gazebo package: https://gi

2017-08-20 09:23:03 -0500 commented question How to stop moving of turtlebot on ROS Hydro Gazebo?

Hi! I cannot reproduce your problem. There seems no turtlebot_empty_world.launch in turtlebot_gazebo paxkage. https://g

2017-07-25 09:02:40 -0500 received badge  Good Question (source)
2017-03-01 07:40:42 -0500 received badge  Good Answer (source)
2017-01-26 06:38:18 -0500 received badge  Famous Question (source)
2016-12-20 17:32:26 -0500 received badge  Taxonomist
2016-09-21 01:47:31 -0500 received badge  Nice Question (source)
2016-09-12 05:24:30 -0500 received badge  Nice Answer (source)
2016-06-23 16:24:22 -0500 received badge  Nice Answer (source)
2016-05-31 08:22:45 -0500 marked best answer Does roslaunch support topic remapping from command line?

Hi all,

The roslaunch page says that we can remap topic by simply adding this line to launch file.

<remap from="chatter" to="hello"/>

I want to ask if we can do the same thing in command line?

roslaunch <package name> <launch file name> chatter:=hello

Thanks~

2016-04-26 08:35:31 -0500 marked best answer Error on genmsg/template_tools.py (AttributeError: 'module' object has no attribute 'Interpreter')

Hi all, I want to generate msg header files in a 64-bit Ubuntu 12.04 (ROS Hydro) by catkin_make agile_grasp_generate_messages. However, I got some error messages indicating that there's no Interpreter() in em module as the error occurs at the line interpreter = em.Interpreter(...) in genmsg/template_tools.py.

I think the error might relates to anaconda I installed before, because when I type python in my terminal, I got:

Python 2.7.9 |Anaconda 2.2.0 (64-bit)| (default, Mar  9 2015, 16:20:48) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>>

and when I locate em.py, there are many candidates: (but those em.py under nltk dir do not contain class Interpreter)

/home/rosfuerte/anaconda/lib/python2.7/site-packages/nltk/cluster/em.py
/home/rosfuerte/anaconda/lib/python2.7/site-packages/nltk/cluster/em.pyc
/home/rosfuerte/anaconda/pkgs/nltk-3.0.2-np19py27_0/lib/python2.7/site-packages/nltk/cluster/em.py
/home/rosfuerte/anaconda/pkgs/nltk-3.0.2-np19py27_0/lib/python2.7/site-packages/nltk/cluster/em.pyc
/usr/lib/pymodules/python2.7/em.py
/usr/lib/pymodules/python2.7/em.pyc
/usr/local/lib/python2.7/dist-packages/nltk/cluster/em.py
/usr/local/lib/python2.7/dist-packages/nltk/cluster/em.pyc
/usr/share/pyshared/em.py
/usr/share/software-center/softwarecenter/ui/gtk3/em.py

So I remove the anoconda from my path by export PATH=... to remove anaconda/bin from PATH variable. After that, when I type python, I got:

Python 2.7.3 (default, Jun 22 2015, 19:33:41) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

But even I set the PATH to exlude anaconda/bin, I still got the same error when I catkin_make agile_grasp_generate_messages. Does anyone know how to solve this problem?

FYI, here's my error messages: (I think the key error is AttributeError: 'module' object has no attribute 'Interpreter')

Generating Lisp code from agile_grasp/Grasps.msg
Generating Lisp code from agile_grasp/CloudSized.msg
Generating Lisp code from agile_grasp/Grasp.msg
Generating EusLisp code from agile_grasp/Grasp.msg
Generating EusLisp code from agile_grasp/CloudSized.msg
Generating EusLisp code from agile_grasp/Grasps.msg
[ 57%] Generating C++ code from agile_grasp/Grasp.msg
Generating EusLisp manifest code for agile_grasp
[ 64%] Traceback (most recent call last):
  File "/opt/ros/hydro/share/gencpp/cmake/../../../lib/gencpp/gen_cpp.py", line 49, in <module>
    srv_template_map)
  File "/opt/ros/hydro/lib/python2.7/dist-packages/genmsg/template_tools.py", line 215, in generate_from_command_line_options
    generate_from_file(argv[1], options.package, options.outdir, options.emdir, options.includepath, msg_template_dict, srv_template_dict)
  File "/opt/ros/hydro/lib/python2.7/dist-packages/genmsg/template_tools.py", line 156, in generate_from_file
    _generate_msg_from_file(input_file, output_dir, template_dir, search_path, package_name, msg_template_dict)
  File "/opt/ros/hydro/lib/python2.7/dist-packages/genmsg/template_tools.py", line 101, in _generate_msg_from_file
    search_path)
  File "/opt/ros/hydro/lib/python2.7/dist-packages/genmsg/template_tools ...
(more)
2016-04-05 06:16:13 -0500 marked best answer What does "Is /clock being published?" error means?

Hi all,

I want to test the function of tabletop_segmentation.But when my node send a service request to /tabletop_segmentation, I always get messages indicate that "NO_CLOUD_RECEIVED".

[ INFO] [1355922807.919213857, 1093.482000000]: Tabletop detection service called; waiting for a point_cloud2 on topic /narrow_stereo_textured/points2
[ERROR] [1355922813.224946787, 1096.538000000]: Tabletop object detector: no point_cloud2 has been received

The problem is /tabletop_segmentation node receive no data from /narrow_stereo_textured/points2.(This topic exists, though)

To test /narrow_stereo_textured/points2, I started gazebo by

  roslaunch manipulation_worlds pr2_table_object.launch

And I use rviz to see what /narrow_stereo_textured/points2 published, and I can see the content by changing Fixed frame from /map to /head_mount_kinect_ir_frame.

image description

However, when I try to rostopic echo this topic, I got

rosfuerte@rosfuerte-K53SM:~/project/nlp/libsvm-3.14$ rostopic echo /narrow_stereo_textured/points2
WARNING: no messages received and simulated time is active.
Is /clock being published?

And the segmentation fails as usual, does anyone know how to solve this problem? I want to test the function of segmentation alone. Thanks.

EDIT: This problem doesn't occur on another computer, which is also fuerte on ubuntu 12.04. I tried sudo apt-get dist-upgrade but I still got the error.

2016-03-17 06:34:45 -0500 received badge  Popular Question (source)
2016-01-12 11:10:03 -0500 received badge  Good Question (source)
2015-11-05 22:08:42 -0500 received badge  Notable Question (source)
2015-11-05 22:08:42 -0500 received badge  Famous Question (source)
2015-11-05 22:08:42 -0500 received badge  Popular Question (source)
2015-10-06 19:26:12 -0500 received badge  Famous Question (source)
2015-09-28 07:26:29 -0500 received badge  Nice Answer (source)
2015-08-25 04:30:34 -0500 received badge  Nice Answer (source)
2015-08-04 03:10:07 -0500 received badge  Notable Question (source)
2015-08-03 08:24:54 -0500 commented answer tf error base_link to map

The key is to find which node want this tf relationship.

2015-07-30 20:25:36 -0500 edited answer tf error base_link to map

The message is complaining that canTransform() is not able to get the relationship of simplebot/base_link to /map. This is because you only have a frame called "base_link" instead of "simplebot/base_link".

So modify your code by changing the arguments of canTransform().

2015-07-30 12:11:11 -0500 answered a question I want to checkout SLAM from https://code.ros.org/svn/ros-pkg/stacks/vslam/trunk by SVN,but the url cannot be available. how to get vslam_system.

There are some backup files in other people's repo:

https://github.com/limhyon/vslam

https://github.com/rhuitl/vslam

2015-07-30 12:05:30 -0500 commented question RGBDslam package missing node RGBDslam

Do you really got the executable when catkin_make?