iCub-main
Loading...
Searching...
No Matches
TrainModule.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_TRAINMODULE__
20#define LM_TRAINMODULE__
21
24
25
26namespace iCub {
27namespace learningmachine {
28
29
39class TrainProcessor : public IMachineProcessor, public yarp::os::TypedReaderCallback<VectorPair> {
40private:
44 bool enabled;
45
46public:
52 TrainProcessor(MachinePortable& mp) : IMachineProcessor(mp), enabled(true) { }
53
59 virtual void setEnabled(bool val) {
60 this->enabled = val;
61 }
62
63 /*
64 * Inherited from TypedReaderCallback.
65 */
66 virtual void onRead(VectorPair& sample);
67
68};
69
70
88
89class TrainModule : public PredictModule {
90private:
94 yarp::os::BufferedPort<VectorPair> train_in;
95
99 yarp::os::Port model_out;
100
104 TrainProcessor trainProcessor;
105
109 TrainModule(const TrainModule& other);
110
114 TrainModule& operator=(const TrainModule& other);
115
116 /*
117 * Inherited from IMachineLearnerModule.
118 */
119 void registerAllPorts();
120
121 /*
122 * Inherited from IMachineLearnerModule.
123 */
124 void unregisterAllPorts();
125
126 /*
127 * Inherited from IMachineLearnerModule.
128 */
129 void printOptions(std::string error = "");
130
134 void printMachineList();
135
136public:
143 TrainModule(std::string pp = "/lm/train")
144 : PredictModule(pp), trainProcessor(machinePortable) { }
145
149 virtual ~TrainModule() { };
150
151 /*
152 * Inherited from IMachineLearnerModule.
153 */
154 virtual bool configure(yarp::os::ResourceFinder& opt);
155
156 /*
157 * Inherited from IMachineLearnerModule.
158 */
159 virtual bool interruptModule();
160
161 /*
162 * Inherited from IMachineLearnerModule.
163 */
164 virtual bool respond(const yarp::os::Bottle& cmd, yarp::os::Bottle& reply);
165};
166
167} // learningmachine
168} // iCub
169
170#endif
IMachineProcessor(MachinePortable &mp)
Constructor.
void unregisterAllPorts()
Unregisters all ports used by this module.
MachinePortable machinePortable
A concrete wrapper around a learning machine.
void registerAllPorts()
Registers all ports used by this module.
PredictModule(const PredictModule &other)
Copy constructor (private and unimplemented on purpose).
virtual bool configure(yarp::os::ResourceFinder &opt)
TrainModule(std::string pp="/lm/train")
Constructor.
virtual bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &reply)
virtual ~TrainModule()
Destructor (empty).
Port processor helper class for incoming training samples.
Definition TrainModule.h:39
virtual void setEnabled(bool val)
Enables or disables processing of training samples.
Definition TrainModule.h:59
virtual void onRead(VectorPair &sample)
TrainProcessor(MachinePortable &mp)
Constructor.
Definition TrainModule.h:52
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< IMachineLearner > MachinePortable
A portable wrapper around an IMachineLearner.
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.