douglasrizzo / dodo_detector_ros

Object detection from images/point cloud using ROS
BSD 3-Clause "New" or "Revised" License
54 stars 11 forks source link

How to run this code in ros kinetic #13

Closed yani-rl-ai closed 4 years ago

yani-rl-ai commented 4 years ago

hi @douglasrizzo , i tried to use your code, i found some errors due to the python version between ros and Dodo detector. Could you give me some tutorial in detail to run this code?

thank you in advance

error message :

(dodoTF) kubota-lab@kubotalab-P960EF:~/dodo_ws$ roslaunch dodo_detector_ros detect_kinect.launch
... logging to /home/kubota-lab/.ros/log/98b04c1a-fcdf-11ea-8592-5076afa87c35/roslaunch-kubotalab-P960EF-17153.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.

started roslaunch server http://192.168.3.18:39851/

SUMMARY
========

PARAMETERS
 * /camera/camera_nodelet_manager/num_worker_threads: 4
 * /camera/depth_rectify_depth/interpolation: 0
 * /camera/driver/color_depth_synchronization: False
 * /camera/driver/color_mode: 5
 * /camera/driver/depth_camera_info_url: 
 * /camera/driver/depth_frame_id: camera_depth_opti...
 * /camera/driver/depth_mode: 5
 * /camera/driver/depth_registration: False
 * /camera/driver/device_id: #1
 * /camera/driver/id_manufacturer: 1d27
 * /camera/driver/id_product: 0601
 * /camera/driver/ir_mode: 5
 * /camera/driver/rgb_camera_info_url: 
 * /camera/driver/rgb_frame_id: camera_rgb_optica...
 * /dodo_detector_ros/detector_type: tf
 * /dodo_detector_ros/image_topic: /camera/rgb/image...
 * /dodo_detector_ros/label_map: ~/.dodo_detector_...
 * /dodo_detector_ros/model_dir: ~/.dodo_detector_...
 * /dodo_detector_ros/point_cloud_topic: /camera/depth/points
 * /dodo_detector_ros/sift_database_path: ~/.dodo_detector_...
 * /dodo_detector_ros/sift_min_pts: 10
 * /dodo_detector_ros/tf_confidence: 0.5
 * /rosdistro: kinetic
 * /rosversion: 1.12.16

NODES
  /camera/
    camera_nodelet_manager (nodelet/nodelet)
    depth_metric (nodelet/nodelet)
    depth_metric_rect (nodelet/nodelet)
    depth_points (nodelet/nodelet)
    depth_rectify_depth (nodelet/nodelet)
    depth_registered_sw_metric_rect (nodelet/nodelet)
    driver (nodelet/nodelet)
    points_xyzrgb_sw_registered (nodelet/nodelet)
    register_depth_rgb (nodelet/nodelet)
    rgb_rectify_color (nodelet/nodelet)
  /
    camera_base_link (tf2_ros/static_transform_publisher)
    camera_base_link1 (tf2_ros/static_transform_publisher)
    camera_base_link2 (tf2_ros/static_transform_publisher)
    camera_base_link3 (tf2_ros/static_transform_publisher)
    dodo_detector_ros (dodo_detector_ros/detector.py)

ROS_MASTER_URI=http://192.168.3.18:11311/

process[camera/camera_nodelet_manager-1]: started with pid [17172]
process[camera/driver-2]: started with pid [17173]
process[camera/rgb_rectify_color-3]: started with pid [17174]
process[camera/depth_rectify_depth-4]: started with pid [17177]
[FATAL] [1600785401.910544972]: Failed to load nodelet '/camera/driver` of type `openni2_camera/OpenNI2DriverNodelet` to manager `camera_nodelet_manager'
process[camera/depth_metric_rect-5]: started with pid [17193]
[FATAL] [1600785401.915437517]: Failed to load nodelet '/camera/rgb_rectify_color` of type `image_proc/rectify` to manager `camera_nodelet_manager'
process[camera/depth_metric-6]: started with pid [17204]
[FATAL] [1600785401.923444755]: Failed to load nodelet '/camera/depth_rectify_depth` of type `image_proc/rectify` to manager `camera_nodelet_manager'
process[camera/depth_points-7]: started with pid [17221]
process[camera/register_depth_rgb-8]: started with pid [17224]
process[camera/points_xyzrgb_sw_registered-9]: started with pid [17242]
[FATAL] [1600785401.936025092]: Failed to load nodelet '/camera/depth_metric_rect` of type `depth_image_proc/convert_metric` to manager `camera_nodelet_manager'
process[camera/depth_registered_sw_metric_rect-10]: started with pid [17263]
[ INFO] [1600785401.941649751]: Initializing nodelet with 4 worker threads.
process[camera_base_link-11]: started with pid [17283]
process[camera_base_link1-12]: started with pid [17303]
process[camera_base_link2-13]: started with pid [17323]
process[camera_base_link3-14]: started with pid [17338]
process[dodo_detector_ros-15]: started with pid [17361]
[camera/driver-2] process has died [pid 17173, exit code 255, cmd /opt/ros/kinetic/lib/nodelet/nodelet load openni2_camera/OpenNI2DriverNodelet camera_nodelet_manager --no-bond ir:=ir rgb:=rgb depth:=depth depth_registered:=depth_registered rgb/image:=rgb/image_raw depth/image:=depth_registered/image_raw __name:=driver __log:=/home/kubota-lab/.ros/log/98b04c1a-fcdf-11ea-8592-5076afa87c35/camera-driver-2.log].
log file: /home/kubota-lab/.ros/log/98b04c1a-fcdf-11ea-8592-5076afa87c35/camera-driver-2*.log
[ERROR] [1600785402.046675411]: Failed to find nodelet with name '/camera/depth_rectify_depth' to unload.
[ERROR] [1600785402.049082404]: Failed to find nodelet with name '/camera/driver' to unload.
[ERROR] [1600785402.049156902]: Failed to find nodelet with name '/camera/depth_metric_rect' to unload.
[ERROR] [1600785402.049268860]: Failed to find nodelet with name '/camera/rgb_rectify_color' to unload.
[camera/rgb_rectify_color-3] process has died [pid 17174, exit code 255, cmd /opt/ros/kinetic/lib/nodelet/nodelet load image_proc/rectify camera_nodelet_manager --no-bond image_mono:=rgb/image_raw image_rect:=rgb/image_rect_color __name:=rgb_rectify_color __log:=/home/kubota-lab/.ros/log/98b04c1a-fcdf-11ea-8592-5076afa87c35/camera-rgb_rectify_color-3.log].
log file: /home/kubota-lab/.ros/log/98b04c1a-fcdf-11ea-8592-5076afa87c35/camera-rgb_rectify_color-3*.log
[camera/depth_rectify_depth-4] process has died [pid 17177, exit code 255, cmd /opt/ros/kinetic/lib/nodelet/nodelet load image_proc/rectify camera_nodelet_manager --no-bond image_mono:=depth/image_raw image_rect:=depth/image_rect_raw __name:=depth_rectify_depth __log:=/home/kubota-lab/.ros/log/98b04c1a-fcdf-11ea-8592-5076afa87c35/camera-depth_rectify_depth-4.log].
log file: /home/kubota-lab/.ros/log/98b04c1a-fcdf-11ea-8592-5076afa87c35/camera-depth_rectify_depth-4*.log
[camera/depth_metric_rect-5] process has died [pid 17193, exit code 255, cmd /opt/ros/kinetic/lib/nodelet/nodelet load depth_image_proc/convert_metric camera_nodelet_manager --no-bond image_raw:=depth/image_rect_raw image:=depth/image_rect __name:=depth_metric_rect __log:=/home/kubota-lab/.ros/log/98b04c1a-fcdf-11ea-8592-5076afa87c35/camera-depth_metric_rect-5.log].
log file: /home/kubota-lab/.ros/log/98b04c1a-fcdf-11ea-8592-5076afa87c35/camera-depth_metric_rect-5*.log
Traceback (most recent call last):
  File "/home/kubota-lab/dodo_ws/src/dodo_detector_ros/src/detector.py", line 6, in <module>
    import tf
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf/__init__.py", line 28, in <module>
    from tf2_ros import TransformException as Exception, ConnectivityException, LookupException, ExtrapolationException
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_ros/__init__.py", line 38, in <module>
    from tf2_py import *
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/tf2_py/__init__.py", line 38, in <module>
    from ._tf2 import *
ImportError: dynamic module does not define module export function (PyInit__tf2)
[dodo_detector_ros-15] process has died [pid 17361, exit code 1, cmd /home/kubota-lab/dodo_ws/src/dodo_detector_ros/src/detector.py __name:=dodo_detector_ros __log:=/home/kubota-lab/.ros/log/98b04c1a-fcdf-11ea-8592-5076afa87c35/dodo_detector_ros-15.log].
log file: /home/kubota-lab/.ros/log/98b04c1a-fcdf-11ea-8592-5076afa87c35/dodo_detector_ros-15*.log
douglasrizzo commented 4 years ago

Can you tell me what was the problem? Maybe there is some code in dodo_detector that is only compatible with Python 3?

yani-rl-ai commented 4 years ago

my problem is i got some error when i launched the project. i changed the config setting based on my camera topic and launch file. but the issues come out such as my above command. which version of ROS did u use for this project? can you give me some short tutorial how to run this code in ROS.

douglasrizzo commented 4 years ago

Here is your error: https://answers.ros.org/question/326226/importerror-dynamic-module-does-not-define-module-export-function-pyinit__tf2/

Your computer is running my package using Python 3, when it should be using Python 2.

Here is the line in my code that tells ROS how to run my Python module:

https://github.com/douglasrizzo/dodo_detector_ros/blob/5f975ac183b92ab587b8f402fa35d92f35cde778/src/detector.py#L1

I use env [1] to find the Python executable in the user's machine. IIRC, python should point to Python 2 in Ubuntu 16.04 (more specifically, the python2 executable). In your case, python is calling Python 3 instead of Python 2.

Try to change that shebang to point directly to your preferred version of Python 2 and see if it fixes your problem.

yani-rl-ai commented 4 years ago

Thank you for your rapid answer. maybe i have some misunderstanding with your packages. First of all, i used python 3 because i thought your dodo detector original package can only run in python 3, so i assumed the ROS package should use some python 3 environments setting. i will try again soon sorry for my bad english

douglasrizzo commented 4 years ago

It's been quite a while since I've last used dodo_detector_ros. Looking at the recent changes, I think you're actually right. I updated this package to work with dodo_detector 0.7, but dodo_detector 0.7 only works with Python 3 mostly because of TensorFlow 2, which has been updated to only work on Python 3.

I'll have to sit down and take a look at this, but maybe I'll have to make this package use a an older version of dodo_detector (probably 0.6.1), since ROS only works with Python 2.

Until then, use commit https://github.com/douglasrizzo/dodo_detector_ros/commit/017266438f3fd7fc20a9b074fe568ef80f900188 of dodo_detector_ros and version 0.6.1 of dodo_detector.

I'm really sorry for the mix up. I'll sort this out as soon as I can.

yani-rl-ai commented 4 years ago

Hi @douglasrizzo thank you for your reply. i tried to follow your recommendation file. i installed the version 0.6.1 (which is python 2), then i tried to install tensorflow (1.15) object detection API. i got an error when i installed it into python 2.7 environment, due to it is only compatible with python 3.6>. Do you have any suggestion?

FYI, i used anaconda to install all the requirement.

douglasrizzo commented 4 years ago

You'd need to find the latest commit in the TensorFlow Object Detection API that works with Python 2.7. I went to their releases and singled out a few commits you can test:

If any of these commits work for you, I'd appreciate if you warn me, because then I could point other ROS/Python 2.7 users to the correct commit.

Edit: please note that the TensorFlow versions I mentioned above are not the ones you'll have to install. Find the latest TensorFlow version that can be installed under Python 2.7, then try to install the Object Detection API using the commits above and see if it works.

yani-rl-ai commented 4 years ago

hey @douglasrizzo , thank you for your answer.

actually i already tests all the link that you shared to me, i tested it on tensorflow-gpu. i found some error and difficulty. FYI, I used CUDA 10.1. when i tested version 1 in tensorflow cpu i did not find any error. but when i tested it on tensorflow gpu. the cuda version is not compatible with my version, i need to change my cuda version(too complicated)

in addition, this below commits TensorFlow 2.1 (Oct 9, 2019) TensorFlow 2.2 (Nov 13, 2019) is not compatible with tensorflow 2 gpu and cpu, these files use library in tensorflow 1, which is not compatible if i run it in tensorflow 2, i need to convert the models script with the provided tools from tensorflow.

douglasrizzo commented 4 years ago

Can you tell me what you did to successfully execute the package?