00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 AbstractController* getController_Gnu(int sensornumber, int motornumber,
00017 int param1, double param2)
00018 {
00019 if(param1 < 2) param1 = 2;
00020 return new InvertNChannelController_Gnu(sensornumber, param1);
00021 }
00022
00023
00024 InvertNChannelController_Gnu::InvertNChannelController_Gnu(int channels, int _buffersize)
00025 :InvertNChannelController(channels, _buffersize),
00026 plotlog("c.dat"),plotlog_x("x.dat"),plotlog_a("a.dat")
00027 {
00028
00029
00030 for (int i=0; i<number_channels; i++){
00031 plotlog.addChannel("h["+intToStr(i)+"]");
00032 plotlog_x.addChannel("x["+intToStr(i)+"]");
00033 plotlog_x.addChannel("y["+intToStr(i)+"]");
00034 for (int j=0; j<number_channels; j++){
00035 plotlog.addChannel("c["+intToStr(i)+"]["+intToStr(j)+"]");
00036 plotlog_a.addChannel("a["+intToStr(i)+"]["+intToStr(j)+"]");
00037 }
00038 }
00039 plotlog.command("set zeroaxis");
00040
00041
00042 plotlog_x.command("set zeroaxis");
00043
00044
00045 plotlog_a.command("set zeroaxis");
00046
00047
00048 };
00049
00050
00051
00052 void InvertNChannelController_Gnu::plot(const sensor* x, const motor* y){
00053
00054
00055 for (int i=0; i<number_channels; i++){
00056 plotlog.putData("h["+intToStr(i)+"]",h.val(i,0));
00057 plotlog_x.putData("x["+intToStr(i)+"]",x[i]);
00058 plotlog_x.putData("y["+intToStr(i)+"]",y[i]);
00059 for (int j=0; j<number_channels; j++){
00060 plotlog.putData("c["+intToStr(i)+"]["+intToStr(j)+"]",C.val(i,j));
00061 plotlog_a.putData("a["+intToStr(i)+"]["+intToStr(j)+"]",A.val(i,j));
00062 }
00063 }
00064
00065 t++;
00066 if (t%100) return;
00067
00068 plotlog.plot();
00069
00070
00071 plotlog_x.plot();
00072
00073
00074 plotlog_a.plot();
00075
00076
00077
00078 };
00079
00080
00081
00082 void InvertNChannelController_Gnu::step(const sensor* x_, int number_sensors,
00083 motor* y_, int number_motors){
00084 InvertNChannelController::step(x_, number_sensors, y_, number_motors);
00085 t--;
00086
00087 plot(x_, y_);
00088
00089 t++;
00090 };
00091
00092
00093
00094 void InvertNChannelController_Gnu::stepNoLearning(const sensor* x_, int number_sensors,
00095 motor* y_, int number_motors){
00096 InvertNChannelController::stepNoLearning(x_, number_sensors, y_, number_motors);
00097 t--;
00098 plot(x_, y_);
00099 t++;
00100 };
00101
00102
00103
00104 std::string InvertNChannelController_Gnu::intToStr(int value)
00105 {
00106 std::ostringstream stream;
00107 stream << value;
00108 return stream.str();
00109 };
00110
00111
00112
00113
00114
00115