[216] | 1 | Breakable Joints |
---|
| 2 | |
---|
| 3 | ================================================================================ |
---|
| 4 | |
---|
| 5 | Description: |
---|
| 6 | This is a small addition to ODE that makes joints breakable. Breakable means |
---|
| 7 | that if a force on a joint is to high it wil break. I have included a modified |
---|
| 8 | version of test_buggy.cpp (test_breakable.cpp) so you can see it for your self. |
---|
| 9 | Just drive your buggy into an obstacle and enjoy! |
---|
| 10 | |
---|
| 11 | ================================================================================ |
---|
| 12 | |
---|
| 13 | Installation instructions: |
---|
| 14 | - copy joint.h, joint.cpp, ode.cpp and step.cpp to the ode/src/ directory |
---|
| 15 | - copy common.h and object.h to the include/ directory |
---|
| 16 | - copy test_breakable.cpp to the ode/test/ directory |
---|
| 17 | - add test_breakable.cpp to the ODE_TEST_SRC_CPP object in the makefile. |
---|
| 18 | - make ode-lib |
---|
| 19 | - make ode-test |
---|
| 20 | You can also use the diffs. The above files will quickly go out of sync with the |
---|
| 21 | rest of ODE but the diffs wil remain valid longer. |
---|
| 22 | |
---|
| 23 | ================================================================================ |
---|
| 24 | |
---|
| 25 | Functions: |
---|
| 26 | dJointSetBreakable (dJointID joint, int b) |
---|
| 27 | If b is 1 the joint is made breakable. If b is 0 the joint is made |
---|
| 28 | unbreakable. |
---|
| 29 | |
---|
| 30 | void dJointSetBreakCallback (dJointID joint, dJointBreakCallback *callbackFunc) |
---|
| 31 | Sets the callback function for this joint. If a funtion is set it will be |
---|
| 32 | called if the joint is broken but before it is actually detached or deleted. |
---|
| 33 | |
---|
| 34 | void dJointSetBreakMode (dJointID joint, int mode) |
---|
| 35 | Use this functions to set some flags. These flags can be ORred ( | ) |
---|
| 36 | together; ie. dJointSetBreakMode (someJoint, |
---|
| 37 | dJOINT_BREAK_AT_B1_FORCE|dJOINT_DELETE_ON_BREAK) |
---|
| 38 | dJOINT_DELETE_ON_BREAK - If the joint breaks it wil be deleted. |
---|
| 39 | dJOINT_BREAK_AT_B1_FORCE - If the force on body 1 is to high the joint will |
---|
| 40 | break |
---|
| 41 | dJOINT_BREAK_AT_B1_TORQUE - If the torque on body 1 is to high the joint will |
---|
| 42 | break |
---|
| 43 | dJOINT_BREAK_AT_B2_FORCE - If the force on body 2 is to high the joint will |
---|
| 44 | break |
---|
| 45 | dJOINT_BREAK_AT_B2_TORQUE - If the torque on body 2 is to high the joint will |
---|
| 46 | break |
---|
| 47 | |
---|
| 48 | void dJointSetBreakForce (dJointID joint, int body, dReal x, dReal y, dReal z) |
---|
| 49 | With this function you can set the maximum force for a body connected to this |
---|
| 50 | joint. A value of 0 for body means body 1, 1 means body 2. The force is |
---|
| 51 | relative to the bodies rotation. |
---|
| 52 | |
---|
| 53 | void dJointSetBreakTorque (dJointID joint, int body, dReal x, dReal y, dReal z) |
---|
| 54 | With this function you can set the maximum torque for a body connected to this |
---|
| 55 | joint. A value of 0 for body means body 1, 1 means body 2. The torque is |
---|
| 56 | relative to the bodies rotation. |
---|
| 57 | |
---|
| 58 | int dJointIsBreakable (dJointID joint) |
---|
| 59 | Returns 1 if this joint is breakable, 0 otherwise. |
---|
| 60 | |
---|
| 61 | int dJointGetBreakMode (dJointID joint) |
---|
| 62 | Returns the breakmode flag. |
---|
| 63 | |
---|
| 64 | void dJointGetBreakForce (dJointID joint, int body, dReal *force) |
---|
| 65 | Returns the force at what this joint will break. A value of 0 for body means |
---|
| 66 | body 1, 1 means body 2. force must have enough space for 3 dReal values. |
---|
| 67 | |
---|
| 68 | void dJointGetBreakTorque (dJointID joint, int body, dReal *torque) |
---|
| 69 | Returns the torque at what this joint will break. A value of 0 for body |
---|
| 70 | means body 1, 1 means body 2. force must have enough space for 3 dReal |
---|
| 71 | values. |
---|
| 72 | |
---|
| 73 | ================================================================================ |
---|
| 74 | |
---|
| 75 | The callback function is defined like this (in common.h): |
---|
| 76 | void dJointBreakCallback (dJointID); |
---|
| 77 | |
---|
| 78 | ================================================================================ |
---|
| 79 | |
---|
| 80 | Problems, known bugs & other issues: |
---|
| 81 | - If the timestep is very small then joints get a lot weaker. They can even fall |
---|
| 82 | apart! |
---|
| 83 | - I have tested all this with the latest checkout from CVS (at the time of |
---|
| 84 | writing ofcourse). I haven't tested it with earlier versions of ODE. |
---|
| 85 | - I have modified the code that fills the jointfeedback struct. I haven't tested |
---|
| 86 | if it still works. |
---|
| 87 | - I'm not sure if the forces are really relative to the connected bodies. |
---|
| 88 | - There are some memory leaks in the test_breakable.cpp example. |
---|
| 89 | |
---|
| 90 | ================================================================================ |
---|
| 91 | |
---|
| 92 | Bugfixes and changes: |
---|
| 93 | 09/08/2003 |
---|
| 94 | - I fixed a bug when there where 0 joints in the simulation |
---|
| 95 | |
---|
| 96 | 06/12/2003 |
---|
| 97 | - dJointGetBreakMode() added, by vadim_mcagon@hotmail.com |
---|
| 98 | |
---|
| 99 | 11/03/2004 |
---|
| 100 | - Updated files to work with latest CVS checkout. |
---|
| 101 | - Added support for dWorldStepFast1() |
---|
| 102 | - Added separate test_breakable.cpp example. |
---|
| 103 | - Updated the code that breaks and destroys a joint. |
---|
| 104 | |
---|
| 105 | ================================================================================ |
---|
| 106 | |
---|
| 107 | Send me an e-mail if you have any suggestions, ideas, bugs, bug-fixes, anything! |
---|
| 108 | e-mail: roelvandijk@home.nl |
---|
| 109 | |
---|
| 110 | Roel van Dijk - 11/03/2004 |
---|