How to use sensor_msgs/Image message?
Hi
- I'm a beginner on ROS.
- I want to use a topic "/usb_cam/image_raw". (this topic is usb_cam package)
- So I made a package, and a Subscriber.
- However, there is still error in the catkin_make process.
- How can I write CMakeList ?
main source
#include "ros/ros.h"
#include "sensor_msgs/Image.h"
void msgCallback(const sensor_msgs::Image::ConstPtr& msg)
{
ROS_INFO("height = %d, width = %d",msg->height, msg->width);
}
int main(int argc, char** argv)
{
ros::init(argc,argv,"cam_data");
ros::NodeHandle nh;
ros::Subscriber cam_sub = nh.subscribe("/usb_cam/image_raw",100,msgCallback);
ros::spin();
return 0;
}
CMakeList
cmake_minimum_required(VERSION 2.8.3)
project(test_cam)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
roscpp
sensor_msgs
)
generate_messages(
DEPENDENCIES
sensor_msgs
)
catkin_package(
# INCLUDE_DIRS include
LIBRARIES test_cam
CATKIN_DEPENDS roscpp sensor_msgs
DEPENDS system_lib
)
include_directories(
${catkin_INCLUDE_DIRS}
)
add_executable(receive_cam src/receive_cam.cpp)
#target_link_libraries(test_cam ${catkin_LIBRARIES})
#add_dependencies(receive_cam test_cam_cpp)