Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all 131 articles
Browse latest View live

Can anyone give a better understanding of this piece of code?

$
0
0
I have a question regarding the following lines in the node given [here](http://wiki.ros.org/cv_bridge/Tutorials/UsingCvBridgeToConvertBetweenROSImagesAndOpenCVImages) : class ImageConverter { ros::NodeHandle nh_; image_transport::ImageTransport it_; ........ ....... public: ImageConverter() : it_(nh_) { ..... .... } I know that the constructor is assigning the value of `nh_` to `it_`, but are they not variables of different type? If they are not, how can we know that?

Is there any point in using image_transport republish instead of using CompressedImage in Python?

$
0
0
I have a Python ROS node that subscribes to a topic of message type CompressedImage. So far it works fine (I play a rosbag with compressed images, run my node, and it correctly reads them [I checked using cv2.imshow()]. I'm probably misunderstanding what the point of compressed_image_transport is. If I have a ROS node (say usb_cam) publishing compressed image messages, and my Python node subscribes to those compressed images (specifying sensor_msgs.msg.CompressedImage as the message type), why would I ever need image_transport or republish for my node (I know it's being used in the publishing node, i.e. usb_cam).

How to use image_transport with nodelets?

$
0
0
**What I need help with:** I am having a lot of trouble getting inter-nodelet image_transport to work. I tried making my code work like one of the nodelets in the `image_proc` package, and I got code that compiles but breaks when it tries do image passing. I suspect I am generating a null pointer, but I'm not sure how to do it correctly. I will attach my code, which consists of two files, "Read.cpp" and "Write.cpp". My goal is for the Read nodelet to read an image, pass it to the Write nodelet, which writes the image to a file. It does not work. **Code:** Here is Read.cpp #include #include #include #include #include #include #include #include #include namespace tensor_nodelets{ class Read : public nodelet::Nodelet{ public: Read() {} private: virtual void onInit(){ ros::NodeHandle& private_nh = getPrivateNodeHandle(); ros::NodeHandle nh_in (private_nh, "camera"); ros::NodeHandle nh_out (private_nh, "camera_out"); it_in_.reset(new image_transport::ImageTransport(nh_in)); it_out_.reset(new image_transport::ImageTransport(nh_out)); sub = private_nh.subscribe("in", 10, &Read::callback, this); image_transport::SubscriberStatusCallback connect_cb = boost::bind(&Read::connect_cb, this); ros::SubscriberStatusCallback connect_cb_info = boost::bind(&Read::connect_cb, this); pub = it_out_->advertiseCamera("image_raw",1, connect_cb,connect_cb, connect_cb_info,connect_cb_info); cv_im = cv::imread("/home/user/testim.png"); cv::imwrite("/home/user/imout.png",cv_im); im_msg = cv_bridge::CvImage(std_msgs::Header(), "bgr8", cv_im).toImageMsg(); } void callback(const std_msgs::Float64::ConstPtr& input){ ROS_INFO("Read callback called, writing image\n"); sensor_msgs::CameraInfoPtr info_msg = sensor_msgs::CameraInfoPtr(); pub.publish(im_msg, info_msg); } void connect_cb() {} // I don't understand what this is here for ros::Subscriber sub; cv::Mat cv_im; sensor_msgs::ImagePtr im_msg; image_transport::CameraPublisher pub; boost::shared_ptr it_in_, it_out_; }; PLUGINLIB_DECLARE_CLASS(tensor_nodelets, Read, tensor_nodelets::Read, nodelet::Nodelet); } Here is Write.cpp #include #include #include #include #include #include #include #include #include namespace tensor_nodelets{ class Write : public nodelet::Nodelet{ public: Write() {} private: virtual void onInit(){ ros::NodeHandle& private_nh = getPrivateNodeHandle(); ros::NodeHandle nh_in (private_nh, "camera"); ros::NodeHandle nh_out (private_nh, "camera_out"); it_in_.reset(new image_transport::ImageTransport(nh_in)); it_out_.reset(new image_transport::ImageTransport(nh_out)); image_transport::TransportHints hints("raw",ros::TransportHints(), private_nh); sub = it_in_->subscribeCamera("image_raw", 1, &Write::im_callback, this, hints); } void im_callback(const sensor_msgs::ImageConstPtr& image_msg, const sensor_msgs::CameraInfoConstPtr& info_msg) { // do stuff here ROS_INFO("Write callback called!\n"); } image_transport::CameraSubscriber sub; boost::shared_ptr it_in_, it_out_; }; PLUGINLIB_DECLARE_CLASS(tensor_nodelets, Write, tensor_nodelets::Write, nodelet::Nodelet); } // namespace tensor_nodelets Here is test.launch Here is the error when I `rostopic pub /Read/in` with any value: [ INFO] [1474930160.984040156]: Read callback called, writing image [standalone_nodelet-2] process has died [pid 7646, exit code -11, cmd /home/rbeethe/ros_catkin_ws/install_isolated/lib/nodelet/nodelet manager __name:=standalone_nodelet __log:=/home/rbeethe/.ros/log/738a30e8-843b-11e6-b6f4-e4b31812fc91/standalone_nodelet-2.log]. log file: /home/rbeethe/.ros/log/738a30e8-843b-11e6-b6f4-e4b31812fc91/standalone_nodelet-2*.log [ INFO] [1474930164.495058369]: Bond broken, exiting [ INFO] [1474930164.495729260]: Bond broken, exiting [Read-3] process has finished cleanly log file: /home/rbeethe/.ros/log/738a30e8-843b-11e6-b6f4-e4b31812fc91/Read-3*.log [Write-4] process has finished cleanly log file: /home/rbeethe/.ros/log/738a30e8-843b-11e6-b6f4-e4b31812fc91/Write-4*.log

Using image transport publisher to publish depth values

$
0
0
I am obtaining a depth image from zed camera using its [zed-ros-wrapper](http://wiki.ros.org/zed-ros-wrapper). I am using [this conversion node](http://wiki.ros.org/cv_bridge/Tutorials/UsingCvBridgeToConvertBetweenROSImagesAndOpenCVImages) to convert the ros image into OpenCV image. Are there any ways to use the `image transport publisher` to publish the depth value of an individual pixel (say (359,639)) of the OpenCV image? More specifically, can I edit the following line from the conversion node above to obtain that value? image_pub_.publish(cv_ptr->toImageMsg()); I know how to print such values to the terminal. I also know how to write a normal Publisher. But I am not able to incorporate such a publisher to the conversion node given above (You can see the problem [here](http://answers.ros.org/question/245254/adding-a-publisher-to-a-fully-functional-node/) and [here](http://answers.ros.org/question/244975/the-node-getting-killed-after-few-runs-when-publisher-is-added/)). But since I have not been able to progress much with that approach, I am trying the alternative mentioned in the question. Any suggestions/solutions/approaches are welcome.

Best way to send images from ROS to a Windows machine

$
0
0
Hello everyone, I am trying to get images from my robot running ROS in a Windows machine to use with Oculus Rift. I don't know what should be the best way to accomplish this. I thought about using socket, but I had bad experiences in the past with sockets. I would to know if there is a better option to receive images in a Windows machine. Thank you very much for any help. :)

GPU pointer in image_transport

$
0
0
Is it possible to pass a pointer to a block of GPU memory in image_transport as an image message? If full functionality is not possible, is it at least possible for two nodelets to be able to pass GPU images, even if other processes can't access them?

CMake Error image_transport when trying to catkin_make project

$
0
0
I am working on ROS Indigo and I am trying to build a simple app that would show the image published by the Astra camera. I do this by subscribing to the following topic `/camera/rgb/image_raw`. But when running `catkin_make` I get the following error: CMake Error at /home/turtlebot/catkin_ws/devel/share/image_transport/cmake/image_transportConfig.cmake:106 (message): Project 'image_transport' specifies '/home/turtlebot/catkin_ws/src/image_common/image_transport/include' as an include dir, which is not found. It does neither exist as an absolute directory nor in '/home/turtlebot/catkin_ws/src/image_common/image_transport//home/turtlebot/catkin_ws/src/image_common/image_transport/include'. Ask the maintainer 'Jack O'Quin , Vincent Rabaud ' to fix it. Call Stack (most recent call first): /opt/ros/indigo/share/catkin/cmake/catkinConfig.cmake:75 (find_package) detect_green_object/CMakeLists.txt:3 (find_package) Here is my code, CMakeLists.txt and package.xml #include #include #include #include void imageCallback(const sensor_msgs::ImageConstPtr& msg) { try { cv::imshow("view", cv_bridge::toCvShare(msg, "bgr8")->image); cv::waitKey(30); } catch (cv_bridge::Exception& e) { ROS_ERROR("Could not convert from '%s' to 'bgr8'.", msg->encoding.c_str()); } } int main(int argc, char **argv) { ros::init(argc, argv, "image_listener"); ros::NodeHandle nh; cv::namedWindow("view"); cv::startWindowThread(); image_transport::ImageTransport it(nh); image_transport::Subscriber sub = it.subscribe("/camera/rgb/image_raw", 1, imageCallback); ros::spin(); cv::destroyWindow("view"); } Here is my package.xml detect_green_object0.0.0The detect_green_object packageturtlebotTODOcatkincv_bridgeroscpprospysensor_msgsstd_msgsmessage_filterspluginlibrosconsoleroslibimage_transporttfcv_bridgeroscpprospysensor_msgsstd_msgsmessage_filterspluginlibrosconsoleroslibimage_transporttf Here is my CMakeLists.txt cmake_minimum_required(VERSION 2.8) project( detect_green_object ) find_package(catkin REQUIRED COMPONENTS roscpp cv_bridge rospy std_msgs message_filters pluginlib rosconsole roslib sensor_msgs image_transport tf OpenCV ) find_package( Boost REQUIRED ) catkin_package( LIBRARIES ${PROJECT_NAME} DEPENDS roscpp rospy std_msgs cv_bridge message_filters pluginlib rosconsole roslib sensor_msgs image_transport tf ) include_directories( ${catkin_INCLUDE_DIRS} ) add_executable( detect_green_object detect_green_object.cpp ) target_link_libraries( detect_green_object ${OpenCV_LIBS} ${catkin_LIBRARIES} )

rosbag Image Decompression With API

$
0
0
Folks, My rosbags all have compressed image topics ONLY. I want to grab the images from my rosbag and decompressed them through the rosbag API (or through code, in general). I believe that should be a fast method compered to playing the rosbag and subscribing to the image topics??? If I am not correct about this, then tell me, and I'll just play each rosbag, and decompress images the old ROS fashion way (I have 1600 rosbags, 8 seconds long each)

image_transport republish One Time Use

$
0
0
Folks, I have several rosbags, 8 seconds long each, which only contain compressed depth images. Since rospy does not support compressedDepth (as far as I know) I am using rosrun image_transport republish to go from compressedDepth to raw. But I noticed that only the first rosbag's image gets republished, but not any rosbag after that, unless I re-run the image transport code above after each rosbag finishes playing...**kind of a lame behavior in my opinion**. Is there an option to tell **republish** to continue republishing?

image_transport rosbag issue

$
0
0
Has anyone else seen problems recording rosbags for all topics of a node using image_transport? > ERROR > [/tmp/buildd/ros-indigo-compressed-depth-image-transport-1.9.2-0trusty-20150729-0539/src/compressed_depth_publisher.cpp:223(CompressedDepthPublisher::publish) >> ... >> Compressed Depth Image Transport -Compression requires single-channel 32bit-floating point or 16bit raw depth images (input format is: bgr8). I see this with [pointgrey_camera_driver (tag 0.12.1)](https://github.com/ros-drivers/pointgrey_camera_driver.git) when doing a `rosbag record -a`. I've noticed some [issues](https://github.com/ros-drivers/axis_camera/issues/32) posted for other packages using image_transport so I thought I'd post a general question in the event there is some broader issue. UPDATE: Running `rosbag record -a -x "(.*)/compressed(.*)"` solves the issue of the errors by not recording the "compressed" topics but doesn't explain why they occur in the first place.

Two Topics with Same Callback

$
0
0
Hi everyone, I am subscribing to two different topics (each with different md5sums) using a single callback. I am using the `message_filters` class to achieve this. In my broadcaster, I am publishing a `point cloud` and an opencv `image`. I want to subscribe in a separate code. My callback signature looks like so: void callback(const sensor_msgs::ImageConstPtr& ensensoImage, const sensor_msgs::PointCloud2ConstPtr& ensensoCloud) { cv::Mat ir; PointCloudT cloud; getImage(ensensoImage, ir); getCloud(ensensoCloud, cloud); ROS_INFO_STREAM("cloud: " << cloud); std::lock_guard lock(mutex); this->ir = ir; this->cloud = cloud; updateImage = true; updateCloud = true; } When I run my code, however, I get an `std::terminate` as follows: ``` user@user:~/catkin_ws$ rosrun ensenso ensenso_viewer terminate called after throwing an instance of 'ros::ConflictingSubscriptionException' what(): Tried to subscribe to a topic with the same name but different md5sum as a topic that was already subscribed [sensor_msgs/PointCloud2/1158d486dd51d683ce2f1be655c3c181 vs. sensor_msgs/Image/060021388200f6f0f447d0fcd9c64743] Aborted (core dumped) ``` Is it not possible to have a callback with different classes of a namespace or am I missing something? For reference, the whole code is [here](https://github.com/lakehanne/ensenso/blob/devel/src/ensenso_viewer.cxx). I would appreciate any help. Thanks!

Problem with image_transport callback

$
0
0
I have the next scenario, class controller : { public: controller(ros::NodeHandle node); ~controller(void); // The callbacks are implemented correctly void imageCallback(const sensor_msgs::ImageConstPtr& msg); void navdataCallback(const ardrone_autonomy::Navdata& data); void foo(){ // Do Something std::thread foo_thread(&controller::foo2, this); foo_thread.join(); } void foo2(){ // Do Something while (something){ // Do Something std::this_thread::sleep_for(std::chrono::milliseconds(20)); ros::spinOnce(); } } private: //Other Stuff } and the main program is int main(int argc, char **argv) { ros::init(argc,argv, "main"); ros::NodeHandle n; controller control(n); image_transport::ImageTransport it(n); image_transport::Subscriber sub = it.subscribe("ardrone/image_raw", 1, &controller::imageCallback, &control); ros::Subscriber navdata = n.subscribe("ardrone/navdata", 1000, &controller::navdataCallback, &control); while(ros::ok()){ ros::spin(); } return 0; } the problem is when I process data in foo2() the navdata messages arrives fine, but stop reciving image data until the end of the thread. How can I resolve this? Is my approach correct? May be the ros::spinOnce is not placed correctly?

Republish to the topic

$
0
0
Hello, I am trying to run the face_recognition package, as I follow the tutorial they ask me to publish video stream to topic /camera/image_raw. I am trying to do it with the image_transport package using command "republish" but when I run it in the command window it says republish: "command not found". Anyone familiar with this situation ?

Compress images into custom message

$
0
0
I want to build a frame filter to synchronize the image streams from an RGBD camera into one message. I am using a `ApproximateTime Synchronizer` to listen to the `sensor_msgs/Image` and `sensor_msgs/CameraInfo` streams and want to publish them in a single message (see blow). How do I compress/decompress the images to put them into the message? Is it possible to build the messages manually by compressing/decompressing the images with OpenCV? Can I utilize image_transport for that to avoid high memory consumption across several nodes? ---------- **Frame.msg** Header header sensor_msgs/CompressedImage rgb_image sensor_msgs/CompressedImage depth_image sensor_msgs/CameraInfo rgb_cam sensor_msgs/CameraInfo depth_cam

How to convert CompressedImage to Image?

$
0
0
I would like to convert CompressedImage to Image. rosrun image_transport republish raw in:=/image_raw compressed out:=/image_raw_converted Then, I could got image_raw_converted which is CompressedImage and 1/10 data size. I would like to use image_raw_converted as Image. So, rosrun image_transport republish compressed in:=/image_raw_converted raw out:=/image_raw_converted2 However, the data size increases by 10 times. Is there any way to convert CompressedImage to Image and also decrease the data size?

Runtime Error with Image Transport in Eclipse IDE

$
0
0
Hi guys, I have configured the Eclipse as my IDE and I am having no problems during compile time for my ROS packages. Once I run or enter the Debug mode, if there is an image_transport object use, it will immediately cause runtime error showing this error message: > [rospack] Error: package 'image_transport' not found [librospack]: error while executing command terminate called after throwing an instance of 'pluginlib::ClassLoaderException' what(): Unable to find package: image_transport When I try to run the same node outside the Eclipse environment I have no such problems. Do you have any idea what might be causing this? Thank you!

Publishing compressed images

$
0
0
Hi all, I have a camera that is giving me JPEG images. The compressed_image_transport overview says: "When writing a driver for such a camera, a quick and dirty approach is to simply copy the JPEG data into a sensor_msgs/CompressedImage message and publish it on a topic of the form image_raw/compressed." So: 1- I guess there isn't any way to use image transport and saying the data we are publishing is compressed. Right? 2- If the alternative way is "quick and dirty" what would be the proper way to do this? Thanks in advance,

How to deactivate image_transport plugins?

$
0
0
Hi I would like to deactivate image_transport plugins from a launch file. My robot has many cameras and I am not using the compressed images. It would save CPU time if I can do that. I would prefer a solution involving a launch file since other members of my team may use those compressed images. If you have no solution with a launch file, I am open to any suggestion. Thanks in advance Stanley

get std_msgs::Header associated with a frame from image_transport?

$
0
0
Is there a way to get the std::msgs::Header associated with an image sent over image_transport? I need some unique key from my images to stick in the header of mesages derived from them to maintain the association.

Image_transport tutorials - Crashes upon publishing an image to the topic

$
0
0
Hello! I've followed the tutorials to get started with image_transport. However, when i start the subscriber, the window created by the subscriber callback (the one titled "view") crashes when i publish an image (by running the subscriber). Also, it doesn't actually show the image from the parameter, but a small part of the desktop instead. Running on kinetic, ubuntu 16.04 Any help would be greatly appreciated!
Viewing all 131 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>