iCub-main
Loading...
Searching...
No Matches
PredictModule.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_PREDICTMODULE__
20#define LM_PREDICTMODULE__
21
24
25namespace iCub {
26namespace learningmachine {
27
38protected:
43
44public:
51
58 return this->machinePortable;
59 }
60
68 return this->getMachinePortable().getWrapped();
69 }
70};
71
72
73
83class PredictProcessor : public IMachineProcessor, public yarp::os::PortReader {
84public:
91
92 /*
93 * Inherited from PortReader.
94 */
95 virtual bool read(yarp::os::ConnectionReader& connection);
96};
97
98
114protected:
115
119 yarp::os::BufferedPort<yarp::sig::Vector> predict_inout;
120
125
130
134 yarp::os::Port model_in;
135
140
145
146 /*
147 * Inherited from IMachineLearnerModule.
148 */
149 void registerAllPorts();
150
151 /*
152 * Inherited from IMachineLearnerModule.
153 */
154 void unregisterAllPorts();
155
156 /*
157 * Inherited from IMachineLearnerModule.
158 */
159 void printOptions(std::string error = "");
160
161public:
167 PredictModule(std::string pp = "/lm/predict")
170
174 virtual ~PredictModule() { }
175
176 /*
177 * Inherited from IMachineLearnerModule.
178 */
179 virtual bool configure(yarp::os::ResourceFinder& opt);
180
181 /*
182 * Inherited from IMachineLearnerModule.
183 */
184 virtual bool interruptModule();
185
186 /*
187 * Inherited from IMachineLearnerModule.
188 */
189 virtual bool respond(const yarp::os::Bottle& cmd, yarp::os::Bottle& reply);
190
191 /*
192 * Inherited from IMachineLearnerModule.
193 */
194 virtual bool close() {
196 if(this->getMachinePortable().hasWrapped()) {
197 return this->getMachine().close();
198 } else {
199 return true;
200 }
201 }
202
209 return this->getMachinePortable().getWrapped();
210 }
211
218 return this->machinePortable;
219 }
220
221};
222
223} // learningmachine
224} // iCub
225
226#endif
An abstract base module for the machine learning YARP interface.
A generalized interface for a learning machine for offline and online learning machines (e....
virtual bool close()
Shut the object down.
Generic abstract class for machine based processors.
virtual MachinePortable & getMachinePortable()
Retrieve the machine portable machine wrapper.
virtual IMachineLearner & getMachine()
Convenience function to quickly retrieve the machine that is wrapped in the portable machine wrapper.
MachinePortable & machinePortable
A pointer to a concrete wrapper around a learning machine.
IMachineProcessor(MachinePortable &mp)
Constructor.
T & getWrapped() const
The accessor for the wrapped object.
Definition PortableT.h:215
virtual ~PredictModule()
Destructor (empty).
void unregisterAllPorts()
Unregisters all ports used by this module.
yarp::os::BufferedPort< yarp::sig::Vector > predict_inout
Buffered port for the incoming samples and corresponding replies.
MachinePortable machinePortable
A concrete wrapper around a learning machine.
yarp::os::Port model_in
Incoming port for the models from the train module.
void printOptions(std::string error="")
Prints the accepted command line options with an optional error message.
virtual bool close()
Close the module.
virtual IMachineLearner & getMachine()
Retrieve the machine that is wrapped in the portable machine wrapper.
PredictModule(std::string pp="/lm/predict")
Constructor.
void registerAllPorts()
Registers all ports used by this module.
virtual bool respond(const yarp::os::Bottle &cmd, yarp::os::Bottle &reply)
virtual bool configure(yarp::os::ResourceFinder &opt)
virtual MachinePortable & getMachinePortable()
Retrieve the machine portable.
PredictProcessor predictProcessor
The processor handling prediction requests.
PredictModule(const PredictModule &other)
Copy constructor (private and unimplemented on purpose).
PredictModule & operator=(const PredictModule &other)
Assignment operator (private and unimplemented on purpose).
Reply processor helper class for predictions.
virtual bool read(yarp::os::ConnectionReader &connection)
PredictProcessor(MachinePortable &mp)
Constructor.
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.