#4419679 - 05/08/18 09:57 PM
EECH Hover Hold & Alt Hold Mods
|
Joined: Apr 2018
Posts: 300
Javelin
Member
|
Member
Joined: Apr 2018
Posts: 300
Idaho Falls, Idaho USA
|
Hi Guys, I'm currently looking at correcting the problems with Hover Hold and Altitude Hold in the sim.
As you know, Hover Hold works most of the time, as long as your vertical velocity is low. If your velocity is higher, it tends to oscillate up and down more than necessary. Altitude Hold on the other hand is mostly useless, it doesn't work over anything but flat terrain. The goal of flying "Nap of the Earth" wasn't achieved by the original programmers. I think we can fix both subsystems.
I've dug through the code and found the code for both control subsystems. It's located here: \aphavoc\source\gunships\dynamics\common\co_force.c Search in the file for "Auto hover calculations", it's about a third of the way through the file.
After digging through the Hover Hold section, I can see that it attempts to control the helicopter using mostly Proportional Control. The proportional code has two different ranges, one for higher velocity and another for low vertical velocity. Proportional Control is inherently unstable, it overshoots horribly and tends to oscillate and never settle. To correct this they've added in a section after the Proportional Control which adds in a damping component artificially, nudging the system with a slight acceleration opposite to the current velocity. When the vertical velocity is high the two sections are unbalanced, causing the system to oscillate. It will eventually settle, but you shouldn't have to wait so long. It should work better than this. There is also a short code section which levels out the helicopter by countering the Pitch and Roll with the cyclic. These motions are damped by gravity elsewhere in the dynamics system and are inherently stable. My original goal wasn't to fiddle with the Hover Hold, but now that I see how it's implemented I think we can improve it quite a bit.
I haven't looked at Altitude Hold in depth yet, that's my next task. It appears to look ahead of the helo one second and attempts to use the altitude ahead of the helo as part of the calculations. That probably helps some, but since it's most likely all Proportional Control, it doesn't work. I've watched the sim while flying over changing terrain and I've seen it oscillate up and down significantly. On one run I tried to lock Altitude Hold in at 300 ft. The terrain dropped away and the helo dropped all the way down until it slightly touched the ground, then swung upwards to almost 600 ft before coming back downwards again. It almost hit the ground again on round two as well. That much overshoot is what you get with 100% Proportional feedback control. Completely useless. We can fix it.
I've modeled the dynamics roughly in a spreadsheet and implemented a PID control loop (Proportional-Integration-Differentiation loop). I've optimized the coefficients to see what works, so I have a starting point for tuning the control loops. Once I get through digging through the Alt Hold section of the code, I'll look at ways to fix the control loops and see what I can do with it. Thor
|
|
#4419681 - 05/08/18 10:13 PM
Re: EECH Hover Hold & Alt Hold Mods
[Re: Javelin]
|
Joined: Jan 2016
Posts: 486
XIII
Member
|
Member
Joined: Jan 2016
Posts: 486
|
Hello Javelin. I am happy that you are trying to improve something in eech. I do not know if you saw this thread, especially thealx post.they can be helpful for you. Maybe if you finish improving the hover you will look at flight model.It would be great, good luck http://SimHQ.com/forum/ubbthreads.php/topics/4388796/1
|
|
#4419742 - 05/09/18 06:51 AM
Re: EECH Hover Hold & Alt Hold Mods
[Re: Javelin]
|
Joined: Jan 2001
Posts: 1,922
Marc
Member
|
Member
Joined: Jan 2001
Posts: 1,922
Corona, California
|
Thanks a bunch, looking forward seeing the result Thor, that sim deserves it
Marc..
HP-Compaq-8100-Elite-SFF-Intel-Core-i5-660-3-33GHz-8GB-250GB-Windows7, GTX1050 -X45+Rudder Pedals, Playseat Challenge
|
|
#4419814 - 05/09/18 03:55 PM
Re: EECH Hover Hold & Alt Hold Mods
[Re: Javelin]
|
Joined: Apr 2018
Posts: 300
Javelin
Member
|
Member
Joined: Apr 2018
Posts: 300
Idaho Falls, Idaho USA
|
My Background? I'm a Mechanical Engineer who has been writing code for personal projects on and off for 30 years. I've mostly programmed in Delphi but I have done a little bit with C here and there. The Electrical Engineer I work with helps me out out when I need it, he's a very strong C programmer. Most of the stuff I've programmed has been analytical graphical stuff, working at stock market projection, but I also worked on coding a 3D sim up from scratch in OpenGL which included a physics modeled helicopter. I was working up to a Mechwarrior-5 sim, but then Piranha Games took it on so I stopped. It was too much for one person anyway. I should have used someone else's 3D rendering engine instead of coding one up from scratch, but I had fun doing it. I had some really unique features in it, like a continuously variable level of detail module for rendering complex items (no one has ever done that before!) an octagonal skybox, procedural scenery placement, stuff like that. I ran out of steam when Piranha stepped in with Mechwarrior Online.
I went through the Altitude Hold code last night. It expends a lot of energy calculating the helo's position one second in the future, but they made a mistake in the physics. The acceleration term (1/2)at^2 was implemented incorrectly, they forgot to multiply by 1/2. This throws the projection off by a bit, but that wasn't the worst of it. The control is purely proportional like I thought, using a coefficient of 5.0 which is pretty high. This time they didn't damp it at all, the altitude is left to cycle up and down at will. I modeled the controls roughly in a spreadsheet and found a solution with a proportional coefficient of 1.0, and a damping coefficient of 2.5. It takes a lot of damping to keep the helo from overshooting and potentially hitting the ground during fast nap of the earth flying. I also found that throttle control isn't enough, you need to pitch the nose up and down in order to maneuver severely enough to follow the terrain closely. Over 30 to 50 knots I kicked in a bit of Pitch control to help it maneuver. Hopefully EECH will respond similar to my model and it won't take much tweaking to get it working smoothly.
After flying for a bit last night, I suspect the Auto Pilot is directly adjusting the helo's altitude, I don't think they used control inputs to adjust the flight path at all. It moves too cleanly and the control inputs don't quite match a physics based solution. I'll take a look just for my own satisfaction when I get some time. Since it's working just fine I don't intend on changing it, I'm just curious.
Taking on an entire helicopter like the Blackhawk is pretty adventurous! To customize it all the way will take some work, there are bits and pieces of code to rework all over the place. The 3D models shouldn't be too difficult, just a lot of hours to create and texture. There might even be 3D models out there you could use to jump off from. Are you going for clickable cockpits? That's a chore I wouldn't want to take on. I'm not sold on clickable cockpits. It means you can't just jump into a new helicopter type and fly it right away. I haven't got the time to learn a dozen different cockpits, I'd rather have a simpler basic control set that works for all of the helo types so I can fly anything in the sim without a steep learning curve every time. Javelin
|
|
#4419830 - 05/09/18 05:06 PM
Re: EECH Hover Hold & Alt Hold Mods
[Re: Javelin]
|
Joined: Jan 2016
Posts: 486
XIII
Member
|
Member
Joined: Jan 2016
Posts: 486
|
|
|
#4420006 - 05/10/18 11:25 AM
Re: EECH Hover Hold & Alt Hold Mods
[Re: Javelin]
|
Joined: Dec 2010
Posts: 1,883
messyhead
Member
|
Member
Joined: Dec 2010
Posts: 1,883
|
Uhmm... I just took a look into the Blackhawk project and Wow, you guys are really taking it to the next level! It looks like a ton of work you're doing, getting all the instrument displays working.
The flight model is more my thing, I enjoy messing with the physics. I'll take a look under the hood when I get time and see what I can do. The Apache feels sluggish to me, and the Comanche behaves oddly when I'm near a hillside. Something's not quite right.
Yeah, it has been a lot of work, and taken a long time so far. The 3D part I find easy-ish, but the coding is the tough part. Most of the code can be re-used for the instruments. But I'm not at the point of having to try and get some unique instruments working, and it's proving tricky. Sockzien is also doing a model,. based on the newer digital cockpit version of the Blackhawk. But I like the "old fashioned" ones, and based it on the special forces model, as it's the only real world model capable of laser targetting and firing Hellfires. The current in game AI model cheats.
|
|
#4420105 - 05/10/18 07:12 PM
Re: EECH Hover Hold & Alt Hold Mods
[Re: Javelin]
|
Joined: Jan 2016
Posts: 486
XIII
Member
|
Member
Joined: Jan 2016
Posts: 486
|
How do you switch between the two different flight models?
in eech.ini you have flag.
|
|
#4420196 - 05/11/18 11:13 AM
Re: EECH Hover Hold & Alt Hold Mods
[Re: Javelin]
|
Joined: Dec 2012
Posts: 1,382
thealx
Member
|
Member
Joined: Dec 2012
Posts: 1,382
|
I did notice one thing yesterday... I didn't see any code for modeling the rear horizontal and vertical stabilizers anywhere. animate_helicopter_controls ( entity *en )
|
|
#4420274 - 05/11/18 06:49 PM
Re: EECH Hover Hold & Alt Hold Mods
[Re: thealx]
|
Joined: Apr 2018
Posts: 300
Javelin
Member
|
Member
Joined: Apr 2018
Posts: 300
Idaho Falls, Idaho USA
|
animate_helicopter_controls ( entity *en ) That would be the keyframe animation code. I was looking through the physics code, which doesn't seem to have a section for calculating the forces on the airframe from the horizontal and vertical stabilizers. The horizontal stabilizer tends to level the helicopter out at higher speeds, the vertical stabilizer straightens out the helicopter and reduces the need for the tail rotor at higher speeds. It also affects the helo when you try to fly directly sideways, it tends to swing the tail in behind, opposite to the direction of motion. The older Huey Cobra's had an large tail fin, making it quite difficult to fly directly sideways without using a lot of pedal action.
Last edited by Javelin; 05/11/18 07:06 PM.
|
|
|
CD WOFF
by Britisheh. 03/28/24 08:05 PM
|
|
|
|
|
|
|
|
|
|
|