Skip to content

Commit 3147d4a

Browse files
committed
Finished node, started launch
1 parent e0d2fb4 commit 3147d4a

File tree

2 files changed

+10
-43
lines changed

2 files changed

+10
-43
lines changed

launch/doubleTimer.launch

Whitespace-only changes.

src/image_timer.cpp

+10-43
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,24 @@
11
#include "ros/ros.h"
2-
#include "std_msgs/String.h"
2+
#include "sensor_msgs/Image.h"
33

4-
/**
5-
* This tutorial demonstrates simple receipt of messages over the ROS system.
6-
*/
7-
void chatterCallback(const std_msgs::String::ConstPtr& msg)
4+
std::string topic_;
5+
void imgCallback(const sensor_msgs::Image::ConstPtr& msg)
86
{
9-
ROS_INFO("I heard: [%s]", msg->data.c_str());
7+
ROS_INFO("I heard image on %s",topic_.c_str());
108
}
119

1210
int main(int argc, char **argv)
1311
{
14-
/**
15-
* The ros::init() function needs to see argc and argv so that it can perform
16-
* any ROS arguments and name remapping that were provided at the command line.
17-
* For programmatic remappings you can use a different version of init() which takes
18-
* remappings directly, but for most command-line programs, passing argc and argv is
19-
* the easiest way to do it. The third argument to init() is the name of the node.
20-
*
21-
* You must call one of the versions of ros::init() before using any other
22-
* part of the ROS system.
23-
*/
12+
2413
ros::init(argc, argv, "listener");
2514

26-
/**
27-
* NodeHandle is the main access point to communications with the ROS system.
28-
* The first NodeHandle constructed will fully initialize this node, and the last
29-
* NodeHandle destructed will close down the node.
30-
*/
3115
ros::NodeHandle n;
3216

33-
/**
34-
* The subscribe() call is how you tell ROS that you want to receive messages
35-
* on a given topic. This invokes a call to the ROS
36-
* master node, which keeps a registry of who is publishing and who
37-
* is subscribing. Messages are passed to a callback function, here
38-
* called chatterCallback. subscribe() returns a Subscriber object that you
39-
* must hold on to until you want to unsubscribe. When all copies of the Subscriber
40-
* object go out of scope, this callback will automatically be unsubscribed from
41-
* this topic.
42-
*
43-
* The second parameter to the subscribe() function is the size of the message
44-
* queue. If messages are arriving faster than they are being processed, this
45-
* is the number of messages that will be buffered up before beginning to throw
46-
* away the oldest ones.
47-
*/
48-
ros::Subscriber sub = n.subscribe("chatter", 1000, chatterCallback);
49-
50-
/**
51-
* ros::spin() will enter a loop, pumping callbacks. With this version, all
52-
* callbacks will be called from within this thread (the main one). ros::spin()
53-
* will exit when Ctrl-C is pressed, or the node is shutdown by the master.
54-
*/
17+
18+
n.param<std::string>("topic", topic_, "/cam0/image_raw");
19+
20+
ros::Subscriber sub = n.subscribe(topic_, 1000, imgCallback);
21+
5522
ros::spin();
5623

5724
return 0;

0 commit comments

Comments
 (0)