Several Images in one msg, How can I do it?
The code I have is the following:
int main(int argc, char **argv) { ros::init(argc, argv, "image_listener"); ros::NodeHandle nh; ros::Rate loop_rate(100); // Rate class instance. ImageManagmentStruct LeftCameraImageStructForGrid, RightCameraImageStructForGrid, KinectImageStructForGrid, KinectDepthImageStructForGrid; ImageManagmentStruct LeftCameraImageStructOneImage, RightCameraImageStructOneImage, KinectImageStructOneImage, KinectDepthImageStructOneImage; // Initializing the image/camera data structures. dataStructuresInitialization ( &LeftCameraImageStructForGrid, &RightCameraImageStructForGrid, &KinectImageStructForGrid, &KinectDepthImageStructForGrid, &LeftCameraImageStructOneImage, &RightCameraImageStructOneImage, &KinectImageStructOneImage, &KinectDepthImageStructOneImage ); // GTK library initialization gtk_init ( &argc, &argv ); // Creating a top level window and connecting it to a sygnal. createMainInterfaceWindow (); // Creating a fixed container, which will hold all the widgets of the GUI. createFixedContainer (); // Creating a GtkGrid widget, which will contain all the images. createGtkTable (); // Attaching the created table to the Container. gtk_fixed_put (GTK_FIXED (pGlobalFixedContainer), pGlobalGtkTable, IMAGES_HORIZONTAL_PLACEMENT, IMAGES_VERTIACL_PLACEMENT); // Subscribing in order to receive images. //ros::Subscriber subLeft = nh.subscribe<sensor_msgs::image> ("/republished/bb2/triclops/left/image_raw", 2, boost::bind(imageCallbackWrapper, _1, globalArrayOfImagesForGrid[0], globalArrayForSingleImages[0])); // ros::Subscriber subRight = nh.subscribe<sensor_msgs::image> ("/republished/bb2/triclops/right/image_raw", 2, boost::bind(imageCallbackWrapper, _1, globalArrayOfImagesForGrid[1], globalArrayForSingleImages[1])); // ros::Subscriber subKinect = nh.subscribe<sensor_msgs::image> ("/republished/usb_cam/image_raw", 2, boost::bind(imageCallbackWrapper, _1, globalArrayOfImagesForGrid[2], globalArrayForSingleImages[2])); // ros::Subscriber subKinectDepth = nh.subscribe<sensor_msgs::image> ("/republished/usb_cam/image_raw", 2, boost::bind(imageCallbackWrapper, _1, globalArrayOfImagesForGrid[3], globalArrayForSingleImages[3])); //New Code, replacing the ros::Subscriber image_transport::ImageTransport it(nh); image_transport::Subscriber subLeft = it.subscribe("/republished/bb2/triclops/left/image_raw", 2, boost::bind(imageCallbackWrapper, _1, globalArrayOfImagesForGrid[0], globalArrayForSingleImages[0])); image_transport::Subscriber subRight = it.subscribe("/republished/bb2/triclops/right/image_raw", 2, boost::bind(imageCallbackWrapper, _1, globalArrayOfImagesForGrid[1], globalArrayForSingleImages[1])); image_transport::Subscriber subKinect = it.subscribe("/republished/usb_cam/image_raw/", 2, boost::bind(imageCallbackWrapper, _1, globalArrayOfImagesForGrid[2], globalArrayForSingleImages[2])); image_transport::Subscriber subKinectDepth = it.subscribe("/republished/usb_cam/image_raw//republished/bb2/triclops/left/image_raw", 2, boost::bind(imageCallbackWrapper, _1, globalArrayOfImagesForGrid[3], globalArrayForSingleImages[3])); g_timeout_add(1000 / 100, do_ros, NULL); gtk_main(); if ( MY_FUNCTIONS_ENTRANCE_CONTROL ) { printf ("\033[01;33mExited from the main function normally.\033[01;37m\n" ); } return 0; }
I try to get the images, but I got none. A simple receiver code, works fine with the Rosbag and one image, this code thosen't make the connections, can any one help me with this problem. pls.
Rodrigo
Sorry my mistake, I forgot to show do_ros function.
gboolean do_ros ( gpointer data ) {
can you put some
std::cout
just beforeros::spinOnce()
to confirm that it gets called?I also find the names of the topics you subscribe to rather strange. run
rostopic list
and check whether it outputs those same topic name exactly (slashes matter).Also check whether there is some data on those topics.
rostopic echo --noarr /republished/usb_cam/image_raw//republished/bb2/triclops/left/image_raw