- Main Page
- Modules
- Classes
- Files
- Related Pages

- File List
- File Members

# src/Simulator.h

Go to the documentation of this file.

    00001 #ifndef SIMULATOR_H_
    00002 #define SIMULATOR_H_
    00003
    00004 #include "config.h"
    00005 #include <ode/ode.h>
    00006 #include "drawstuff/drawstuff.h"
    00007 #include "typedefs.h"
    00008 #include <string>
    00009
    00010 class Simulator {
    00011 public:
    00016     enum ViewpointType {VP_STATIC, VP_CAR_FOLLOW};
    00017
    00019     static Simulator* getInstance();
    00020     virtual ~Simulator();
    00021
    00023     void init(const std::string simfile, const std::string carsfile, const std::string worldfile, bool visualize = true);
    00025     void run();
    00027     void start();
    00029     void loop(int pause);
    00031     void command(int cmd);
    00033     void nearCallback(void *data, dGeomID o1, dGeomID o2);
    00034
    00038     void addSimulationObject(SimulationObject* object);
    00042     void removeSimulationObject(SimulationObject* object);
    00043
    00045     void scheduleForAddition(SimulationObject* o);
    00046
    00048     void scheduleForRemoval(SimulationObject* o);
    00049
    00051     void addSector(Sector* sector);
    00052
    00054     void addViewPoint(float* xyz, float* hpr);
    00055
    00057     std::string getInfo();
    00058
    00060     void printHelp();
    00061
    00062 private:
    00063     //since Simulator is a singleton, we need to keep these private
    00064     Simulator();
    00065     Simulator(const Simulator&);
    00066     Simulator& operator=(const Simulator&);
    00067
    00069     void addScheduledObjects();
    00071     void removeScheduledObjects();
    00072
    00074     void loopHeadLess();
    00075
    00077     void cycleViewpointObject(bool forward = true);
    00078
    00080     void cycleStaticViewPoints(bool forward = true);
    00081
    00083     static Simulator* _instance;
    00084
    00086     SOContainer _sobjects;
    00088     AOContainer _aobjects;
    00090     VOContainer _vobjects;
    00092     SectorMap _sectors;
    00094     SOVector _scheduledForAddition;
    00096     SOVector _scheduledForRemoval;
    00097
    00099     dWorldID _world;
    00101     dSpaceID _space;
    00103     dGeomID _plane;
    00105     dJointGroupID _contactgroup;
    00107     dsFunctions _fn;
    00109     dReal _gravity;
    00111     dReal _ERP;
    00113     dReal _CFM;
    00115     double _simstep;
    00117     int _numOfCars;
    00118
    00120     ViewpointType _viewpointType;
    00122     int _lastCarViewpoint;
    00124     int _lastStaticViewpoint;
    00126     ViewPointVector _viewpoints;
    00128     bool _visualize;
    00129
    00130     friend class ConfigurationParser;
    00131     friend class Sector;
    00132 };
    00133
    00135 static void gStart() { Simulator::getInstance()->start(); }
    00137 static void gLoop(int pause) { Simulator::getInstance()->loop(pause); }
    00139 static void gCommand(int cmd) { Simulator::getInstance()->command(cmd); }
    00141 static void gNearCallback(void *data, dGeomID o1, dGeomID o2) { Simulator::getInstance()->nearCallback(data, o1, o2); }
    00142
    00143 #endif /*SIMULATOR_H_*/