[ODE] Test Buggy with Four Wheels(URGENT!)

cagla okutan c2sode at yahoo.com.tr
Fri Feb 17 02:02:23 MST 2006


Yes, I had noticed that I forgot to apply motor to the
other front wheel. But isn't it wrong to apply steer
and speed to back wheels. In reality back wheels don't
turn right and left. Now after applying motor and
steer to both front wheels, it is all right, it does
not go right or left when accelerating on a line. but
now this time another problem: after some speed it
begins to turn somersault. It seems i am still doing
something wrong? 

--- Bram Stolk <bram at sara.nl> yazdı:

> You should apply the motor to two wheels.
> Or even 4 wheels.
> Not to just joint[0] only.
> Same goes for steer.
> 
> Bram
> 
> 
> -----Original Message-----
> From: "cagla okutan" <c2sode at yahoo.com.tr>
> To: "ode at q12.org" <ode at q12.org>
> Sent: 17-02-06 0:09
> Subject: [ODE] Test Buggy with Four Wheels(URGENT!)
> 
> Hi,
> I tried to add a fourth wheel to test buggy, the
> manipulated code is below: 
> 
> /***************** SILA *********************/ :
> parts
> added or changed
>  But it did not work. What goes wrong is as follows:
> without any left or right steer when i accelerate
> the
> buggy only pushing the keys 'a' or 'z' , it begins
> to
> go left, it does not go straight. What may be the
> problem. I would be very glad if anybody helps.
> 
> 
> 
> /*
> 
> buggy with suspension.
> this also shows you how to use geom groups.
> 
> */
> 
> 
> #include <ode/ode.h>
> #include <drawstuff/drawstuff.h>
> 
> #ifdef _MSC_VER
> #pragma warning(disable:4244 4305)  // for VC++, no
> precision loss complaints
> #endif
> 
> // select correct drawing functions
> 
> #ifdef dDOUBLE
> #define dsDrawBox dsDrawBoxD
> #define dsDrawSphere dsDrawSphereD
> #define dsDrawCylinder dsDrawCylinderD
> #define dsDrawCappedCylinder dsDrawCappedCylinderD
> #endif
> 
> 
> // some constants
> 
> #define LENGTH 0.7	// chassis length
> #define WIDTH 0.5	// chassis width
> #define HEIGHT 0.2	// chassis height
> #define RADIUS 0.18	// wheel radius
> #define STARTZ 0.5	// starting height of chassis
> #define CMASS 1		// chassis mass
> #define WMASS 0.2	// wheel mass
> 
> 
> // dynamics and collision objects (chassis, 3
> wheels,
> environment)
> 
> static dWorldID world;
> static dSpaceID space;
> static dBodyID body[5]; 	/***************** SILA
> *********************/ 
> static dJointID joint[4];	// joint[0] is the front
> wheel /***************** SILA *********************/
> 
> static dJointGroupID contactgroup;
> static dGeomID ground;
> static dSpaceID car_space;
> static dGeomID box[1];
> static dGeomID sphere[4];	/***************** SILA
> *********************/ 
> static dGeomID ground_box;
> 
> 
> // things that the user controls
> 
> static dReal speed=0,steer=0;	// user commands
> 
> 
> 
> // this is called by dSpaceCollide when two objects
> in
> space are
> // potentially colliding.
> 
> static void nearCallback (void *data, dGeomID o1,
> dGeomID o2)
> {
>   int i,n;
> 
>   // only collide things with the ground
>   int g1 = (o1 == ground || o1 == ground_box);
>   int g2 = (o2 == ground || o2 == ground_box);
>   if (!(g1 ^ g2)) return;
> 
>   const int N = 10;
>   dContact contact[N];
>   n = dCollide
> (o1,o2,N,&contact[0].geom,sizeof(dContact));
>   if (n > 0) {
>     for (i=0; i<n; i++) {
>       contact[i].surface.mode = dContactSlip1 |
> dContactSlip2 |
> 	dContactSoftERP | dContactSoftCFM |
> dContactApprox1;
>       contact[i].surface.mu = dInfinity;
>       contact[i].surface.slip1 = 0.1;
>       contact[i].surface.slip2 = 0.1;
>       contact[i].surface.soft_erp = 0.5;
>       contact[i].surface.soft_cfm = 0.3;
>       dJointID c = dJointCreateContact
> (world,contactgroup,&contact[i]);
>       dJointAttach (c,
> 		    dGeomGetBody(contact[i].geom.g1),
> 		    dGeomGetBody(contact[i].geom.g2));
>     }
>   }
> }
> 
> 
> // start simulation - set viewpoint
> 
> static void start()
> {
>   static float xyz[3] = {0.8317f,-0.9817f,0.8000f};
>   static float hpr[3] =
> {121.0000f,-27.5000f,0.0000f};
>   dsSetViewpoint (xyz,hpr);
>   printf ("Press:\t'a' to increase speed.\n"
> 	  "\t'z' to decrease speed.\n"
> 	  "\t',' to steer left.\n"
> 	  "\t'.' to steer right.\n"
> 	  "\t' ' to reset speed and steering.\n"
> 	  "\t'1' to save the current state to
> 'state.dif'.\n");
> }
> 
> 
> // called when a key pressed
> 
> static void command (int cmd)
> {
>   switch (cmd) {
>   case 'a': case 'A':
>     speed += 0.3;
>     break;
>   case 'z': case 'Z':
>     speed -= 0.3;
>     break;
>   case ',':
>     steer -= 0.5;
>     break;
>   case '.':
>     steer += 0.5;
>     break;
>   case ' ':
>     speed = 0;
>     steer = 0;
>     break;
>   case '1': {
>       FILE *f = fopen ("state.dif","wt");
>       if (f) {
>         dWorldExportDIF (world,f,"");
>         fclose (f);
>       }
>     }
>   }
> }
> 
> 
> // simulation loop
> 
> static void simLoop (int pause)
> {
>   int i;
>   //if (!pause) {
>     // motor
>     dJointSetHinge2Param
> (joint[0],dParamVel2,-speed);
>     dJointSetHinge2Param (joint[0],dParamFMax2,0.1);
> 
>     // steering
> 	
>     dReal v = steer - dJointGetHinge2Angle1
> (joint[0]);
>     if (v > 0.1) v = 0.1;
>     if (v < -0.1) v = -0.1;
> 
=== message truncated ===



	

	
		
_____________________________________________________
Yahoo! kullaniyor musunuz?
Simdi, 1GB e-posta saklama alani sunuyor
http://tr.mail.yahoo.com


More information about the ODE mailing list