speech
All Data Structures Functions Modules Pages
start-inspect.h
1 /*
2  * Copyright (C) 2017 Department of Robotics Brain and Cognitive Sciences - Istituto Italiano di Tecnologia
3  * Author: Vadim Tikhanoff
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 __ICUB_STARTINSPECT_MOD_H__
19 #define __ICUB_STARTINSPECT_MOD_H__
20 
21 #include <yarp/os/BufferedPort.h>
22 #include <yarp/os/RFModule.h>
23 #include <yarp/os/Network.h>
24 #include <yarp/os/Thread.h>
25 #include <yarp/os/PeriodicThread.h>
26 #include <yarp/os/Time.h>
27 #include <yarp/os/Stamp.h>
28 #include <yarp/sig/Vector.h>
29 #include <yarp/sig/Image.h>
30 
31 #include <yarp/os/RpcClient.h>
32 
33 #include <vector>
34 #include <string>
35 #include <cstring>
36 #include <algorithm>
37 
38 struct Object{
39 
40  std::string name;
41  std::vector<std::string> property;
42 };
43 
44 class STARTManager : public yarp::os::BufferedPort<yarp::os::Bottle>
45 {
46 private:
47 
48  std::string moduleName; //string containing module name
49  std::string inSpeechPortName; //string containing speech input port name
50  std::string outSTARTPortName; //string containing start output port name
51 
52  yarp::os::BufferedPort<yarp::os::Bottle> speechInPort; //input port containing speech
53  yarp::os::BufferedPort<yarp::os::Bottle> startOutPort; //output port containing start
54 
55  Object *objectDetails;
56 
57 public:
63  STARTManager( const std::string &moduleName );
64  ~STARTManager();
65 
66  bool open();
67  void close();
68  void onRead( yarp::os::Bottle &bot );
69  void interrupt();
70 
71  static bool aZCheck(char c)
72  {
73  return !isalpha(c);
74  }
75 
76 };
77 
78 class STARTModule:public yarp::os::RFModule
79 {
80  /* module parameters */
81  std::string moduleName;
82  std::string handlerPortName;
83  yarp::os::RpcServer rpcPort;
84 
85  /* pointer to a new thread */
86  STARTManager *startManager;
87  bool closing;
88 
89 public:
90 
91 
92  bool configure(yarp::os::ResourceFinder &rf); // configure all the module parameters and return true if successful
93  bool interruptModule(); // interrupt, e.g., the ports
94  bool close(); // close and shut down the module
95 
96  double getPeriod();
97  bool updateModule();
98 };
99 
100 
101 #endif
102 //empty line to make gcc happy