| 1 |
/************************************************************************* |
| 2 |
* * |
| 3 |
* Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith. * |
| 4 |
* All rights reserved. Email: [email protected] Web: www.q12.org * |
| 5 |
* * |
| 6 |
* This library is free software; you can redistribute it and/or * |
| 7 |
* modify it under the terms of EITHER: * |
| 8 |
* (1) The GNU Lesser General Public License as published by the Free * |
| 9 |
* Software Foundation; either version 2.1 of the License, or (at * |
| 10 |
* your option) any later version. The text of the GNU Lesser * |
| 11 |
* General Public License is included with this library in the * |
| 12 |
* file LICENSE.TXT. * |
| 13 |
* (2) The BSD-style license that is included with this library in * |
| 14 |
* the file LICENSE-BSD.TXT. * |
| 15 |
* * |
| 16 |
* This library is distributed in the hope that it will be useful, * |
| 17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * |
| 19 |
* LICENSE.TXT and LICENSE-BSD.TXT for more details. * |
| 20 |
* * |
| 21 |
*************************************************************************/ |
| 22 |
|
| 23 |
#ifndef _ODE_JOINT_AMOTOR_H_ |
| 24 |
#define _ODE_JOINT_AMOTOR_H_ |
| 25 |
|
| 26 |
#include "joint.h" |
| 27 |
|
| 28 |
|
| 29 |
// angular motor |
| 30 |
|
| 31 |
typedef dxJoint dxJointAMotor_Parent; |
| 32 |
class dxJointAMotor: |
| 33 |
public dxJointAMotor_Parent |
| 34 |
{ |
| 35 |
public: |
| 36 |
dxJointAMotor(dxWorld *w); |
| 37 |
virtual ~dxJointAMotor(); |
| 38 |
|
| 39 |
public: |
| 40 |
virtual void getSureMaxInfo(SureMaxInfo* info); |
| 41 |
virtual void getInfo1(Info1* info); |
| 42 |
virtual void getInfo2(dReal worldFPS, dReal worldERP, |
| 43 |
int rowskip, dReal *J1, dReal *J2, |
| 44 |
int pairskip, dReal *pairRhsCfm, dReal *pairLoHi, |
| 45 |
int *findex); |
| 46 |
virtual dJointType type() const; |
| 47 |
virtual size_t size() const; |
| 48 |
|
| 49 |
public: |
| 50 |
void setOperationMode(int mode); |
| 51 |
int getOperationMode() const { return m_mode; } |
| 52 |
|
| 53 |
void setNumAxes(unsigned num); |
| 54 |
int getNumAxes() const { return m_num; } |
| 55 |
|
| 56 |
dJointBodyRelativity getAxisBodyRelativity(unsigned anum) const; |
| 57 |
|
| 58 |
void setAxisValue(unsigned anum, dJointBodyRelativity rel, dReal x, dReal y, dReal z); |
| 59 |
void getAxisValue(dVector3 result, unsigned anum) const; |
| 60 |
|
| 61 |
private: |
| 62 |
void doGetUserAxis(dVector3 result, unsigned anum) const; |
| 63 |
void doGetEulerAxis(dVector3 result, unsigned anum) const; |
| 64 |
|
| 65 |
public: |
| 66 |
void setAngleValue(unsigned anum, dReal angle); |
| 67 |
dReal getAngleValue(unsigned anum) const { dAASSERT(dIN_RANGE(anum, dSA__MIN, dSA__MAX)); return m_angle[anum]; } |
| 68 |
|
| 69 |
dReal calculateAngleRate(unsigned anum) const; |
| 70 |
|
| 71 |
void setLimotParameter(unsigned anum, int limotParam, dReal value) { dAASSERT(dIN_RANGE(anum, dSA__MIN, dSA__MAX)); m_limot[anum].set(limotParam, value); } |
| 72 |
dReal getLimotParameter(unsigned anum, int limotParam) const { dAASSERT(dIN_RANGE(anum, dSA__MIN, dSA__MAX)); return m_limot[anum].get(limotParam); } |
| 73 |
|
| 74 |
public: |
| 75 |
void addTorques(dReal torque1, dReal torque2, dReal torque3); |
| 76 |
|
| 77 |
private: |
| 78 |
void computeGlobalAxes(dVector3 ax[dSA__MAX]) const; |
| 79 |
void doComputeGlobalUserAxes(dVector3 ax[dSA__MAX]) const; |
| 80 |
void doComputeGlobalEulerAxes(dVector3 ax[dSA__MAX]) const; |
| 81 |
|
| 82 |
void computeEulerAngles(dVector3 ax[dSA__MAX]); |
| 83 |
void setEulerReferenceVectors(); |
| 84 |
|
| 85 |
private: |
| 86 |
inline dSpaceAxis BuildFirstBodyEulerAxis() const; |
| 87 |
inline dJointConnectedBody BuildFirstEulerAxisBody() const; |
| 88 |
|
| 89 |
private: |
| 90 |
friend struct dxAMotorJointPrinter; |
| 91 |
|
| 92 |
private: |
| 93 |
int m_mode; // a dAMotorXXX constant |
| 94 |
unsigned m_num; // number of axes (0..3) |
| 95 |
dJointBodyRelativity m_rel[dSA__MAX]; // what the axes are relative to (global,b1,b2) |
| 96 |
dVector3 m_axis[dSA__MAX]; // three axes |
| 97 |
// these vectors are used for calculating Euler angles |
| 98 |
dVector3 m_references[dJCB__MAX]; // original axis[2], relative to body 1; original axis[0], relative to body 2 |
| 99 |
dReal m_angle[dSA__MAX]; // user-supplied angles for axes |
| 100 |
dxJointLimitMotor m_limot[dJBR__MAX]; // limit+motor info for axes |
| 101 |
}; |
| 102 |
|
| 103 |
|
| 104 |
#endif |
| 105 |
|