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 <core/threading/thread.h>
25 #include <aspect/clock.h>
26 #include <aspect/configurable.h>
27 #include <aspect/logging.h>
28 #include <aspect/blackboard.h>
29 #include <aspect/blocked_timing.h>
30 #include <plugins/gazebo/aspect/gazebo.h>
31 #include <string.h>
32 #include <config/config.h>
33 
34 #include <fvutils/ipc/shm_image.h>
35 #include <boost/circular_buffer.hpp>
36 
37 //from Gazebo
38 #include <gazebo/transport/TransportTypes.hh>
39 #include <gazebo/msgs/MessageTypes.hh>
40 #include <gazebo/transport/transport.hh>
41 
42 
44 {
45  public:
46  GazsimWebcam(std::string shm_id,
47  gazebo::transport::NodePtr gazebo_world_node,
48  fawkes::Configuration* config);
49  ~GazsimWebcam();
50 
51  private:
52  //Subscriber to receive webcam data from gazebo
53  gazebo::transport::SubscriberPtr webcam_sub_;
54 
55  //handler function for incoming webcam data messages
56  void on_webcam_data_msg(ConstImageStampedPtr &msg);
57 
58  //shared memory buffer
60  //reference to the buffer of shm_buffer_
61  unsigned char *buffer_;
62 
63  //config values
64  //topic name of the gazebo message publisher
65  std::string topic_name_;
66  double width_, height_;
67  //id of the shared memory object
68  std::string shm_id_;
69  std::string frame_;
70  firevision::colorspace_t format_from_;
71  firevision::colorspace_t format_to_;
72 };
73 
74 #endif
Shared memory image buffer.
Definition: shm_image.h:181
GazsimWebcam(std::string shm_id, gazebo::transport::NodePtr gazebo_world_node, fawkes::Configuration *config)
Constructor.
Interface for configuration handling.
Definition: config.h:67
Simulates a single webcam in Gazebo.
Definition: gazsim_webcam.h:43