Fawkes API  Fawkes Development Version
gazsim_webcam.h
1 /***************************************************************************
2  * gazsim_webcam.h - Class to simulate a single webcam from gazebo
3  *
4  * Created: Mon Mar 16 19:38:43 2015
5  * Copyright 2015 Frederik Zwilling
6  ****************************************************************************/
7 
8 /* This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Library General Public License for more details.
17  *
18  * Read the full text in the LICENSE.GPL file in the doc directory.
19  */
20 
21 #ifndef _PLUGINS_GAZSIM_WEBCAM_H_
22 #define _PLUGINS_GAZSIM_WEBCAM_H_
23 
24 #include <aspect/blackboard.h>
25 #include <aspect/blocked_timing.h>
26 #include <aspect/clock.h>
27 #include <aspect/configurable.h>
28 #include <aspect/logging.h>
29 #include <config/config.h>
30 #include <core/threading/thread.h>
31 #include <fvutils/ipc/shm_image.h>
32 #include <plugins/gazebo/aspect/gazebo.h>
33 
34 #include <boost/circular_buffer.hpp>
35 #include <string.h>
36 
37 //from Gazebo
38 #include <gazebo/msgs/MessageTypes.hh>
39 #include <gazebo/transport/TransportTypes.hh>
40 #include <gazebo/transport/transport.hh>
41 
43 {
44 public:
45  GazsimWebcam(std::string shm_id,
46  gazebo::transport::NodePtr gazebo_world_node,
47  fawkes::Configuration * config);
48  ~GazsimWebcam();
49 
50 private:
51  //Subscriber to receive webcam data from gazebo
52  gazebo::transport::SubscriberPtr webcam_sub_;
53 
54  //handler function for incoming webcam data messages
55  void on_webcam_data_msg(ConstImageStampedPtr &msg);
56 
57  //shared memory buffer
59  //reference to the buffer of shm_buffer_
60  unsigned char *buffer_;
61 
62  //config values
63  //topic name of the gazebo message publisher
64  std::string topic_name_;
65  double width_, height_;
66  //id of the shared memory object
67  std::string shm_id_;
68  std::string frame_;
69  firevision::colorspace_t format_from_;
70  firevision::colorspace_t format_to_;
71 };
72 
73 #endif
Simulates a single webcam in Gazebo.
Definition: gazsim_webcam.h:43
GazsimWebcam(std::string shm_id, gazebo::transport::NodePtr gazebo_world_node, fawkes::Configuration *config)
Constructor.
Interface for configuration handling.
Definition: config.h:65
Shared memory image buffer.
Definition: shm_image.h:184