karma
All Modules
module.h
1 /*
2  * Copyright (C) 2011 Department of Robotics Brain and Cognitive Sciences - Istituto Italiano di Tecnologia
3  * Author: Vadim Tikhanoff Ugo Pattacini
4  * email: vadim.tikhanoff@iit.it
5  * Permission is granted to copy, distribute, and/or modify this program
6  * under the terms of the GNU General Public License, version 2 or any
7  * later version published by the Free Software Foundation.
8  *
9  * A copy of the license can be found at
10  * http://www.robotcub.org/icub/license/gpl.txt
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15  * Public License for more details
16 */
17 
18 #ifndef __MODULE_H__
19 #define __MODULE_H__
20 
21 #include <string>
22 
23 #include "opencv2/opencv.hpp"
24 
25 #include <yarp/os/Time.h>
26 #include <yarp/os/RFModule.h>
27 #include <yarp/os/RpcServer.h>
28 #include <yarp/os/RpcClient.h>
29 #include <yarp/os/BufferedPort.h>
30 #include <yarp/os/Port.h>
31 #include <yarp/sig/Image.h>
32 #include <yarp/sig/Vector.h>
33 
34 #include "iCub/utils.h"
35 
36 /**********************************************************/
37 struct lineData
38 {
39  double gradient;
40  double intercept;
41 };
42 
43 /**********************************************************/
44 class Manager : public yarp::os::RFModule
45 {
46 protected:
47  std::string name; //name of the module
48  yarp::os::Port rpcHuman; //human rpc port (receive commands via rpc)
49 
50  yarp::os::Port motionFilter; //port that receives an image containing blobs from motion
51  yarp::os::Port toolPoint; //port that receives an image containing blobs from motion
52  yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb> > imgOutPort; //port that sends out img
53 
54  MotionFeatures motionFeatures; //class to receive points from motionFilter
55 
56  lineData *lineDetails;
57 
58  int processHumanCmd(const yarp::os::Bottle &cmd, yarp::os::Bottle &b);
59  void processBlobs(yarp::os::Bottle &b, cv::Mat &dest, lineData *lineDetails);
60  void processMotionPoints(yarp::os::Bottle &b);
61  yarp::os::Bottle processImage(yarp::os::Bottle &b, cv::Mat &dest, cv::Mat &clean, lineData *lineDetails);
62  void getIntersection(cv::Mat &dest, lineData *lineDetails );
63 
64  friend class MotionFeatures;
65 
66 public:
67  bool configure(yarp::os::ResourceFinder &rf);
68  bool interruptModule();
69  bool close();
70  bool updateModule();
71  double getPeriod();
72 };
73 
74 #endif