OHM GeneralVehicle

MaxBuzz

Well-known member
Joined
Sep 19, 2016
Messages
1,392
Reaction score
2,126
Points
128
Location
Kursk
if I understand correctly it is impossible to connect GeneralVehicle attachment with VesselBuilder attachment (Orbiter hangs when uncoupling attachments)
 

MaxBuzz

Well-known member
Joined
Sep 19, 2016
Messages
1,392
Reaction score
2,126
Points
128
Location
Kursk
if I understand correctly it is impossible to connect GeneralVehicle attachment with VesselBuilder attachment (Orbiter hangs when uncoupling attachments)
everything works, I just didn't understand the system
 

Krishnan

I believe, my friends, caravans of rockets
Joined
Nov 22, 2019
Messages
197
Reaction score
116
Points
43
Location
Hampton, Virginia
Preferred Pronouns
He/Him
For realism at the KSC Shuttle Landing Facility, where can I find an alligator mesh and texture?
I suppose you can download one from online, like this one, and convert it to a mesh using utilities.
(edit: This is a crocodile)
 

jacquesmomo

Addon Developer
Addon Developer
Joined
Jun 14, 2008
Messages
611
Reaction score
449
Points
78
Location
FRANCE
Website
francophone.dansteph.com
if I understand correctly it is impossible to connect GeneralVehicle attachment with VesselBuilder attachment (Orbiter hangs when uncoupling attachments)
Hello :cheers:

So some details :

You can absolutely connect a generalVehicle with a vesselbuilder and it works. But..... :unsure:
we cannot disconnect them, otherwise orbiter crashes :

here is an example : it is a Pirogue with 2 meshes:
  • one for the wheels => general vehicle
  • the other with the bodywork and the animations ==> vessel buider.

you can have a look here : https://www.orbiter-forum.com/threads/french-guyana-airports-and-cessna-172.39953/

here are the 2 config-files with the attachment points:

The GV file :
ClassName=GeneralVehicle
Module=GeneralVehicle

EnableFocus=false
Mesh = Guyane\Vehicles\Pirogue_GV
; mesh invisible


Empty_Mass = 1000
Cockpit_pos = 0 2.5 -8.66
Height_From_Ground = 0.6
Always_Upright = FALSE

Max_Speed = 30
Reverse_Max_Speed = 20
Acceleration = 0.25
Brake = 0.1

Steering_Speed = 0.5
Max_Steering_Angle = 10
Camber = 1

; ( en conflit avec VB )
;====================
Front_Lights_Pos = 0 0 8
Rear_Lights_Pos = 0 -1 -1000

Listen_From = Pirogue

BEGIN_ATTACHMENT
C 0 0 0 0 1 0 0 0 1 BDY
END_ATTACHMENT
and the VB file :
ClassName = VesselBuilder1
Module = VesselBuilder1

;CONFIGURATION FILE FOR Pirogue

NOEDITOR = FALSE

CONFIGURATIONS = 1

;<-------------------------GENERAL SETTINGS - Configuration: 0------------------------->

EMPTY_MASS = 1000
VSIZE = 5
PMI = 20 20 10
CSECTIONS = 20 20 20
GRAVITYGDAMP = 0
ROTDRAG = 0.01 0.01 0.01

;<-------------------------MESHES DEFINITIONS------------------------->

MESH_0_NAME = Guyane\Vehicles\PirogueCoque
MESH_0_POS = 0 -0.9 0
MESH_0_DIR = 0 0 1
MESH_0_ROT = 0 1 0
MESH_0_VIS = 23


;<-------------------------DOCKS DEFINITIONS------------------------->


;<-------------------------ATTACHMENTS DEFINITIONS------------------------->

ATT_0_IDX = 0
ATT_0_POS = 0 0 -3
ATT_0_DIR = 0 -1 0
ATT_0_ROT = 0 0 1
ATT_0_RANGE = 10
ATT_0_ID = BDY
ATT_0_TOPARENT = TRUE
ATT_0_IDCHECK = FALSE

ATT_1_IDX = 1
ATT_1_POS = 0 -0.67 2.73
ATT_1_DIR = 3.46945e-018 1 6.12323e-017
ATT_1_ROT = 1 0 0
ATT_1_RANGE = 10
ATT_1_ID = [ Caisse Regina ]
ATT_1_TOPARENT = FALSE
ATT_1_IDCHECK = TRUE
ATT_1_IDCHECKSTRING = Regina (etc etc................)



I tried to make 2 configurations with this pirogue :
- a configuration with the passengers, the suitcases, the tarpaulin... (config_0)
a configuration with nothing (empty car) (config_1)

when you pass from config 0 to config 1, the VB part separates from the GV part. !!! to bad !!! :confused:


I tried a trick: I added the following lines at the beginning of the VB file:

BEGIN_ATTACHMENT
P 0 0 0 0 -1 0 0 0 1 BDY
END_ATTACHMENT

In this case, the passage Config_0 => Config_1 works ! the VB part remains firmly attached to the GV part. :D

unfortunately when we go back to Config_0 orbiter blocks and it crashes :cautious: CTD

I hope my explanations are clear and that you have understood... :cheers:
 

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,271
Reaction score
3,244
Points
203
Location
Toulouse
Orbiter hangs when uncoupling attachments

If I'm correct what fails "under the hood" is that attachments are often used to pass "pointers" (some kind of memory allocation) and if Orbiter asks for a pointer and that there is nothing... it gets messy. It doesn't handle the case when the pointer "is nothing". A pointer can't be "nothing". For the machine, it doesn't make any sense. Its a bit like asking a calculator to divide a number by 0. Well, the good thing is that the environment (MSVS) is very safe, it won't mess anything with your computer.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
I made a cfg for a lunar rover.
But shouldn't it be tilted to follow the slant? The right side is lower than the left
wPjSeVv.jpg

ClassName=GeneralVehicle Module=GeneralVehicle Empty_Mass = 1000 ;[kg] empty mass (almost unused) Mesh = IACarLunarRover_GV ; meshname Cockpit_pos = .411 1.96 .96 ; [m m m] Position of the cockpit camera Acceleration = 1.45 ; [G] Acceleration factor expressed in Gs Brake = 3 ; [G] Deceleration factor expressed in Gs Max_Speed = 200 ; [km/h] Max Speed Reverse_Max_Speed = 50 ; [km/h] Max Speed in Reverse Steering_Speed = 1.5 ; Steering wheel velocity factor Full_Pedal_Time = 2 ; [s] seconds from the beginning of pressing of Acceleration or Brake and the full power is applied Max_Steering_Angle = 30 ; [DEG] Max steering of the front wheels per side Height_From_Ground = 0 ; [m] height of the center of gravity from the ground Always_Upright = TRUE ;if set to TRUE vehicle will always remain parallel to the ideal ground, without following terrain's inclinations Four_Wheels_Steering = FALSE ;if true also rear wheels will steer ;Mesh Groups - just specify using space between them Rear_Right_Groups = 1 Rear_Left_Groups = 1 Front_Right_Groups = 2 Front_Left_Groups = 6 ;Middle_Right_Groups = 1 ;Middle_Left_Groups = 94 ;Steering_Wheel_Groups = 8 ;Front_Wheels_Diameter = 0.750766 ;if not specified the module will try to calcualte it automatically ;Rear_Wheels_Diameter = 0.755238 ;if not specified the module will try to calcualte it automatically ;Rotations info ;Rear_Axel_Pos = 0.0 -0.2426463 -2.121106 ;if not specified the rear right tyre group barycenter will be used ;Front_Axel_Pos = 0.7848695 -0.2371205 1.54079 ;if not specified the front right tyre group barycenter will be used. The left will be considered symmetrical ;Steering_Axis = 0.6513898 0 1.542014 ;axis for steering of the front tyres. Just specify the Front - Right tyre rotation, the Front left will be considered symmetrical if not specified the front right wheel groups barycenter will be used ;Steering_Wheel_Pos = 0 0 0.505 ;if not specified the steering wheel group barycenter will be used ;Steering_Wheel_Axis = 0 0.487821 -0.872943 ; if not specified 0 0 -1 is used Camber = 0 ;[DEG] camber angle of the front wheels, no camber is implemented for rear wheels.

and from the log:
lunarrover: Meshname:IACarLunarRover_GV lunarrover: Cockpit Position: 0.411 1.960 0.960 lunarrover: Acceleration:1.450 Gs Brake:3.000 Gs Maximum Speed:200.000 km/h Max Reverse Speed:50.000 km/h lunarrover: Always Upright TRUE lunarrover: No Steering Animation FALSE lunarrover: Steering Speed Factor:1.500 Maximum Steering Angle:30.000 lunarrover: Full Pedal Time:2.000 lunarrover: Rear Right Groups: 1 n.0 = 1 lunarrover: Rear Left Groups: 1 n.0 = 1 lunarrover: Front Left Groups: 1 n.0 = 6 lunarrover: Front Right Groups: 1 n.0 = 2 lunarrover: Rear Axle Position-> x:0.000000 y:0.427625 z:0.011738 lunarrover: Front Right Axle Position-> x:-1.025371 y:0.429014 z:2.270320 lunarrover: Steering Axis Position-> x:-1.025371 y:0.429014 z:2.270320 lunarrover: Front Wheels Camber = 0.000 lunarrover: Front Wheels Diameter: 0.8580 lunarrover: Rear Wheels Diameter: 0.8580 lunarrover: Height From Ground = 0.000 lunarrover: Towing Attachment Position: 0.000 0.000 0.000 lunarrover: Tow Max Angle:160.0
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,666
Reaction score
100
Points
78
I made a cfg for a lunar rover.
But shouldn't it be tilted to follow the slant? The right side is lower than the left
wPjSeVv.jpg

ClassName=GeneralVehicle Module=GeneralVehicle Empty_Mass = 1000 ;[kg] empty mass (almost unused) Mesh = IACarLunarRover_GV ; meshname Cockpit_pos = .411 1.96 .96 ; [m m m] Position of the cockpit camera Acceleration = 1.45 ; [G] Acceleration factor expressed in Gs Brake = 3 ; [G] Deceleration factor expressed in Gs Max_Speed = 200 ; [km/h] Max Speed Reverse_Max_Speed = 50 ; [km/h] Max Speed in Reverse Steering_Speed = 1.5 ; Steering wheel velocity factor Full_Pedal_Time = 2 ; [s] seconds from the beginning of pressing of Acceleration or Brake and the full power is applied Max_Steering_Angle = 30 ; [DEG] Max steering of the front wheels per side Height_From_Ground = 0 ; [m] height of the center of gravity from the ground Always_Upright = TRUE ;if set to TRUE vehicle will always remain parallel to the ideal ground, without following terrain's inclinations Four_Wheels_Steering = FALSE ;if true also rear wheels will steer ;Mesh Groups - just specify using space between them Rear_Right_Groups = 1 Rear_Left_Groups = 1 Front_Right_Groups = 2 Front_Left_Groups = 6 ;Middle_Right_Groups = 1 ;Middle_Left_Groups = 94 ;Steering_Wheel_Groups = 8 ;Front_Wheels_Diameter = 0.750766 ;if not specified the module will try to calcualte it automatically ;Rear_Wheels_Diameter = 0.755238 ;if not specified the module will try to calcualte it automatically ;Rotations info ;Rear_Axel_Pos = 0.0 -0.2426463 -2.121106 ;if not specified the rear right tyre group barycenter will be used ;Front_Axel_Pos = 0.7848695 -0.2371205 1.54079 ;if not specified the front right tyre group barycenter will be used. The left will be considered symmetrical ;Steering_Axis = 0.6513898 0 1.542014 ;axis for steering of the front tyres. Just specify the Front - Right tyre rotation, the Front left will be considered symmetrical if not specified the front right wheel groups barycenter will be used ;Steering_Wheel_Pos = 0 0 0.505 ;if not specified the steering wheel group barycenter will be used ;Steering_Wheel_Axis = 0 0.487821 -0.872943 ; if not specified 0 0 -1 is used Camber = 0 ;[DEG] camber angle of the front wheels, no camber is implemented for rear wheels.

and from the log:
lunarrover: Meshname:IACarLunarRover_GV lunarrover: Cockpit Position: 0.411 1.960 0.960 lunarrover: Acceleration:1.450 Gs Brake:3.000 Gs Maximum Speed:200.000 km/h Max Reverse Speed:50.000 km/h lunarrover: Always Upright TRUE lunarrover: No Steering Animation FALSE lunarrover: Steering Speed Factor:1.500 Maximum Steering Angle:30.000 lunarrover: Full Pedal Time:2.000 lunarrover: Rear Right Groups: 1 n.0 = 1 lunarrover: Rear Left Groups: 1 n.0 = 1 lunarrover: Front Left Groups: 1 n.0 = 6 lunarrover: Front Right Groups: 1 n.0 = 2 lunarrover: Rear Axle Position-> x:0.000000 y:0.427625 z:0.011738 lunarrover: Front Right Axle Position-> x:-1.025371 y:0.429014 z:2.270320 lunarrover: Steering Axis Position-> x:-1.025371 y:0.429014 z:2.270320 lunarrover: Front Wheels Camber = 0.000 lunarrover: Front Wheels Diameter: 0.8580 lunarrover: Rear Wheels Diameter: 0.8580 lunarrover: Height From Ground = 0.000 lunarrover: Towing Attachment Position: 0.000 0.000 0.000 lunarrover: Tow Max Angle:160.0

Always_Upright = TRUE ;if set to TRUE vehicle will always remain parallel to the ideal ground, without following terrain's inclinations

Set it to FALSE. The ideal ground is the sphere.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
Thanks. I made that one change and now the rover is inside the ground
WaPLpz7.jpg

1vybbKD.jpg

Height_From_Ground = 0 ; [m] height of the center of gravity from the ground Always_Upright = FALSE ;if set to TRUE vehicle will always remain parallel to the ideal ground, without following terrain's inclinations Four_Wheels_Steering = FALSE ;if true also rear wheels will steer

And I have a coded vessel using a sample of the code and it didn't tilt to the side.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
Not sure why this acts like that. BUt When I did it for the GV_LER it was good. Still the heading issues at the caps though.
 

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
611
Reaction score
52
Points
43
Location
Happy Wherever
Not sure why this acts like that. BUt When I did it for the GV_LER it was good. Still the heading issues at the caps though.
Height_From_Ground = 0 ; [m] height of the center of gravity from the ground
This doesn't look right.
Try experimenting with positive values.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
But what about this:

KJ6iavc.jpg


Here the LER should move forward but it moves sideways. The headings about 62 degrees. If I turn to a heading of zero then I get straight forward movement.




scn:
BEGIN_DESC Current scenario state Contains the latest simulation state. END_DESC BEGIN_ENVIRONMENT System Sol Date MJD 52006.7834486119 Help CurrentState_img END_ENVIRONMENT BEGIN_FOCUS Ship ler END_FOCUS BEGIN_CAMERA TARGET ler MODE Extern POS 38.585172 4.583662 -92.102966 TRACKMODE TargetRelative FOV 50.00 END_CAMERA BEGIN_HUD TYPE Surface END_HUD BEGIN_MFD Left TYPE Map REF Moon POS 0.00 0.00 END_MFD BEGIN_MFD Right TYPE Map REF Moon POS 0.00 0.00 END_MFD BEGIN_SHIPS ISS:ProjectAlpha_ISS STATUS Orbiting Earth RPOS -4469410.098 5010888.123 -548226.961 RVEL 5583.6147 4707.7010 -2410.5810 AROT 30.000 0.000 50.000 AFCMODE 7 IDS 0:588 100 1:586 100 2:584 100 3:582 100 4:580 100 NAVFREQ 0 0 XPDR 466 END Mir:Mir STATUS Orbiting Earth RPOS 4883821.451 -277159.182 -4531516.278 RVEL 5262.9248 345.9103 5655.5892 AROT 0.000 -45.000 90.000 AFCMODE 7 IDS 0:540 100 1:542 100 2:544 100 XPDR 482 END Luna-OB1:Wheel STATUS Orbiting Moon RPOS -81527.629 -2236565.030 -36.875 RVEL 1479.0590 -53.8648 -0.0004 AROT -0.000 -0.000 144.363 VROT 0.0000 0.0000 10.0000 AFCMODE 7 IDS 0:560 100 1:564 100 XPDR 494 END PB-01:ShuttlePB STATUS Landed Moon BASE Brighton Beach:2 POS -33.4450804 41.1217033 HEADING 220.00 ALT 1.465 AROT -144.482 -3.641 140.941 AFCMODE 7 PRPLEVEL 0:1.000000 NAVFREQ 484 124 END GL-01:DeltaGlider STATUS Landed Earth BASE Habana:2 POS -82.3988276 22.9994604 HEADING 174.13 ALT 2.469 AROT -112.553 -8.844 172.993 AFCMODE 7 PRPLEVEL 0:1.000000 1:1.000000 NAVFREQ 0 0 0 0 XPDR 0 HOVERHOLD 0 1 0.0000e+000 0.0000e+000 GEAR 1.0000 0.0000 AAP 0:0 0:0 0:0 END GL-NT:DeltaGlider STATUS Landed Moon BASE Brighton Beach:4 POS -33.4375000 41.1315933 HEADING 70.00 ALT 2.553 AROT 15.897 -19.322 41.728 AFCMODE 7 PRPLEVEL 0:1.000000 1:1.000000 NAVFREQ 0 0 0 0 XPDR 0 HOVERHOLD 0 1 0.0000e+000 0.0000e+000 GEAR 1.0000 0.0000 AAP 0:0 0:0 0:0 END SH-02:ShuttleA STATUS Landed Moon BASE Brighton Beach:5 POS -33.4299196 41.1282967 HEADING 43.18 ALT 3.027 AROT 33.290 1.365 39.194 AFCMODE 7 PRPLEVEL 0:1.000000 1:1.000000 NAVFREQ 0 0 XPDR 0 PODANGLE 0.0000 0.0000 DOCKSTATE 0 0.0000 GEAR 0 0.0000 PAYLOAD MASS 0.0 0 ATTREF 0 0 0 ADI_LAYOUT 0 END GL-02:DeltaGlider STATUS Landed Mars BASE Olympus:3 POS -135.4300000 12.7366197 HEADING 0.00 ALT 2.532 AROT 81.111 -8.915 -44.736 AFCMODE 7 PRPLEVEL 0:1.000000 1:1.000000 NAVFREQ 0 0 0 0 XPDR 0 HOVERHOLD 0 1 0.0000e+000 0.0000e+000 GEAR 1.0000 0.0000 AAP 0:0 0:0 0:0 END ler:GV_LER STATUS Landed Moon POS 3.4775830 -86.0077152 HEADING 63.15 ALT 2.166 AROT 1.963 -23.309 175.660 AFCMODE 7 NAVFREQ 0 0 END END_SHIPS
 

jacquesmomo

Addon Developer
Addon Developer
Joined
Jun 14, 2008
Messages
611
Reaction score
449
Points
78
Location
FRANCE
Website
francophone.dansteph.com
Hello

I did some tests at the location on the Moon indicated by gattispilot with vehicles made by me

So all "generic_vehicle" vehicles move sideways as he told us

I tested a truck and a canoe : same as Lunar Rover from Dan's UMmu

1.jpg

On the other hand, my Cessna (it is not a "generic_vehicle" vessel, but a "vehicleBuilder" plane) rolls normally, without slipping...
(of course it does not fly ) :ROFLMAO:

2.jpg

General_vehicle bug ? or Orbiter's bug ? May be both of them.....

If anyone has an idea... 🤔
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
This was from @Max-Q
"
So this bug happens is because as you get close to the pole a degree of longitude is less meters of distance than at the equator, and without a correction somewhere, the sideways bug happens. With one line of code changed, your rover now drives correctly.

In the Move() function, where it does the driving calculation:

C++:
if (FWD || BWD) {
double d_lat = (CurrentSpeed * oapiGetSimStep() * cos(vs2.surf_hdg)) / each_deg;
double d_lng = (CurrentSpeed * oapiGetSimStep() * sin(vs2.surf_hdg)) / each_deg;
vs2.surf_lat += d_lat * RAD;
vs2.surf_lng += d_lng * RAD;
}

Change the last line:

C++:
vs2.surf_lng += d_lng * RAD;
to:

C++:
vs2.surf_lng += (d_lng * tan(abs(vs2.surf_lat))) * RAD;"

I had a rover for the moon,..... And it drove sideways. Now this this code it drive straight.:)


UACS eva guys does the same
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,666
Reaction score
100
Points
78
This was from @Max-Q
"
So this bug happens is because as you get close to the pole a degree of longitude is less meters of distance than at the equator, and without a correction somewhere, the sideways bug happens. With one line of code changed, your rover now drives correctly.

In the Move() function, where it does the driving calculation:

C++:
if (FWD || BWD) {
double d_lat = (CurrentSpeed * oapiGetSimStep() * cos(vs2.surf_hdg)) / each_deg;
double d_lng = (CurrentSpeed * oapiGetSimStep() * sin(vs2.surf_hdg)) / each_deg;
vs2.surf_lat += d_lat * RAD;
vs2.surf_lng += d_lng * RAD;
}

Change the last line:

C++:
vs2.surf_lng += d_lng * RAD;
to:

C++:
vs2.surf_lng += (d_lng * tan(abs(vs2.surf_lat))) * RAD;"

I had a rover for the moon,..... And it drove sideways. Now this this code it drive straight.:)


UACS eva guys does the same
Ah yes, I never tested the pole locations actually so the trigonometry misses up when the latitude gets close to 90. Very well pointed out.
 

gattispilot

Addon Developer
Addon Developer
Joined
Oct 17, 2007
Messages
8,636
Reaction score
2,613
Points
203
Location
Dallas, TX
At a lost.
void T_Rover::Move(double simdt) { double rt = oapiGetSize(GetSurfaceRef()); double moon_circ = rt * 2 * PI; double each_deg = moon_circ / 360; grav_acc = GGRAV * oapiGetMass(GetSurfaceRef()) / (rt * rt); memset(&vs2, 0, sizeof(vs2)); vs2.version = 2; GetStatusEx(&vs2); double theta = 0; if (RGT || LFT) { if (FWD || BWD) { double angolo_sterzata = CurrentSterzo * 2 * Max_Steering_Angle; theta = (CurrentSpeed * oapiGetSimStep() * tan(angolo_sterzata)) / (Passo); vs2.surf_hdg += theta; if (vs2.surf_hdg > PI2) { vs2.surf_hdg -= PI2; } if (vs2.surf_hdg < 0) { vs2.surf_hdg += PI2; } } } if (FWD || BWD) { double d_lat = (CurrentSpeed * oapiGetSimStep() * cos(vs2.surf_hdg)) / each_deg; double d_lng = (CurrentSpeed * oapiGetSimStep() * sin(vs2.surf_hdg)) / each_deg; vs2.surf_lat += d_lat * RAD; vs2.surf_lng += (d_lng * tan(abs(vs2.surf_lat))) * RAD; } double lng, lat, hdg; lng = vs2.surf_lng; lat = vs2.surf_lat; hdg = vs2.surf_hdg; VECTOR3 ant_dx_pos = _V(0.95, 0, 1.55); double ant_dx_dlat = ((ant_dx_pos.z * cos(hdg) - ant_dx_pos.x * sin(hdg)) / each_deg) * RAD; double ant_dx_dlng = ((ant_dx_pos.z * sin(hdg) + ant_dx_pos.x * cos(hdg)) / each_deg) * RAD; double elev_ant_dx = oapiSurfaceElevation(GetSurfaceRef(), lng + ant_dx_dlng, lat + ant_dx_dlat); VECTOR3 ant_sx_pos = _V(-0.95, 0, 1.55); double ant_sx_dlat = ((ant_sx_pos.z * cos(hdg) - ant_sx_pos.x * sin(hdg)) / each_deg) * RAD; double ant_sx_dlng = ((ant_sx_pos.z * sin(hdg) + ant_sx_pos.x * cos(hdg)) / each_deg) * RAD; double elev_ant_sx = oapiSurfaceElevation(GetSurfaceRef(), lng + ant_sx_dlng, lat + ant_sx_dlat); VECTOR3 post_pos = _V(0, 0, -1.55); double post_dlat = ((+post_pos.z * cos(hdg)) / each_deg) * RAD; double post_dlng = ((+post_pos.z * sin(hdg)) / each_deg) * RAD; double elev_post = oapiSurfaceElevation(GetSurfaceRef(), lng + post_dlng, lat + post_dlat); double roll_angle; double pitch_angle; roll_angle = atan2(elev_ant_dx - elev_ant_sx, ant_dx_pos.x - ant_sx_pos.x); pitch_angle = atan2(-elev_post + ((elev_ant_dx + elev_ant_sx) * 0.5), ant_dx_pos.z - post_pos.z); if (FWD || BWD || RGT || LFT) { MATRIX3 rot1 = RotationMatrix(_V(0 * RAD, (90 * RAD - lng), 0 * RAD), TRUE); MATRIX3 rot2 = RotationMatrix(_V(-lat + 0 * RAD, 0, 0 * RAD), TRUE); MATRIX3 rot3 = RotationMatrix(_V(0, 0, 180 * RAD + hdg), TRUE); //MATRIX3 rot4 = RotationMatrix(_V(90 * RAD, 0, 0), TRUE); MATRIX3 rot4 = RotationMatrix(_V(90 * RAD - pitch_angle, 0, roll_angle), TRUE); // MATRIX3 rot_pitch = RotationMatrix(_V(pitch_angle, 0, 0)); // MATRIX3 rot_roll = RotationMatrix(_V(0, 0, roll_angle)); MATRIX3 RotMatrix_Def = mul(rot1, mul(rot2, mul(rot3, rot4))); vs2.arot.x = atan2(RotMatrix_Def.m23, RotMatrix_Def.m33); vs2.arot.y = -asin(RotMatrix_Def.m13); vs2.arot.z = atan2(RotMatrix_Def.m12, RotMatrix_Def.m11); vs2.vrot.x = Height_From_Ground; DefSetStateEx(&vs2); } if (CurrentSterzo < 0) { State_Rotate_Left += (CurrentSpeed * simdt / Wheel_Length) * WheelSpeedAdjust(CurrentSterzo, inside_dist_factor); State_Rotate_Right += (CurrentSpeed * simdt / Wheel_Length) * WheelSpeedAdjust(CurrentSterzo, outside_dist_factor); } else if (CurrentSterzo > 0) { State_Rotate_Left += (CurrentSpeed * simdt / Wheel_Length) * WheelSpeedAdjust(CurrentSterzo, outside_dist_factor); State_Rotate_Right += (CurrentSpeed * simdt / Wheel_Length) * WheelSpeedAdjust(CurrentSterzo, inside_dist_factor); } else { State_Rotate_Left += CurrentSpeed * simdt / Wheel_Length; State_Rotate_Right += CurrentSpeed * simdt / Wheel_Length; } if (State_Rotate_Left > 1) { State_Rotate_Left -= (int)State_Rotate_Left; } else if (State_Rotate_Left < 0) { State_Rotate_Left += 1; } if (State_Rotate_Right > 1) { State_Rotate_Right -= (int)State_Rotate_Right; } else if (State_Rotate_Right < 0) { State_Rotate_Right += 1; } //SetAnimation(anim_rotate_left, State_Rotate_Left); //SetAnimation(anim_rotate_right, State_Rotate_Right); //SetAnimation(anim_steering, (CurrentSterzo + 0.5)); //sprintf(oapiDebugString(), "State_Rotate_Left %lf State_Rotate_Right %lf", State_Rotate_Left, State_Rotate_Right); }

made the modification but here the vehicle still goes sideways. unless the heading is 0 or 180

STATUS Landed Moon
POS -2.1085262 -12.5614811
HEADING 359.81
 
Top