svmsgd_alg_node.cpp
Go to the documentation of this file.
00001 #include "svmsgd_alg_node.h"
00002 
00003 SvmsgdAlgNode::SvmsgdAlgNode(void) :
00004   algorithm_base::IriBaseAlgorithm<SvmsgdAlgorithm>()
00005 {
00006   //init class attributes if necessary
00007   //this->loop_rate_ = 2;//in [Hz]
00008 
00009   // [init publishers]
00010   
00011   // [init subscribers]
00012   
00013   // [init services]
00014   this->learning_service_ = this->public_node_handle_.advertiseService("svmsgd_learning_service", &SvmsgdAlgNode::new_example_callback, this);
00015 
00016   // [init clients]
00017   
00018   // [init action servers]
00019   
00020   // [init action clients]
00021 }
00022 
00023 SvmsgdAlgNode::~SvmsgdAlgNode(void)
00024 {
00025   // [free dynamic memory]
00026 }
00027 
00028 void SvmsgdAlgNode::mainNodeThread(void)
00029 {
00030   // [fill msg structures]
00031   
00032   // [fill srv structure and make request to the server]
00033   
00034   // [fill action structure and make request to the action server]
00035 
00036   // [publish messages]
00037 }
00038 
00039 /*  [subscriber callbacks] */
00040 
00041 /*  [service callbacks] */
00042 bool SvmsgdAlgNode::new_example_callback(iri_svmsgd::new_train_example_service::Request &req, iri_svmsgd::new_train_example_service::Response &res)
00043 {
00044   this->alg_.process_new_example(req.new_example.feature_vector, req.new_example.label);
00045   res.new_classifier.bias=this->alg_.get_bias();
00046   res.new_classifier.w=this->alg_.get_w();
00047   return true;
00048 }
00049 
00050 bool SvmsgdAlgNode::calibration_callback(iri_svmsgd::calibration_service::Request &req, iri_svmsgd::calibration_service::Response &res)
00051 {
00052   this->alg_.calibrate(req.calibration_examples.calibration_examples);
00053   res.calibrated=true;
00054   return true;
00055 }
00056 
00057 /*  [action callbacks] */
00058 
00059 /*  [action requests] */
00060 
00061 void SvmsgdAlgNode::node_config_update(Config &config, uint32_t level)
00062 {
00063   this->alg_.lock();
00064 
00065   this->alg_.unlock();
00066 }
00067 
00068 void SvmsgdAlgNode::addNodeDiagnostics(void)
00069 {
00070 }
00071 
00072 /* main function */
00073 int main(int argc,char *argv[])
00074 {
00075   return algorithm_base::main<SvmsgdAlgNode>(argc, argv, "svmsgd_alg_node");
00076 }
00077 


iri_svmsgd
Author(s): Arnau Ramisa
autogenerated on Fri Dec 6 2013 23:13:11