iCub-main
Loading...
Searching...
No Matches
TransformModule.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2007-2010 RobotCub Consortium, European Commission FP6 Project IST-004370
3 * author: Arjan Gijsberts
4 * email: arjan.gijsberts@iit.it
5 * website: www.robotcub.org
6 * Permission is granted to copy, distribute, and/or modify this program
7 * under the terms of the GNU General Public License, version 2 or any
8 * later version published by the Free Software Foundation.
9 *
10 * A copy of the license can be found at
11 * http://www.robotcub.org/icub/license/gpl.txt
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16 * Public License for more details
17 */
18
19#ifndef LM_TRANSFORMMODULE__
20#define LM_TRANSFORMMODULE__
21
25
26
27namespace iCub {
28namespace learningmachine {
29
40protected:
45
46public:
53
60 return this->transformerPortable;
61 }
62
69 return this->getTransformerPortable().getWrapped();
70 }
71};
72
85class TransformPredictProcessor : public ITransformProcessor, public yarp::os::PortReader {
86protected:
90 yarp::os::Port& predictRelay_inout;
91
92public:
100
101 /*
102 * Inherited from PortReader.
103 */
104 virtual bool read(yarp::os::ConnectionReader& connection);
105
111 virtual yarp::os::Port& getOutputPort() {
112 return this->predictRelay_inout;
113 }
114
115};
116
117
128 : public ITransformProcessor, public yarp::os::TypedReaderCallback<VectorPair> {
129private:
133 yarp::os::BufferedPort<VectorPair>& train_out;
134
135public:
142 yarp::os::BufferedPort<VectorPair>& p)
143 : ITransformProcessor(tp), train_out(p) { }
144
145 /*
146 * Inherited from TypedReaderCallback.
147 */
148 virtual void onRead(VectorPair& input);
149
155 virtual yarp::os::BufferedPort<VectorPair>& getOutputPort() {
156 return this->train_out;
157 }
158
159};
160
161
162
163
174
175class TransformModule : public IMachineLearnerModule {
176private:
180 TransformerPortable transformerPortable;
181
185 yarp::os::BufferedPort<VectorPair> train_in;
186
190 yarp::os::BufferedPort<VectorPair> train_out;
191
195 yarp::os::BufferedPort<yarp::sig::Vector> predict_inout;
196
200 yarp::os::Port predictRelay_inout;
201
205 TransformTrainProcessor trainProcessor;
206
210 TransformPredictProcessor predictProcessor;
211
215 TransformModule(const TransformModule& other);
216
220 TransformModule& operator=(const TransformModule& other);
221
222 /*
223 * Inherited from IMachineLearnerModule.
224 */
225 void registerAllPorts();
226
227 /*
228 * Inherited from IMachineLearnerModule.
229 */
230 void unregisterAllPorts();
231
232 /*
233 * Inherited from IMachineLearnerModule.
234 */
235 void printOptions(std::string error = "");
236
240 void printTransformerList();
241
242public:
248 TransformModule(std::string pp = "/lm/transform")
249 : IMachineLearnerModule(pp), transformerPortable((ITransformer*) 0),
250 trainProcessor(transformerPortable, train_out),
251 predictProcessor(transformerPortable, predictRelay_inout) {
252 }
253
257 virtual ~TransformModule() { }
258
259 /*
260 * Inherited from IMachineLearnerModule.
261 */
262 virtual bool configure(yarp::os::ResourceFinder& opt);
263
264 /*
265 * Inherited from IMachineLearnerModule.
266 */
267 virtual bool interruptModule();
268
269 /*
270 * Inherited from IMachineLearnerModule.
271 */
272 virtual bool respond(const yarp::os::Bottle& cmd, yarp::os::Bottle& reply);
273
280 return this->getTransformerPortable().getWrapped();
281 }
282
289 return this->transformerPortable;
290 }
291
292};
293
294} // learningmachine
295} // iCub
296
297#endif
virtual void registerAllPorts()=0
Registers all ports used by this module.
virtual void unregisterAllPorts()=0
Unregisters all ports used by this module.
IMachineLearnerModule(const IMachineLearnerModule &other)
Copy Constructor (private and unimplemented on purpose).
ITransformProcessor(TransformerPortable &tp)
Constructor.
TransformerPortable & transformerPortable
A reference to a portable transformer.
virtual TransformerPortable & getTransformerPortable()
Retrieve the transformer portable wrapper.
virtual ITransformer & getTransformer()
Retrieve the wrapped transformer.
A class that provides a preprocessing interface, which can be used to preprocess the data samples tha...
T & getWrapped() const
The accessor for the wrapped object.
Definition PortableT.h:215
virtual bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &reply)
TransformModule(std::string pp="/lm/transform")
Constructor.
virtual ~TransformModule()
Destructor (empty).
virtual bool configure(yarp::os::ResourceFinder &opt)
virtual ITransformer & getTransformer()
Retrieve the transformer that is used in this TransformModule.
virtual TransformerPortable & getTransformerPortable()
Retrieve the transformer portable.
Reply processor helper class for predictions.
virtual bool read(yarp::os::ConnectionReader &connection)
TransformPredictProcessor(TransformerPortable &tp, yarp::os::Port &p)
Constructor.
yarp::os::Port & predictRelay_inout
The relay port.
virtual yarp::os::Port & getOutputPort()
Accessor for the prediction output port.
Port processor helper class for incoming training samples.
TransformTrainProcessor(TransformerPortable &tp, yarp::os::BufferedPort< VectorPair > &p)
Constructor.
virtual yarp::os::BufferedPort< VectorPair > & getOutputPort()
Retrieve the training output port.
A pair of vectors using the wire format formerly provided by yarp::os::PortablePair<yarp::sig::Vector...
Definition VectorPair.h:28
cmd
Definition dataTypes.h:30
bool error
PortableT< ITransformer > TransformerPortable
A portable wrapper around an ITransformer.
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.