[ODE] dRay, c++ interface, khepera model?

Martin C. Martin martin at metahuman.org
Thu Nov 21 14:38:01 2002


This is a multi-part message in MIME format.
--------------AE4A85DEE0EE67C92AD2D7AE
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Here's the new C++ interface.  It most likely won't compile out of the box
with ODE 0.03, since it uses some of the newer features in the CVS
version.  But it shouldn't be hard to port, more or less just comment out
lines that don't compile.

- Martin

Thomas Buehmann wrote:
> 
> hi,
> is it possible to get the c++ interface by martin c. martin and the dRay
> contribution without having to use cvs or copy and paste?
> apart from that, is anyone aware of a good khepera-style two-wheeled
> differential-steering model? if i use two wheels in front of my vehicle to drive
> and steer and an additional supporting wheel in the back, the latter tends to
> bend if the distance between front-wheels and supporting wheel is small (all use
> hinge2). is that model too simple or is it just a matter of tweaking cfm etc...?
> 
> thanks,
> thomas.
> 
> sorry if this mail got posted twice. i send it earlier from an unlisted address.
> ______________________________________________________________________________
> Der Anrufbeantworter für Ihre E-Mail-Korrespondenz - WEB.DE FreeMail
> http://freemail.web.de/features/?mc=021137
> 
> _______________________________________________
> ODE mailing list
> ODE@q12.org
> http://q12.org/mailman/listinfo/ode
--------------AE4A85DEE0EE67C92AD2D7AE
Content-Type: application/x-unknown-content-type-hfile;
 name="odecpp_new.h"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename="odecpp_new.h"

LyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKioqKioqKioNCiAqCQkJCQkJCQkJICoNCiAqIE9wZW4gRHluYW1pY3Mg
RW5naW5lLCBDb3B5cmlnaHQgKEMpIDIwMDEsMjAwMiBSdXNzZWxsIEwuIFNtaXRoLgkgKg0K
ICogQWxsIHJpZ2h0cyByZXNlcnZlZC4gIEVtYWlsOiBydXNzQHExMi5vcmcgICBXZWI6IHd3
dy5xMTIub3JnIAkgKg0KICoJCQkJCQkJCQkgKg0KICogVGhpcyBsaWJyYXJ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