Esempio n. 1
0
// Called by Physics::Server when the Level is attached to the server.
void CLevel::Activate()
{
	TimeToSim = 0.0;

	// Initialize ODE //???per-Level?
	dInitODE();
	ODEWorldID = dWorldCreate();
	dWorldSetQuickStepNumIterations(ODEWorldID, 20);

	// FIXME(enno): is a quadtree significantly faster? -- can't count geoms with quadtree
	ODECommonSpaceID  = dSimpleSpaceCreate(NULL);
	ODEDynamicSpaceID = dSimpleSpaceCreate(ODECommonSpaceID);
	ODEStaticSpaceID  = dSimpleSpaceCreate(ODECommonSpaceID);

	dWorldSetGravity(ODEWorldID, Gravity.x, Gravity.y, Gravity.z);
	dWorldSetContactSurfaceLayer(ODEWorldID, 0.001f);
	dWorldSetContactMaxCorrectingVel(ODEWorldID, 100.0f);
	dWorldSetERP(ODEWorldID, 0.2f);     // ODE's default value
	dWorldSetCFM(ODEWorldID, 0.001f);    // the default is 10^-5

	// setup autodisabling
	dWorldSetAutoDisableFlag(ODEWorldID, 1);
	dWorldSetAutoDisableSteps(ODEWorldID, 5);
	//dWorldSetAutoDisableTime(ODEWorldID, 1.f);
	dWorldSetAutoDisableLinearThreshold(ODEWorldID, 0.05f);   // default is 0.01
	dWorldSetAutoDisableAngularThreshold(ODEWorldID, 0.1f);  // default is 0.01

	// create a Contact group for joints
	ContactJointGroup = dJointGroupCreate(0);
}
Esempio n. 2
0
int main (int argc, char **argv)
{
	doFast = true;
	
	// setup pointers to drawstuff callback functions
	dsFunctions fn;
	fn.version = DS_VERSION;
	fn.start = &start;
	fn.step = &simLoop;
	fn.command = &command;
	fn.stop = 0;
	fn.path_to_textures = "../../drawstuff/textures";
  if(argc==2)
    {
        fn.path_to_textures = argv[1];
    }
	
	dInitODE();

	bodies = 0;
	joints = 0;
	boxes = 0;
	spheres = 0;
	
	resetSimulation();
	
	// run simulation
	dsSimulationLoop (argc,argv,352,288,&fn);
	
	dJointGroupDestroy (contactgroup);
	dSpaceDestroy (space);
	dWorldDestroy (world);
	dCloseODE();
	return 0;
}
    /**
     *  \brief The constructor for the physical world.
     *
     *  pre:
     *      - none
     *
     *  post:
     *      - all private variables should be initialized correct
     *        should correct be spezified?
     *      - world, space, contactgroup and world_init to false (0)
     */
    WorldPhysics::WorldPhysics(ControlCenter *control) {

      this->control = control;
      draw_contact_points = 0;
      fast_step = 0;
      world_cfm = 1e-10;
      world_erp = 0.1;
      world_gravity = Vector(0.0, 0.0, -9.81);
      ground_friction = 20;
      ground_cfm = 0.00000001;
      ground_erp = 0.1;
      world = 0;
      space = 0;
      contactgroup = 0;
      world_init = 0;
      num_contacts = 0;
      create_contacts = 1;
      log_contacts = 0;

      // the step size in seconds
      step_size = 0.01;
      // dInitODE is relevant for using trimesh objects as correct as
      // possible in the ode implementation
      MutexLocker locker(&iMutex);
#ifdef ODE11
      // for ode-0.11
      dInitODE2(0);
      dAllocateODEDataForThread(dAllocateMaskAll);
#else
      dInitODE();
#endif
      dSetErrorHandler (myErrorFunction);
      dSetDebugHandler (myDebugFunction);
      dSetMessageHandler (myMessageFunction);
    }
Esempio n. 4
0
int main()
{
  dInitODE();
  testRandomNumberGenerator();
  testInfinity();
  testPad();
  testCrossProduct();
  testSetZero();
  testNormalize3();
  //testReorthonormalize();     ... not any more
  testPlaneSpace();
  testMatrixMultiply();
  testSmallMatrixMultiply();
  testCholeskyFactorization();
  testCholeskySolve();
  testInvertPDMatrix();
  testIsPositiveDefinite();
  testFastLDLTFactorization();
  testSolveLDLT();
  testLDLTAddTL();
  testLDLTRemove();
  testMassFunctions();
  testRtoQandQtoR();
  testQuaternionMultiply();
  testRotationFunctions();
  dTestMatrixComparison();
  dTestSolveLCP();
  // dTestDataStructures();
  dCloseODE();
  return 0;
}
Esempio n. 5
0
int main(int argc, char **argv)
{
    PseudoRandomSeed();
  
    dInitODE();

//create simulator and set robot position at (0, -8)  
    Simulator sim(0, -8);    

//create motion planner
    MotionPlanner mp(&sim);    

//create graphics
    Graphics graphics(&mp);
    
//create obstacles and terrain
    CreateWorld1(&sim);
    
//if argument specified, set as maximum motion planning time
    if(argc > 1)
	graphics.SetMotionPlannerMaxTime(atof(argv[1]));    

//print help messages
    graphics.HandleEventOnHelp();

//enter event loop
    graphics.MainLoop();
    
    return 0;    
}
Esempio n. 6
0
int main (int argc, char **argv)
{
  int i;
  dInitODE();

  // process the command line args. anything that starts with `-' is assumed
  // to be a drawstuff argument.
  for (i=1; i<argc; i++) {
    if ( argv[i][0]=='-' && argv[i][1]=='i' && argv[i][2]==0) cmd_interactive = 1;
    else if ( argv[i][0]=='-' && argv[i][1]=='g' && argv[i][2]==0) cmd_graphics = 0;
    else if ( argv[i][0]=='-' && argv[i][1]=='e' && argv[i][2]==0) cmd_graphics = 0;
    else if ( argv[i][0]=='-' && argv[i][1]=='n' && isdigit(argv[i][2]) ) {
      char *endptr;
      long int n = strtol (&(argv[i][2]),&endptr,10);
			if (*endptr == 0) cmd_test_num = n;
		}
    else
      cmd_path_to_textures = argv[i];
  }

  // do the tests
  if (cmd_test_num == -1) {
    for (i=0; i<NUM_JOINTS*100; i++) doTest (argc,argv,i,0);
  }
  else {
    doTest (argc,argv,cmd_test_num,1);
  }

  dCloseODE();
  return 0;
}
Esempio n. 7
0
 void CDynamics3DEngine::Init(TConfigurationNode& t_tree) {
    /* Init parent */
    CPhysicsEngine::Init(t_tree);
    /* Parse the XML */
    GetNodeAttributeOrDefault(t_tree, "gravity", m_cGravity, CVector3(0.0f, 0.0f, -9.81f));
    GetNodeAttributeOrDefault<Real>(t_tree, "erp", m_fERP, 0.8);
    GetNodeAttributeOrDefault<Real>(t_tree, "cfm", m_fCFM, 0.01);
    GetNodeAttributeOrDefault<UInt32>(t_tree, "iterations", m_unIterations, 20);
    GetNodeAttributeOrDefault<size_t>(t_tree, "max_contacts", m_unMaxContacts, 32);
    /* Init ODE stuff */
    m_tWorldID = dWorldCreate();
    m_tSpaceID = dHashSpaceCreate(0);
    dSpaceSetSublevel(m_tSpaceID, 0);
    m_tContactJointGroupID = dJointGroupCreate(0);
    dWorldSetGravity(m_tWorldID, 0.0f, 0.0f, -9.81f);
    dWorldSetERP(m_tWorldID, m_fERP);
    dWorldSetCFM(m_tWorldID, m_fCFM);
    dWorldSetQuickStepNumIterations(m_tWorldID, m_unIterations);
    dInitODE();
    /* Initialize contact information */
    m_ptContacts = new dContact[m_unMaxContacts];
    for(UInt32 i  = 0; i < m_unMaxContacts; ++i) {
       ::memset(&(m_ptContacts[i].surface), 0, sizeof(dSurfaceParameters));
       m_ptContacts[i].surface.mode = dContactMu2;
       m_ptContacts[i].surface.mu = dInfinity;
       m_ptContacts[i].surface.mu2 = dInfinity;
    }
    /* Add a planar floor */
    m_tFloor = dCreatePlane(m_tSpaceID, 0, 0, 1.0f, 0.0f);
    /* Set the random seed from a random number taken from ARGoS RNG */
    m_pcRNG = CARGoSRandom::CreateRNG("argos");
    dRandSetSeed(m_pcRNG->Uniform(CRange<UInt32>(1,65535)));
 }
void PhysWorld::Initialize()
{
	dInitODE();
    mWorld = dWorldCreate();
	mSpace = dSimpleSpaceCreate(0);
	isInitialized = true;
}
Esempio n. 9
0
/* ------------------------
* メイン関数
------------------------ */
int main(int argc, char *argv[])
{
    /* txtデータ読み込み */
    LoadTxt("route.txt", routeX, routeY, routeZ, &lineRoute);
    LoadTxt("obstacle.txt", obstX, obstY, obstZ, &lineObst);
    /* ODEの初期化 */
    dInitODE();
    /* 描画関数の設定 */
    setDrawStuff();
    /* ワールド, スペース, 接触点グループの生成 */
    world = dWorldCreate();
    space = dHashSpaceCreate(0);
    contactgroup = dJointGroupCreate(0);
    /* 地面, 重力の生成 */
    ground = dCreatePlane(space,0,0,1,0);
    dWorldSetGravity(world, 0.0, 0.0, -9.8);
    /* CFM, ERPの設定 */
    dWorldSetCFM(world,1e-3);
    dWorldSetERP(world,0.8);
    /* 全方向移動ロボットの生成 */
    t1 = clock();
    MakeBox();
    MakeOmni();
    /* シミュレーションループ */
    dsSimulationLoop(argc,argv,640,480,&fn);
    /* 接触点グループ, スペース, ワールドの破壊, ODEの終了 */
    dJointGroupDestroy(contactgroup);
    dSpaceDestroy(space);
    dWorldDestroy(world);
    dCloseODE();
    return 0;
}
Esempio n. 10
0
ODEDomain::ODEDomain(char const *space_type, Input *input) : BaseDomain(input)
{
    printf("ODEDomain constructor\n");   
    dInitODE();
    world = dWorldCreate();
    contactgroup = dJointGroupCreate (0);
           
    //dWorldSetAutoDisableFlag(world,1);
    
    //dWorldSetCFM(world,1e-5);
    //Set and get the global CFM (constraint force mixing) value. Typical values are in the range 10-9 -- 1. The default is 10-5 if single precision is being used, or 10-10 if double precision is being used.
    
    //TODO HERE HAS TO BE ANOTHER PARAMETR
    //dWorldSetContactSurfaceLayer(world,0.001);

    //dWorldSetQuickStepNumIterations (world,ITERS);
    
    dRandSetSeed (time(NULL));
    setGravity(m_input->gravity_v[0],m_input->gravity_v[1],m_input->gravity_v[2]);

    if (space_type == std::string("quad"))
    {
        dVector3 Center = {boundaries[0][0]+delta[0]*0.5, boundaries[1][0]+delta[1]*0.5, boundaries[2][0]+delta[2]*0.5, 0};
        dVector3 Extents = {delta[0] * 0.55, delta[1] * 0.55, delta[2] * 0.55, 0};                
        printf(":::: Using Quad Tree Space\n");
        space = dQuadTreeSpaceCreate (0, Center, Extents, 6);        
    }
    else if (space_type == std::string("hash"))
    {                
        printf(":::: Using Hash Space\n");
        space = dHashSpaceCreate (0);
        //dHashSpaceSetLevels (space,-10,10);
    }
    else if (space_type == std::string("sap")) 
    {
        printf(":::: Using Sweep And Prune Space\n");
        space = dSweepAndPruneSpaceCreate (0, dSAP_AXES_XYZ);
    }
    else if (space_type == std::string("simple")) 
    {
        printf(":::: Using Simple Space\n");
        space = dSimpleSpaceCreate(0);
    }

    if (!space) 
    {
        printf(":::: Using Sweep And Prune Space\n");
        space = dSweepAndPruneSpaceCreate (0, dSAP_AXES_XYZ);            
    }
    
    //TODO redo tests
    //I did tests: deposition of 10000 particles without& (~catBits[PARTICLES])& (~catBits[PARTICLES]) collisions.
    //SWAP: 6 sec
    //HASH: 7.15 sec
    //QUAD: 41.8 sec
    //SIMLE: 59 sec
    
    printf("ODE conf: %s", dGetConfiguration());      
    printf("\n:::: sizeof(dReal)=%lu\n\n", sizeof(dReal));
}
Esempio n. 11
0
void PhysicsServer::Init()
{
    if (m_bInited)
    {
        return;
    }
    RemoveChildren();
    m_Objects.clear();

    dInitODE();

    m_WorldID           = dWorldCreate();
    m_DefaultSpaceID    = dHashSpaceCreate( NULL );
    m_ContactGroupID    = dJointGroupCreate( 0 );

    dWorldSetAutoDisableFlag( m_WorldID, 1 );
    dWorldSetAutoDisableAverageSamplesCount( m_WorldID, 1 );

    if (m_WorldID)
    {
        SetERP( m_ERP );
        SetCFM( m_CFM );
        SetGravity( m_Gravity );
    }

    m_pDefMaterial = g_pObjectServer->FindObject<PhysMaterial>( "defaullt_mtl", this );
    if (!m_pDefMaterial) 
    {
        m_pDefMaterial = new PhysMaterial();
        m_pDefMaterial->SetName( "defaullt_mtl" );
        AddChild( m_pDefMaterial );
    }

    m_bInited = true;
} // PhysicsServer::Init
Esempio n. 12
0
 void Init() {
   if(!gODEInitialized) {
     printf("Initializing ODE...\n");
     dInitODE();
     InitODECustomMesh();
     gODEInitialized = true;
   }
 }
Esempio n. 13
0
int main (int argc, char **argv)
{
    // setup pointers to drawstuff callback functions
    dsFunctions fn;
    fn.version = DS_VERSION;
    fn.start = &start;
    fn.step = &simLoop;
    fn.command = &command;
    fn.stop = 0;
    fn.path_to_textures = DRAWSTUFF_TEXTURE_PATH;

    // create world
    dInitODE();
    world = dWorldCreate();

#if 1
    space = dHashSpaceCreate (0);
#elif 0
    dVector3 center = {0,0,0}, extents = { 100, 100, 100};
    space = dQuadTreeSpaceCreate(0, center, extents, 5);
#elif 0
    space = dSweepAndPruneSpaceCreate (0, dSAP_AXES_XYZ);
#else
    space = dSimpleSpaceCreate(0);
#endif

    contactgroup = dJointGroupCreate (0);
    dWorldSetGravity (world,0,0,-0.5);
    dWorldSetCFM (world,1e-5);
    
    dWorldSetLinearDamping(world, 0.00001);
    dWorldSetAngularDamping(world, 0.005);
    dWorldSetMaxAngularSpeed(world, 200);

    dWorldSetContactSurfaceLayer (world,0.001);
    ground = dCreatePlane (space,0,0,1,0);
    
    memset (obj,0,sizeof(obj));

    // create lift platform
    platform = dCreateBox(space, 4, 4, 1);

    dGeomSetCategoryBits(ground, 1ul);
    dGeomSetCategoryBits(platform, 2ul);
    dGeomSetCollideBits(ground, ~2ul);
    dGeomSetCollideBits(platform, ~1ul);

    // run simulation
    dsSimulationLoop (argc,argv,352,288,&fn);

    dJointGroupDestroy (contactgroup);
    dSpaceDestroy (space);
    dWorldDestroy (world);
    dCloseODE();
    return 0;
}
Esempio n. 14
0
WorldManagerServer::WorldManagerServer()
{
	dInitODE();
	mWorld = dWorldCreate();
	mGlobalSpace = dHashSpaceCreate(0);
	mContactGroup = dJointGroupCreate(0);
	dWorldSetGravity(mWorld, 0, -100, 0);

	mStaticSpace = dSimpleSpaceCreate(mGlobalSpace);
}
Esempio n. 15
0
int main(int argc, char *argv[]) {
    dsFunctions fn;
    double x[4] = {0.00}, y[4] = {0.00};  // Center of gravity
    double z[4] = { 0.05, 0.50, 1.50, 2.55};

    double m[4] = {10.00, 2.00, 2.00, 2.00};       // mass

    double anchor_x[4]  = {0.00}, anchor_y[4] = {0.00};// anchors of joints
    double anchor_z[4] = { 0.00, 0.10, 1.00, 2.00};

    double axis_x[4]  = { 0.00, 0.00, 0.00, 0.00};  // axises of joints
    double axis_y[4]  = { 0.00, 0.00, 1.00, 1.00};
    double axis_z[4]  = { 1.00, 1.00, 0.00, 0.00};

    fn.version = DS_VERSION;
    fn.start   = &init;
    fn.step    = &simLoop;
    fn.command = &command;
    fn.path_to_textures = "drawstuff_texture";

    dInitODE();  // Initialize ODE
    world = dWorldCreate();  // Create a world
    dWorldSetGravity(world, 0, 0, -9.8);

    bool isDrawingEnabled = true;

    Leg leg(world);
    LegDraw legDraw(&leg);
    
    /*
    for (int i = 0; i < NUM; i++) {
    dMass mass;
    link[i] = dBodyCreate(world);
    dBodySetPosition(link[i], x[i], y[i], z[i]); // Set a position
    dMassSetZero(&mass);      // Set mass parameter to zero
    dMassSetCapsuleTotal(&mass,m[i],3,r[i],l[i]);  // Calculate mass parameter
    dBodySetMass(link[i], &mass);  // Set mass
    }

    joint[0] = dJointCreateFixed(world, 0); // A fixed joint
    dJointAttach(joint[0], link[0], 0);     // Attach the joint between the ground and the base
    dJointSetFixed(joint[0]);               // Set the fixed joint

    for (int j = 1; j < NUM; j++) {
    joint[j] = dJointCreateHinge(world, 0); // Create a hinge joint
    dJointAttach(joint[j], link[j-1], link[j]); // Attach the joint
    dJointSetHingeAnchor(joint[j], anchor_x[j], anchor_y[j],anchor_z[j]);
    dJointSetHingeAxis(joint[j], axis_x[j], axis_y[j], axis_z[j]);
    }*/

    dsSimulationLoop(argc, argv, 640, 480, &fn); // Simulation loop

    dCloseODE();
    return 0;
}
Esempio n. 16
0
/**
 * @brief Iniciar simulacao com alguns parametros
 *
 * Funcao executada apenas no inicio da simulacao
 *
 */
void start()
{
    // Initialize ODE
    dInitODE();

    // Set initial viewpoint for drawstuff
    float xyz[3] = {0, 0, 125*SC};
    float hpr[3] = {90, -90, 0};

    dsSetViewpoint(xyz,hpr);
}
Esempio n. 17
0
File: dm6.cpp Progetto: Ry0/ODE
/*** シミュレーションの初期化 ***/
void dmInit()
{
	dInitODE();                              // ODEの初期化
	world = dWorldCreate();                  // 世界の創造
	dWorldSetGravity(world, 0.0,0.0,-9.8);        // 重力設定

	space        = dHashSpaceCreate(0);   // 衝突用空間の創造
	contactgroup = dJointGroupCreate(0);  // ジョイントグループの生成
	ground = dCreatePlane(space,0,0,1,0); // 地面(平面ジオメトリ)の生成
	dsSetSphereQuality(3);
}
Esempio n. 18
0
int main (int argc, char **argv)
{
  int i;
  dReal k;
  dMass m;

  /* setup pointers to drawstuff callback functions */
  dsFunctions fn;
  fn.version = DS_VERSION;
  fn.start = &start;
  fn.step = &simLoop;
  fn.command = 0;
  fn.stop = 0;
  fn.path_to_textures = "../../drawstuff/textures";
  if(argc==2)
    {
        fn.path_to_textures = argv[1];
    }

  /* create world */
  dInitODE();
  world = dWorldCreate();
  space = dHashSpaceCreate (0);
  contactgroup = dJointGroupCreate (1000000);
  dWorldSetGravity (world,0,0,-0.5);
  dCreatePlane (space,0,0,1,0);

  for (i=0; i<NUM; i++) {
    body[i] = dBodyCreate (world);
    k = i*SIDE;
    dBodySetPosition (body[i],k,k,k+0.4);
    dMassSetBox (&m,1,SIDE,SIDE,SIDE);
    dMassAdjust (&m,MASS);
    dBodySetMass (body[i],&m);
    sphere[i] = dCreateSphere (space,RADIUS);
    dGeomSetBody (sphere[i],body[i]);
  }
  for (i=0; i<(NUM-1); i++) {
    joint[i] = dJointCreateBall (world,0);
    dJointAttach (joint[i],body[i],body[i+1]);
    k = (i+0.5)*SIDE;
    dJointSetBallAnchor (joint[i],k,k,k+0.4);
  }

  /* run simulation */
  dsSimulationLoop (argc,argv,352,288,&fn);

  dJointGroupDestroy (contactgroup);
  dSpaceDestroy (space);
  dWorldDestroy (world);
  dCloseODE();
  return 0;
}
int main (int argc, char **argv)
{
    // setup pointers to drawstuff callback functions
    dsFunctions fn;
    fn.version = DS_VERSION;
    fn.start = &start;
    fn.step = &simLoop;
    fn.stop = 0;
    fn.command = 0;
    fn.path_to_textures = "../../drawstuff/textures";
 
    dInitODE ();
    // create world
    world = dWorldCreate ();
    space = dHashSpaceCreate (0);
    dWorldSetGravity (world,0,0,0); //Original Gravity = -0.2
    dWorldSetCFM (world,1e-5);
    dCreatePlane (space,0,0,1,0);
    contactgroup = dJointGroupCreate (0);

    // create object
    sphere0 = dBodyCreate (world);
    sphere0_geom = dCreateSphere (space,0.5);
    dMassSetSphere (&m,1,0.5);
    dBodySetMass (sphere0,&m);
    dGeomSetBody (sphere0_geom,sphere0);
 
    sphere1 = dBodyCreate (world);
    sphere1_geom = dCreateSphere (space,0.5);
    dMassSetSphere (&m,1,0.5);
    dBodySetMass (sphere1,&m);
    dGeomSetBody (sphere1_geom,sphere1);
 
    sphere2 = dBodyCreate (world);
    sphere2_geom = dCreateSphere (space,0.5);
    dMassSetSphere (&m,1,0.5);
    dBodySetMass (sphere2,&m);
    dGeomSetBody (sphere2_geom,sphere2);
  
    // set initial position
    dBodySetPosition (sphere0,0,0,4);
    dBodySetPosition (sphere1,5,0,4);
    dBodySetPosition (sphere2,-2,0,4);

// run simulation
    dsSimulationLoop (argc,argv,352,288,&fn);
    // clean up
    dJointGroupDestroy (contactgroup);
    dSpaceDestroy (space);
    dWorldDestroy (world);
    dCloseODE();
    return 0;
}
Esempio n. 20
0
int main (int argc, char **argv)
{
    // set for drawing
    dsFunctions fn;
    fn.version = DS_VERSION;
    fn.start   = &start;
    fn.step    = &simLoop;
    fn.command = NULL;
    fn.stop    = NULL;
    fn.path_to_textures = "../textures";


    dInitODE();              // init ODE
    world = dWorldCreate();  // create a dynamic world
    dWorldSetGravity(world,0,0,-0.1);

    dMass m;                 // a parameter for mass
    dMassSetZero (&m);       // initialize the parameter

    //@a sphere
    sphere.body = dBodyCreate (world);     // create a rigid body
    dReal radius = 0.5;                    // radius [m]
    dMassSetSphere (&m,DENSITY,radius);    // calculate a mass parameter for a sphere
    dBodySetMass (sphere.body,&m);         // set the mass parameter to the body
    dBodySetPosition (sphere.body,0,1, 1); // set the position of the body


    //@a box
    box.body = dBodyCreate (world);
    dMassSetBox (&m,DENSITY,sides[0],sides[1],sides[2]);
    dBodySetMass (box.body,&m);
    dBodySetPosition (box.body,0,2,1);

    // a capsule
    capsule.body = dBodyCreate (world);
    dMassSetCapsule(&m,DENSITY,3,radius,length);
    dBodySetMass (capsule.body,&m);
    dBodySetPosition (capsule.body,0,4,1);

    // a cylinder
    cylinder.body = dBodyCreate (world);
    dMassSetCylinder(&m,DENSITY,3,radius,length);
    dBodySetMass (cylinder.body,&m);
    dBodySetPosition (cylinder.body,0,3,1);

    // do the simulation
    dsSimulationLoop (argc,argv,960,480,&fn);

    dWorldDestroy (world); // destroy the world
    dCloseODE();           // close ODE

    return 0;
}
Esempio n. 21
0
int startup_physics(void)
{
    dInitODE();

    world = dWorldCreate();
    space = dHashSpaceCreate(0);
    group = dJointGroupCreate(0);

    dWorldSetGravity(world, 0, (dReal) -9.8, 0);
    // dWorldSetAutoDisableFlag(world, 1);

    return 1;
}
Esempio n. 22
0
void initWorldModelling(int testcase)
{
    /* create world */
    dRandSetSeed(1);
    dInitODE();
    //dInitODE2(dInitFlagManualThreadCleanup);
    //dAllocateODEDataForThread(dAllocateMaskAll);
    world = dWorldCreate();
    space = dHashSpaceCreate (0);

    //dWorldSetAutoDisableFlag(World, 1);

    // The parameter needs to be zero.
    contactgroup = dJointGroupCreate (0);
    dWorldSetGravity (world,0,-9.81f,0);
    dWorldSetCFM (world,1e-2f);   //1e-5f was the originally value used.
    dWorldSetERP(world,1.0f);   // 1 is Error Correction is applied.

    // Set Damping
    dWorldSetLinearDamping(world, 0.01f);  // 0.00001
    dWorldSetAngularDamping(world, 0.005f);     // 0.005
    dWorldSetMaxAngularSpeed(world, 200);

    // Set and get the depth of the surface layer around all geometry objects. Contacts are allowed to sink into the surface layer up to the given depth before coming to rest. The default value is zero. Increasing this to some small value (e.g. 0.001) can help prevent jittering problems due to contacts being repeatedly made and broken.
    dWorldSetContactSurfaceLayer (world,0.001f);

    ground = dCreatePlane (space,0,1,0,0);



    switch(testcase)
    {
    case 1:initIslands();test1();break;// Carrier stability
    case 2:initIslands();test1();test2();break;// Manta landing on island.
    case 3:initIslands();test1();test2();test3();break;// Manta crashing on structure
    case 4:initIslands();test1();test2();test3();test4();break;// Manta landing on runway
    case 5:initIslands();test1();test2();break;// Manta landing on aircraft
    case 6:initIslands();test1();test6();break;// Carrier stranded on island
    case 7:test1();test2();test7();break; //Manta crashing on water.
    case 8:initIslands();test1();test8();break; // Walrus reaching island.
    case 9:test1();test9();break; // Walrus stability.
    case 10:initIslands();test1();test10();break; // Walrus arrive to island and build the command center.
    case 11:initIslands();test11();break; // Carrier stability far away.
    case 12:initIslands();test1();test12();break; // Bullets
    case 13:initIslands();test13();break;
    default:initIslands();test1();break;
    }

    testing = testcase;

}
Esempio n. 23
0
int main (int argc, char **argv)
{
     
    static dMass m;
    
    dReal mass = 1.0;
    // set for drawing
    dsFunctions fn;
    fn.version = DS_VERSION;
    fn.start   = &start;
    fn.step    = &simLoop;
    fn.command = NULL;
    fn.stop    = NULL;
    fn.path_to_textures = "../textures";


    dInitODE();              // init ODE
    world = dWorldCreate();  // create a dynamic world
    space = dSimpleSpaceCreate  (0);
    

    

    //@a box
    capsule = dBodyCreate (world);
    geom =  dCreateCapsule (space,radius,length);    //create geometry.
    dMassSetCapsule(&m,DENSITY,3,radius,length);
    dBodySetMass (capsule,&m);
    dGeomSetBody(geom,capsule);
    dBodySetPosition (capsule,0,4,1);


    //Gravedad y cosas de simulacion
    dWorldSetGravity(world,0,0,-9.81);
    dWorldSetCFM (world,1e-5);
    dCreatePlane (space,0,0,1,0);
    contactgroup = dJointGroupCreate (0);

    //  the simulation
    dsSimulationLoop (argc,argv,960,480,&fn);

  
  //-- Destroy the world!!! 
    
    dJointGroupDestroy (contactgroup);
    dSpaceDestroy (space);
    dWorldDestroy (world);
    dCloseODE();

    return 0;
}
Esempio n. 24
0
PWorld::PWorld(dReal dt,dReal gravity,CGraphics* graphics)
{
    //dInitODE2(0);
    dInitODE();
    world = dWorldCreate();
    space = dHashSpaceCreate (0);
    contactgroup = dJointGroupCreate (0);
    dWorldSetGravity (world,0,0,-gravity);
    objects_count = 0;
    sur_matrix = NULL;
    //dAllocateODEDataForThread(dAllocateMaskAll);
    delta_time = dt;
    g = graphics;
}
Esempio n. 25
0
File: arm1.cpp Progetto: Ry0/ODE
int main(int argc, char **argv)
{
  dInitODE();                                     // ODEの初期化
  setDrawStuff();
  world        = dWorldCreate();                  // ワールドの生成
  space        = dHashSpaceCreate(0);             // スペースの生成
  contactgroup = dJointGroupCreate(0);            // 接触グループの生成
  ground       = dCreatePlane(space, 0, 0, 1, 0); // 地面の生成
  dWorldSetGravity(world, 0, 0, -9.8);            // 重力の設定
  makeArm();                                      // アームの生成
  dsSimulationLoop(argc, argv, 640, 480, &fn);    // シミュレーションループ
  dSpaceDestroy(space);                           // スペースの破壊
  dWorldDestroy(world);                           // ワールドの破壊
  dCloseODE();                                    // ODEの終了
  return 0;
}
Esempio n. 26
0
int main (int argc, char **argv)
{
  // setup pointers to drawstuff callback functions
  dsFunctions fn;
  fn.version = DS_VERSION;
  fn.start = &start;
  fn.step = &simLoop;
  fn.command = &command;
  fn.stop = 0;
  fn.path_to_textures = "../../drawstuff/textures";
  if(argc==2)
    {
        fn.path_to_textures = argv[1];
    }

  // create world
  dInitODE();
  world = dWorldCreate();
  space = dHashSpaceCreate (0);
  contactgroup = dJointGroupCreate (0);
  dWorldSetGravity (world,0,0,-0.5);
  dWorldSetCFM (world,1e-5);
  dWorldSetAutoDisableFlag (world,1);

#if 1

  dWorldSetAutoDisableAverageSamplesCount( world, 10 );

#endif


  dWorldSetContactMaxCorrectingVel (world,0.1);
  dWorldSetContactSurfaceLayer (world,0.001);
  dCreatePlane (space,0,0,1,0);
  memset (obj,0,sizeof(obj));

  // run simulation
  dsSimulationLoop (argc,argv,352,288,&fn);

  dJointGroupDestroy (contactgroup);
  dSpaceDestroy (space);
  dWorldDestroy (world);
  dCloseODE();
  return 0;
}
Esempio n. 27
0
int main (int argc, char *argv[]) {
  dInitODE();
  setDrawStuff();
  world        = dWorldCreate();
  space        = dHashSpaceCreate(0);
  contactgroup = dJointGroupCreate(0);

  dWorldSetGravity(world,0,0,0);
  dWorldSetERP(world,1.0);          // ERPの設定
  dWorldSetCFM(world,0.0);          // CFMの設定
  ground = dCreatePlane(space,0,0,1,0);
  create();
  dsSimulationLoop (argc,argv,500,600,&fn);
  dWorldDestroy (world);
  dCloseODE();

  return 0;
}
Esempio n. 28
0
int main (int argc, char **argv)
{
    // setup pointers to drawstuff callback functions
    dsFunctions fn;
    fn.version = DS_VERSION;
    fn.start = &start;
    fn.step = &simLoop;
    fn.command = &command;
    fn.stop = stop;
    fn.path_to_textures = DRAWSTUFF_TEXTURE_PATH;
    
    // create world
    dInitODE();

    // run demo
    dsSimulationLoop (argc, argv, 800, 600, &fn);

    dCloseODE();
    return 0;
}
Esempio n. 29
0
void create_world(Controller* controller,bool log,bool bMoviePlay)
{
// create world
    dRandSetSeed(10);
    dInitODE();
    creatures.clear();
    world = dWorldCreate();
    space = dHashSpaceCreate (0);
    contactgroup = dJointGroupCreate (0);
    dWorldSetGravity (world,0,0,-9.8);
    floorplane = dCreatePlane (space,0,0,1, 0.0);
    dWorldSetERP(world,0.1);
    dWorldSetCFM(world,1E-4);

    Biped* biped = new Biped(log,bMoviePlay);
    dVector3 pos={0.0,0.0,0.0};

    biped->Create(world,space,pos,controller);
    creatures.push_back(biped);
}
Esempio n. 30
0
int main (int argc, char **argv)
{
  int i;

  // setup pointers to drawstuff callback functions
  dsFunctions fn;
  fn.version = DS_VERSION;
  fn.start = &start;
  fn.step = &simLoop;
  fn.command = &command;
  fn.stop = 0;
  fn.path_to_textures = "../../drawstuff/textures";
  if(argc==2)
    {
        fn.path_to_textures = argv[1];
    }

  dInitODE();

  // test the simple space:
  // space = dSimpleSpaceCreate();

  // test the hash space:
  // space = dHashSpaceCreate (0);
  // dHashSpaceSetLevels (space,-10,10);

  // test the quadtree space
  dVector3 Center = {0, 0, 0, 0};
  dVector3 Extents = {10, 0, 10, 0};
  space = dQuadTreeSpaceCreate(0, Center, Extents, 7);

  for (i=0; i < NUM; i++) geom[i] = 0;
  init_test();

  // run simulation
  dsSimulationLoop (argc,argv,352,288,&fn);

  dSpaceDestroy (space);
  dCloseODE();
  return 0;
}