-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImageSubscribe.cc
40 lines (34 loc) · 1.23 KB
/
ImageSubscribe.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <gazebo/transport/transport.hh>
#include <gazebo/msgs/msgs.hh>
#include <gazebo/gazebo_client.hh>
#include <iostream>
//typedef const boost::shared_ptr<const gazebo::msgs::Pose> PosePtr;
void cb(ConstImagesStampedPtr &imagesStamped)
{
//std::cout << imagesStamped->DebugString();
::google::protobuf::int32 sec = imagesStamped->time().sec();
::google::protobuf::int32 nsec = imagesStamped->time().nsec();
std::cout << "Read time: sec: " << sec << " nsec: " << nsec << std::endl;
for (int i =0; i < imagesStamped->image_size(); ++i)
{
const ::gazebo::msgs::Image &image = imagesStamped->image(i);
::google::protobuf::uint32 width = image.width();
std::cout<<"image width: "<<width<<std::endl;
}
}
/////////////////////////////////////////////////
int main(int _argc, char **_argv)
{
gazebo::client::setup(_argc, _argv);
gazebo::transport::NodePtr node;
node = gazebo::transport::NodePtr(new gazebo::transport::Node());
node->Init();
gazebo::transport::SubscriberPtr sub = node->Subscribe("~/camera/link/camera/image", cb);
std::cout<<"subscribe success"<<std::endl;
while (true)
{
//std::cout<<"loop entered"<<std::endl;
gazebo::common::Time::MSleep(10);
}
gazebo::client::shutdown();
}