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
22#include <yarp/os/PortablePair.h>
23
25
26
27namespace iCub {
28namespace learningmachine {
29
30
40class TrainProcessor : public IMachineProcessor, public yarp::os::TypedReaderCallback< yarp::os::PortablePair<yarp::sig::Vector,yarp::sig::Vector> > {
41private:
45 bool enabled;
46
47public:
53 TrainProcessor(MachinePortable& mp) : IMachineProcessor(mp), enabled(true) { }
54
60 virtual void setEnabled(bool val) {
61 this->enabled = val;
62 }
63
64 /*
65 * Inherited from TypedReaderCallback.
66 */
67 virtual void onRead(yarp::os::PortablePair<yarp::sig::Vector,yarp::sig::Vector>& sample);
68
69};
70
71
90class TrainModule : public PredictModule {
91private:
95 yarp::os::BufferedPort< yarp::os::PortablePair<yarp::sig::Vector,yarp::sig::Vector> > train_in;
96
100 yarp::os::Port model_out;
101
105 TrainProcessor trainProcessor;
106
110 TrainModule(const TrainModule& other);
111
115 TrainModule& operator=(const TrainModule& other);
116
117 /*
118 * Inherited from IMachineLearnerModule.
119 */
120 void registerAllPorts();
121
122 /*
123 * Inherited from IMachineLearnerModule.
124 */
125 void unregisterAllPorts();
126
127 /*
128 * Inherited from IMachineLearnerModule.
129 */
130 void printOptions(std::string error = "");
131
135 void printMachineList();
136
137public:
144 TrainModule(std::string pp = "/lm/train")
145 : PredictModule(pp), trainProcessor(machinePortable) { }
146
150 virtual ~TrainModule() { };
151
152 /*
153 * Inherited from IMachineLearnerModule.
154 */
155 virtual bool configure(yarp::os::ResourceFinder& opt);
156
157 /*
158 * Inherited from IMachineLearnerModule.
159 */
160 virtual bool interruptModule();
161
162 /*
163 * Inherited from IMachineLearnerModule.
164 */
165 virtual bool respond(const yarp::os::Bottle& cmd, yarp::os::Bottle& reply);
166};
167
168} // learningmachine
169} // iCub
170
171#endif
Generic abstract class for machine based processors.
MachinePortable machinePortable
A concrete wrapper around a learning machine.
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:40
virtual void setEnabled(bool val)
Enables or disables processing of training samples.
Definition TrainModule.h:60
TrainProcessor(MachinePortable &mp)
Constructor.
Definition TrainModule.h:53
virtual void onRead(yarp::os::PortablePair< yarp::sig::Vector, yarp::sig::Vector > &sample)
cmd
Definition dataTypes.h:30
bool error
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.