Change
ros::init(argc, argv,"talker");to
ros::init(argc, argv,"publisher");Change
ros::init(argc, argv,"listener");to
ros::init(argc, argv,"subscriber");Open session2_pubsub/CMakeLists.txt and add following lines to the bottom of the file.
add_executable(publisher src/publisher.cpp)
target_link_libraries(publisher ${catkin_LIBRARIES})
add_executable(subscriber src/subscriber.cpp)
target_link_libraries(subscriber ${catkin_LIBRARIES})Go to root of the workspace
cd ~/ros_workshop/catkin buildor
catkin_makeOpen a terminal and run,
roscoreOpen a 2nd terminal in the workspace root and run,
source devel/setup.bashrosrun session2_pubsub publisherOpen a 3rd terminal in the workspace root and run,
source devel/setup.bashrosrun session2_pubsub subscriber