00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <stdio.h>
00034 #include <drawstuff/drawstuff.h>
00035 #include <ode/ode.h>
00036
00037 #include <selforg/noisegenerator.h>
00038
00039 #include "simulation.h"
00040 #include "odeagent.h"
00041 #include <selforg/one2onewiring.h>
00042 #include <selforg/derivativewiring.h>
00043 #include "playground.h"
00044 #include "sphere.h"
00045
00046 #include <selforg/invertnchannelcontroller.h>
00047 #include <selforg/sinecontroller.h>
00048
00049 #include "schlangeservo.h"
00050 #include "schlangeforce.h"
00051 #include "nimm2.h"
00052
00053 ConfigList configs;
00054 list<PlotOption> plotoptions;
00055
00056
00057 void start(const OdeHandle& odeHandle, GlobalData& global)
00058 {
00059 dsPrint ( "\nWelcome to the virtual ODE - robot simulator of the Robot Group Leipzig\n" );
00060 dsPrint ( "------------------------------------------------------------------------\n" );
00061 dsPrint ( "Press Ctrl-C for an basic commandline interface.\n\n" );
00062
00063 global.odeConfig.setParam("gravity",-9.0);
00064
00065
00066
00067
00068
00069
00070
00071 float KameraXYZ[3]= {5.0f, 7.0f, 7.0f};
00072 float KameraViewXYZ[3] = {-85.0f,-12.0f,0.0000f};
00073
00074 dsSetViewpoint ( KameraXYZ , KameraViewXYZ );
00075 dsSetSphereQuality (2);
00076
00077
00078
00079
00080 Playground* playground = new Playground(odeHandle);
00081 playground->setGeometry(15.0, 0.2, 1.5);
00082 playground->setPosition(0,0,0);
00083 global.obstacles.push_back(playground);
00084
00085 Sphere* sphere;
00086 for (int i=-3; i<3; i++){
00087 sphere = new Sphere(odeHandle);
00088 sphere->setPosition(i*0.5,i*0.5,1.0);
00089 global.obstacles.push_back(sphere);
00090 }
00091
00092
00093
00094
00095 SchlangenConf con = SchlangeForce::getDefaultConf();
00096 SchlangeForce*schlange3 = new SchlangeForce(0, odeHandle, con);
00097 Position p3(1,1,0);
00098 Color col3 (1,1,0);
00099 schlange3->place(p3,&col3);
00100 AbstractController *controller3 = new InvertNChannelController(10,true);
00101
00102 One2OneWiring* wiring3 = new One2OneWiring(new ColorUniformNoise(0.1));
00103 OdeAgent* agent3 = new OdeAgent(NoPlot);
00104 agent3->init(controller3, schlange3, wiring3);
00105 global.agents.push_back(agent3);
00106 configs.push_back(controller3);
00107 configs.push_back(schlange3);
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155 showParams(configs);
00156 }
00157
00158 void end(GlobalData& global){
00159 for(ObstacleList::iterator i=global.obstacles.begin(); i != global.obstacles.end(); i++){
00160 delete (*i);
00161 }
00162 global.obstacles.clear();
00163 for(OdeAgentList::iterator i=global.agents.begin(); i != global.agents.end(); i++){
00164 delete (*i)->getRobot();
00165 delete (*i)->getController();
00166 delete (*i);
00167 }
00168 global.agents.clear();
00169 }
00170
00171
00172
00173 void config(GlobalData& global){
00174 changeParams(configs);
00175 }
00176
00177 void printUsage(const char* progname){
00178 printf("Usage: %s [-g] [-l]\n\t-g\tuse guilogger\n\t-l\tuse guilogger with logfile", progname);
00179 }
00180
00181 int main (int argc, char **argv)
00182 {
00183 if(contains(argv, argc, "-g")) plotoptions.push_back(PlotOption(GuiLogger));
00184 if(contains(argv, argc, "-l")) plotoptions.push_back(PlotOption(GuiLogger_File));
00185 if(contains(argv, argc, "-h")) printUsage(argv[0]);
00186
00187
00188 simulation_init(&start, &end, &config);
00189
00190 simulation_start(argc, argv);
00191 simulation_close();
00192 return 0;
00193 }
00194