Fawkes API Fawkes Development Version
gazsim_webcam_thread.cpp
1/***************************************************************************
2 * gazsim_webcam_plugin.cpp - Plugin simulates Webcams in Gazebo and
3 * provides a shared memory buffer
4 *
5 * Created: Sat Sep 21 17:37:42 2013
6 * Copyright 2013 Frederik Zwilling
7 ****************************************************************************/
8
9/* This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Library General Public License for more details.
18 *
19 * Read the full text in the LICENSE.GPL file in the doc directory.
20 */
21
22#include "gazsim_webcam_thread.h"
23
24#include <aspect/logging.h>
25#include <fvutils/color/conversions.h>
26#include <tf/types.h>
27#include <utils/math/angle.h>
28
29#include <gazebo/msgs/msgs.hh>
30#include <gazebo/transport/Node.hh>
31#include <gazebo/transport/transport.hh>
32#include <math.h>
33#include <stdio.h>
34
35using namespace fawkes;
36using namespace gazebo;
37
38/** @class WebcamSimThread "gazsim_webcam_thread.h"
39 * Thread simulates a number of webcams in Gazebo
40 * @author Frederik Zwilling
41 */
42
43/** Constructor. */
45: Thread("WebcamSimThread", Thread::OPMODE_WAITFORWAKEUP),
46 BlockedTimingAspect(BlockedTimingAspect::WAKEUP_HOOK_SENSOR_PROCESS)
47{
48}
49
50void
52{
53 logger->log_debug(name(), "Initializing Simulation of the Webcams");
54 shm_ids_ = config->get_strings("/gazsim/webcam/shm-image-ids");
55
56 for (std::vector<std::string>::iterator it = shm_ids_.begin(); it != shm_ids_.end(); ++it) {
57 webcams_.push_back(new GazsimWebcam(*it, gazebo_world_node, config));
58 }
59}
60
61void
63{
64 for (std::vector<GazsimWebcam *>::iterator it = webcams_.begin(); it != webcams_.end(); ++it) {
65 delete *it;
66 }
67}
68
69void
71{
72 //The interesting stuff happens in the callback of the webcams
73}
Simulates a single webcam in Gazebo.
Definition: gazsim_webcam.h:43
virtual void finalize()
Finalize the thread.
virtual void loop()
Code to execute in the thread.
virtual void init()
Initialize the thread.
WebcamSimThread()
Constructor.
Thread aspect to use blocked timing.
Configuration * config
This is the Configuration member used to access the configuration.
Definition: configurable.h:41
virtual std::vector< std::string > get_strings(const char *path)=0
Get list of values from configuration which is of type string.
gazebo::transport::NodePtr gazebo_world_node
Gazebo Node for communication with the world (e.g.
Definition: gazebo.h:51
virtual void log_debug(const char *component, const char *format,...)=0
Log debug message.
Logger * logger
This is the Logger member used to access the logger.
Definition: logging.h:41
Thread class encapsulation of pthreads.
Definition: thread.h:46
const char * name() const
Get name of thread.
Definition: thread.h:100
Fawkes library namespace.