Thanks to Kuddel I got a better/stable rover. I still have a rover animation issue.
{
if (TURN_proc > 1) TURN_proc = (TURN_proc - 1);
else if (TURN_proc < 0) TURN_proc = (TURN_proc + 1);
if (TURN_check == TURN_DOWN)TURN_proc = (TURN_proc + db);
else if (TURN_check == TURN_UP)TURN_proc = (TURN_proc - db);
else if (TURN_check == TURN_STOP)TURN_proc = TURN_proc;
double ax14 = TURN_proc - rot;
if (ax14 > 1) ax14 -= 1;
else if (ax14 < 0) ax14 += 1;
double ax36 = TURN_proc + rot;
if (ax36 > 1) ax36 -= 1;
else if (ax36 < 0) ax36 += 1;
SetAnimation(anim_FRONTWHEELFRAMERIGHT, ax14);
//SetAnimation(anim_axle2, TURN_proc);
//SetAnimation(anim_REARWHEELFRAMERIGHT, ax36);
SetAnimation(anim_FRONTLEFTWHEELFRAME, ax14);
//SetAnimation(anim_axle5, TURN_proc);
//SetAnimation(anim_REARWHEELFRAME, ax36);
//sprintf(oapiDebugString(), "ax14:%04d TURN:%04d ROT:%04d", ax14, TURN_proc, rot);
}
left whhel frame
static UINT FRONTWHEELFRAMEGrp1[1] = { GRP_FRONTLEFTAXLE };//LEFTFRONTWHEELFRAME
rms2_anim[4] = new MGROUP_ROTATE(0, FRONTWHEELFRAMEGrp1, 1, _V(-.461, -.224, .62), _V(0, 1, 0), (float)(90 * RAD)); // -2 .. +145
anim_FRONTLEFTWHEELFRAME = CreateAnimation(0.0);
parentFRTFRAME = AddAnimationComponent(anim_FRONTLEFTWHEELFRAME, 0, 1, rms2_anim[4]);
rightwheelframe
static UINT FRONTWHEELFRAMEGrp3A[1] = { GRP_FRONTRIGHTAXLE };//
rms3_anim[4] = new MGROUP_ROTATE(0, FRONTWHEELFRAMEGrp3A, 1, _V(.461, -.224, .62), _V(0, 1, 0), (float)(90 * RAD)); // -2 .. +145
anim_FRONTWHEELFRAMERIGHT = CreateAnimation(0.0);
parentFRTFRAME = AddAnimationComponent(anim_FRONTWHEELFRAMERIGHT, 0, 1, rms3_anim[4]);
as you can see the animation is basically the same
if (TURNDir ==LEFT) {//LEFT TURN
d_hdg = d_hdg + .0000001;//rate of steering change of heading
vs2.surf_hdg -= d_hdg;
if (vs2.surf_hdg < 0) { vs2.surf_hdg += 2 * PI; }
rot += 0.0005;//animation axle wheel turn rate
if (rot > .125) rot = .125;
}
if (TURNDir == RIGHT) {//RIGHT TURN
rot -= 0.0005;//animation axle wheel turn rate
if (rot < -.125) rot = -.125;
d_hdg = d_hdg + .0000001;//rate of steering change of heading
vs2.surf_hdg += d_hdg;
//sprintf(oapiDebugString(), "turn %d SURFHDG %2.2f", i3, vs2.surf_hdg);
if (vs2.surf_hdg > 2 * PI) { vs2.surf_hdg -= 2 * PI; }
}
if (TURNDir == NEUTRAL) {// straight so straighten wheels
//sprintf(oapiDebugString(), "turn %2.2f cos %2.2f sin %2.2f,rot %2.2f", TURN_proc, cosTurn, sinTurn, rot);
if (abs(rot) <= 0.005) rot = 0;
else if (rot < 0) rot += 0.0005;
else if (rot > 0) rot -= 0.0005;
d_hdg = 0;
}
so on left turn the front wheels amost turn 90 degrees plus the turn. they return to 90 degrees right turn fine
Also I wonder if there a fix for the rover being below the surface. I can adjust the td point so at the start it is good but then as you drive it looks like it is sinking. Using the hi res terrain?
TOUCHDOWNVTX td[4];
double x_target = -0.5;
double stiffness = (-1) * (MASS * 9.80655) / (3 * x_target);
double damping = 0.9 * (2 * sqrt(MASS * stiffness));
for (int i = 0; i < 4; i++)
{
td[i].damping = damping;
td[i].mu = 3;
td[i].mu_lng = 3;
td[i].stiffness = stiffness;
}
td[0].pos.x = cos(30 * RAD) * ro;
td[0].pos.y = -Height_From_Ground;
td[0].pos.z = -sin(30 * RAD) * ro;
td[1].pos.x = 0;
td[1].pos.y = -Height_From_Ground;
td[1].pos.z = 1 * ro;
td[2].pos.x = -cos(30 * RAD) * ro;
td[2].pos.y = -Height_From_Ground;
td[2].pos.z = -sin(30 * RAD) * ro;
td[3].pos.x = 0;
td[3].pos.y = 15 * ro;
td[3].pos.z = 0;
SetTouchdownPoints(td, 4);