Ask Your Question

K Chen's profile - activity

2020-05-27 06:44:42 -0500 received badge  Good Question (source)
2019-10-16 11:33:38 -0500 received badge  Nice Question (source)
2017-08-25 10:31:29 -0500 received badge  Good Question (source)
2017-08-25 07:25:48 -0500 received badge  Nice Question (source)
2016-07-21 10:31:16 -0500 received badge  Notable Question (source)
2016-07-21 10:31:16 -0500 received badge  Famous Question (source)
2016-07-21 10:31:16 -0500 received badge  Popular Question (source)
2016-05-01 15:50:05 -0500 received badge  Nice Question (source)
2016-01-07 11:27:13 -0500 commented answer rospy ImportError - cannot find custom module under src/ folder

But it's weird when I am printing out the sys.path, it does not include src path still, but when I import some file under 'src/foopy' using from foopy import foopkg it is working. How did python find foopkg.py?

2016-01-07 11:16:59 -0500 commented answer rospy ImportError - cannot find custom module under src/ folder

Many thanks for your reply! Problem resolved!

2016-01-07 04:13:41 -0500 asked a question rospy ImportError - cannot find custom module under src/ folder

Here are the steps to reproduce:

  1. create a new package under ~/catkin_ws/src:

    catkin_create_pkg foopy rospy
    
  2. create src/foopy folder and add __init__.py in it

  3. create a main.py under scripts/ folder:

#!/usr/bin/env python
# -*- coding: utf-8

import roslib; roslib.load_manifest('foopy')
import rospy

import sys
for f in sys.path:
    print f
Then chmod +x and execute it using: rosrun foopy main.py It prints:
/home/k/catkin_ws/src/foopy/scripts
/usr/local/lib/python2.7/dist-packages
/home/k/catkin_ws/devel/lib/python2.7/dist-packages
/opt/ros/indigo/lib/python2.7/dist-packages
/usr/lib/python2.7
...

Which does not include module foopy of my src/foopy folder. So when I import anything created under src/foopy/, it will raise an ImportError.

How to solve this issue?

2014-07-10 15:38:28 -0500 received badge  Famous Question (source)
2014-07-03 09:31:29 -0500 received badge  Notable Question (source)
2014-06-30 03:20:30 -0500 received badge  Famous Question (source)
2014-06-24 08:25:45 -0500 received badge  Notable Question (source)
2014-06-19 22:41:40 -0500 received badge  Popular Question (source)
2014-06-18 04:30:02 -0500 asked a question use custom built opencv along with cv_bridge

After updating to Hydro, the method mentioned in this answer does not work anymore, where I have to depend on cv_bridge to transfer sensor_msgs::Image to cv::Mat. The cmake will strike a warning:

  Cannot generate a safe runtime search path for target my_custom_node
  because there is a cycle in the constraint graph:
    dir 0 is [/usr/local/lib]
      dir 1 must precede it due to runtime library [libopencv_calib3d.so.2.4]
    dir 1 is [/opt/ros/hydro/lib]
      dir 0 must precede it due to runtime library [libopencv_videostab.so.2.4]

And the built binary is indeed linking the /opt/ros/hydro/lib/libopencv_xxx.so (checked with ldd).

So what is currently the right way to use custom built opencv, while I have dependency like cv_bride which depends on the opencv2 package?

Thanks for any suggestions.

2014-06-06 23:10:53 -0500 received badge  Enthusiast
2014-06-06 23:10:53 -0500 received badge  Enthusiast
2014-06-02 04:59:57 -0500 commented answer Packages without source cannot generate msgs?

Thanks for pointing out! It's indeed the problem.

2014-06-01 09:37:14 -0500 received badge  Popular Question (source)
2014-05-30 18:14:52 -0500 asked a question Packages without source cannot generate msgs?

I put several custom defined msgs in a package (named custom_msg_pkg), and this package does not contain any cpp or python sources. Then I have other packages depending on this package, using the provided custom msgs. But at compilation time (through catkin_make), the custom_msg_pkg is not being built first, so the compiler gives errors complaining not able to find the custom defined msgs in the custom_msg_pkg.

I am quite sure that I don't get it wrong in package.xml or CMakeLists.txt, since if I manually build them one by one, it works. So I think the problem lies in the order of building packages. In the custom_msg_pkg's CMakeLists.txt, I cannot add add_dependencies(executable custom_msg_pkg_generate_messages_cpp), so these messages are not built in the first place when I simple strike catkin_make.

So I am writing to ask:

  1. If there is some way to make the custom_msg_pkg built before the dependent packages?
  2. Is it a bad idea to have a package without source but only contains msg/srv files?

Thanks for any suggestions!

2014-04-20 06:50:30 -0500 marked best answer Messages lost between rospy and roscpp

I encountered a strange problem of losing some messages between roscpp node and rospy node. I can see my roscpp node publishing my defined message using rostopic echo, but the rospy node sometimes cannot receive them(sometimes it can). I tried to reproduce the problem but just end up with nothing.

The only clue I can get is when this happen, I use rxgraph to see the ros node graph, and it prints:

"unknown node reported: unknown node /XXX"

/XXX is the name of my rospy node. The rospy node uses 3 threads and it calls rospy.spin() in the main thread.

I am using electric under ubuntu 11.10. There are more than 10 nodes running when this problem happen.

Thank you for any help or suggestions.

2014-04-20 06:50:06 -0500 marked best answer load parameters from yaml file API

Is there a way to load .yaml file in C++ and override the parameters in some given namespace? I know this can be done in launch files using <rosparam load...>, but can I do it in my code? Thanks in advance.

2014-04-20 06:49:52 -0500 marked best answer rosbag record pointcloud2 and tf data best practice?

What is the best way to record pointcloud2 data? I tried rosbag record but the bag file becomes too large(2G) only for about 30 seconds. I tried -j to compress, but it cannot work with infinite buffer size(-b 0).

I tried: rosbag record -b 0 -O test.bag /tf /camera/rgb/points and rosbag record -b 0 -O test.bag -j /tf /camera/rgb/points

But both will exhaust all physical memory and throw a std::bad_alloc() exception then quit, so I have to limit the record to at most 80 seconds. Any option to drop down the frame rate or compress the pointcloud2 data into binary compressed .pcd files, but still maintain corresponding /tf data?

2014-04-20 06:48:39 -0500 marked best answer How to catch nodelet shutdown signal?

I created a new thread in a nodelet which runs some task until the nodelet is shutdown. But I don't know how to let the new thread know when the nodelet is shutting down, so for now it will make the whole nodelet_manager crash when I only wants to end that nodelet.

I tried to use getPrivateNodeHandle() to get the ros::NodeHandle instance, and use nodehandle.ok() to test whether the new thread should stop, sometimes it works, but sometimes not.

2014-04-20 06:48:39 -0500 marked best answer Nodelet multi-threading example

Hi all,

I am finding a way to separate some heavy load process into some standalone threads so that I could get other callbacks in time using nodelet. I looked at the nodelet wiki page but it has few description about its multi-threading model and usage, so I am wondering where I could find such usage examples or projects already doing this?

BTW, is creating my own threads using boost inside a nodelet a bad idea?

Thanks for any help.

2014-04-08 22:02:52 -0500 received badge  Great Question (source)
2014-04-08 22:02:48 -0500 marked best answer How to use newer versions of opencv in Fuerte

Recently I had an issue building my own package depending on cv_bridge package and a custom-built opencv library. I was able to solve the linking problem in previous ROS versions here, but later I found out that the package was in fact using the fuerte/include/opencv header, but linking with the right /usr/local/lib libs. Everything should be OK if the headers were not changed, but if they do, it will fail.

To find out why I listed all the include dirs in cmake, and I got the following result(only the first 5 items)

-- --> include dir='/home/kai/Projects/my_pkg/include'
-- --> include dir='/opt/ros/fuerte/include'
-- --> include dir='/usr/local/include/opencv'
-- --> include dir='/usr/local/include'
-- --> include dir='/opt/ros/fuerte/stacks/vision_opencv/cv_bridge/include'

As can be seen, the ros/fuerte/include dir precedes the /usr/local/include; as a result, even if I can find my custom-built opencv headers and libraries through FindPackage() in CMakeLists.txt from setting the right $CMAKE_PREFIX_PATH env var, the #include <opencv.h> will still find the ros/fuerte/include/opencv first.

To reproduce this problem, try the following:

  1. Install ros fuerte opencv package
  2. Download opencv from opencv.org and make&make install it with your own build options(namely, with CUDA)
  3. Create a package depending on cv_bridge package
  4. Follow the link provided above to make sure your CMakeLists.txt can use FindPackage() to find your custom built opencv package(default in /usr/local)
  5. Write some pieces of code using opencv's specific features(CUDA, if you built with it)
  6. rosmake or cmake ..& make it.
  7. Check the depend.make file under your_pkg/build/CMakeFiles/your_pkg.dir, find opencv occurrences, it will be /opt/ros/fuerte/include/opencv, not /usr/local/include/opencv

So what I am writing to ask is, is there any way to make my own opencv include path precedes the ros include path? Or it won't be found because there is a opencv/opencv2 dir in the fuerte/include dir and they will be found first. Currently I renamed ROS's provided opencv&opencv2 dirs names to hide them from being found, but I think there should be some better way.

Thanks in advance.