Subscribing to depth information from zed camera
I am trying to write a subscriber to obtain the depth information from a zed camera. I have written the following .cpp code:
//#include <iostream>
#include "ros/ros.h"
//#include "std_msgs/String.h"
#include "sensor_msgs/Image.h"
//using namespace std;
void depthCallback(const sensor_msgs::Image& msg)
{
ROS_INFO("Depth Info: [%d]", msg->data )
}
int main(int argc, char **argv)
{
//cout << "Hello world!" << endl;
ros::init(argc, argv, "zed_depth_subscriber")
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("/camera/depth/image_rect_color",1000, depthCallback);
ros::spin ();
return 0;
}
I realize that the line: ROS_INFO("Depth Info: [%d]", msg->data )
may throw an error (I am expecting a matrix, but not really sure how I can handle it in a ROS subscriber). But my current problem is related to CMakeLists.txt and package.xml files.
This subscriber is supposed to obtain depth information from the topic /camera/depth/image_rect_color from the zed wrapper. I am planning to add this .cpp file to
~/catkin_ws/src/zed-ros-wrapper/src/
and edit the CMakeLists.txt in the location:
~/catkin_ws/src/zed-ros-wrapper/
I am looking at the example given in ROS Tutorials which gave me the following:
add_executable(listener src/listener.cpp)
target_link_libraries(listener ${catkin_LIBRARIES})
add_dependencies(listener beginner_tutorials_generate_messages_cpp)
I know that 'listener' should be replaced with 'zed_depth_subscriber'. But how do I identify the dependencies? How will the line add_dependencies(....
change?
Also do I need to edit package.xml residing in the same folder as that of CMakeLists.txt?