Sign in to follow this  
Guest Steven007

Can gauges control directly the ailerons, elevator, rudder?

Recommended Posts

Hi,I'm busy with writing an autopilot for an autonomous unmanned aerial vehicle. For the moment I'll be happy if I can write the software for it :-). The design is so that the software gets it information from an altimeter, compass, pitot tube and GPS to determine the position. The software controls the throttle, ailerons, elevators and if necessary the rudder.Now it would be great if I could test this in FS2002!I searched the FS2002 Panels & Gauges SDK for variables that I could change to control the ailerons, elevator, throttle, but I didn't find anything usefull (okay, some autopilot functions, but those are what I need to test!). I intend to use the gauge as follows:I have a random plane with panel. The gauge should be just a button. If the button is pushed, then the gauge directs the plane following a defined flightplan which is defined in the gauge. When the button is pushed again, the gauge should stop controlling the plane.Questions: 1) How does the gauge now when its button is pressed?2) Access to altitude, heading, IAS, GPS position is done through the token variables listed in the SDK. But how do I control the ailerons, elevators, rudder and throttle?Thanks,Steven10 km north of EBBR or 17 km SE of EBBR

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

>Hi,>>I'm busy with writing an autopilot for an autonomous unmanned>aerial vehicle. For the moment I'll be happy if I can write>the software for it :-). The design is so that the software>gets it information from an altimeter, compass, pitot tube and>GPS to determine the position. The software controls the>throttle, ailerons, elevators and if necessary the rudder.>Now it would be great if I could test this in FS2002!>I searched the FS2002 Panels & Gauges SDK for variables that I>could change to control the ailerons, elevator, throttle, but>I didn't find anything usefull (okay, some autopilot>functions, but those are what I need to test!). >Steven These are some XML Key Events available:KEY_ELEVATOR_DOWNKEY_ELEVATOR_UPKEY_AILERON_LEFTKEY_AILERON_CENTERKEY_AILERON_RIGHTKEY_RUDDER_LEFTKEY_RUDDER_CENTERKEY_RUDDER_RIGHT I'm not sure what are available in C Tokens, but most are similar.Ron

Share this post


Link to post
Share on other sites

I use the ...AXIS_..._SET events for finer control. AXIS because there was a an old anomaly with reversed directions in FS2000/FS2002, but I think that's fixed now.KEY_AXIS_RUDDER_SETKEY_AXIS_AILERONS_SETKEY_AXIS_ELEVATOR_SETKEY_THROTTLE1_SETthese are C events, the XML as usually without KEY_.Arne Bartels

Share this post


Link to post
Share on other sites

While reading sd2gau14's documents, I encountered what I needed. Reading the token variabels should be done as following:MODULE_VAR name_you_chose = {};In the code one writes he should use name_you_chose.(Probably I have forgotten some lines, there was a lot to read ;-), and I only read it once)In order to control the outputs, one should use the following command:trigger_key_event( , value between 0.000 and 1.000 );Thanks,Steven10 km North of EBBR,Struggling through SDKs and tutorials

Share this post


Link to post
Share on other sites

the trigger_key_event takes arguments as integers, no floats. Often it's simple 0 or 1 (or is ignored at all), but for all control surfaces and many other key_events it is between -16384 and 16384.Arne Bartels

Share this post


Link to post
Share on other sites

the trigger_key_event takes arguments as integers, no floats. Often it's simple 0 or 1 (or is ignored at all), but for all control surfaces and many other key_events it is between -16384 and 16384.Arne BartelsP.S. the button pressure event is relaized with the mouse rectangles, "simple" events with MOUSE_CHILD_EVENT (key events without effect of argument) or MOUSE_CHILD_FUNCT for more complex stuff.

Share this post


Link to post
Share on other sites

So for my autopilot, I'd rather use MOUSE_CHILD_FUNCT instead of MOUSE_CHILD_EVENT. The function referred to in the MOUSE_CHILD_FUNCT line would be then something likevoid FSAPI myFunction(void){//my code comes here}?Perhaps I'll read the SDKs more than once again ;-)Ohwell, first I'll convert my Java code of the autopilot to C/C++, and then I'll try to convert it to a gauge.Greetings,Steven17 km SE of EBBR

Share this post


Link to post
Share on other sites

WARNING !!If you use trigger_key_event to control the ailerons, rudder and elevator, you may have the problem I have explained in the post: "Using trigger_key_event (fix control acceleration)".It says that when you use trigger_key_event frequently in your code (that is, several times per second), it folls the acceleration system that is supposed to accelerate the value changes of the autopilot for example. Every change will be done by increments of 10 instead of 1. If I am not clear, please read my post...Unfortunately, if you develop a new autopilot, I guess you will have to call trigger_key_event several times per second, and you may encounter this problem.If you have another solution, please let me knowGood luck !!Eric

Share this post


Link to post
Share on other sites

>If you use trigger_key_event to control the ailerons, rudder>and elevator, you may have the problem I have explained in the>post: "Using trigger_key_event (fix control acceleration)".>It says that when you use trigger_key_event frequently in your>code (that is, several times per second), it folls the>acceleration system that is supposed to accelerate the value>changes of the autopilot for example. Every change will be>done by increments of 10 instead of 1. If I am not clear,>please read my post...It can be avoided by using SET events instead INC/DEC events

Share this post


Link to post
Share on other sites

That's right, I already use the SET events and not the INC/DEC (I use HEADING_BUG_SET). But I have to update it frequently so that:- the aircraft follows its route as accurately as possible,- if the aircraft is far from its route, it will come back on it in a smooth way.For this reason, I have to use trigger_key_event(HEADING_BUG_SET, value) very frequently.Eric

Share this post


Link to post
Share on other sites

>For this reason, I have to use>trigger_key_event(HEADING_BUG_SET, value) very frequently.>So which controls accelerated?

Share this post


Link to post
Share on other sites

There is no connection between controls. I mean that I use HEADING_BUG_SET to update the target heading, but when I change the target autopilot altitude, it increases 1000 by 1000 instead of 100 by 100, as if it was accelerated.In addition, all the key sequences (such as E 1 or E 2 to select an engine) are inoperative in this context. This is normal, because the generation of key events through the trigger_key_event function call destroy the key sequence.How can we avoid this? I don't know...Eric

Share this post


Link to post
Share on other sites

Fortunately for me, I don't plan to use any inbuilt autopilot functions :-). I just need to use the aileron, rudder and elevator functions. I'd love to show some code, but it's still in Java (school's back :-S). Eric, isn't it possible to generate events that select an engine? I thought there were some events in the SDK to select an engine, maybe you can use these?Greetings,Steven

Share this post


Link to post
Share on other sites

Eric, after some thinking...If you have problems with controlling your autopilot, maybe you should write your own autopilot code, and control the ailerons,... directly, instead of using the Microsoft functions of setting the heading in their autopilot code (I assume you are doing it that way). I think, in my current version, I'll lose altitude during turns and vice versa. Greetings,Steven17 km SE of EBBR

Share this post


Link to post
Share on other sites

>There is no connection between controls. I mean that I use>HEADING_BUG_SET to update the target heading, but when I>change the target autopilot altitude, it increases 1000 by>1000 instead of 100 by 100, as if it was accelerated.Use also SET for autopilot target altitude.Use SET for everithing. Forgot about INC/DEC at all.

Share this post


Link to post
Share on other sites

You're right, I use the MS autopilot functions.I know you're right, the better solution is to develop my own autopilot that controls ailerons, rudder and elevators. But I will not do that, it is a much too big amount of work...Eric

Share this post


Link to post
Share on other sites

I'm sure you can do pretty much all you want with the default FS A/P. It is a matter of how you handle and use it as a ressource. As an example, the STEC55X in the Meridian is entirely based on the FS A/P support functions and engine (execpt the CWS mode which hold the bank and current VS, which in addition to the FS A/P SDK trigger_key events also uses the aileron_set for the bank control). To do this, the FS A/P is treated as an engine managed by a finite state 55X A/P code. In doing so, the 55X "forces" the FS A/P to the modes it has to be engaged in, 18 times a second, and in the end, you have a 55X which works with the 55X logic, not the default BK based A/P logic.Having said that, the new Meridian 2004 and 530XP v2.0 for FS2004 can control the A/P NAV mode directly (to make the aircraft fly to a particular track when the GPS is set for example, and the A/P is armed in NAV mode) in overiding the FS internal variable which holds the current "A/P in NAV mode track to fly to" This is not in the SDK, and like for the AI Traffic, requires to find out what functions to call in the FS modules, and what data to write in these modules. I won't document this here, but I wanted to write this to at least let you know it is feasible since it looks like this is what you are looking for for your FMC. So any attempt to find out won't be in vain. You only need one tool:http://home.t-online.de/home/Ollydbg/Hope this helps!

Share this post


Link to post
Share on other sites

I did this and it works also. The only drawback is that there is no acceleration any more... Acceleration is painful when faulty, but it helps when it works fine.Nothing is perfect...Thanks to everyone for your help !!!!Eric

Share this post


Link to post
Share on other sites

>I did this and it works also. The only drawback is that there>is no acceleration any more... Acceleration is painful when>faulty, but it helps when it works fine.>Nothing is perfect...>You can do it.For example one hotzone for 100 feets target altitude increment, other for 1000 increment. Or left mouse button for 100, right for 1000

Share this post


Link to post
Share on other sites

Once again, you're 100% right. I have already thought about using the left mouse button for standard increments of 100 and the right one for increments of 1000. But I've had so many problem reports on my Airbus panels, from people who couldn't use this left/right mouse button feature, that I now hesitate to use it again.Having the same area clickable with the left or right mouse button has already worked perfect on my machine, but it seems that it is painful for some users.I'll think about it...Thanks !!Eric

Share this post


Link to post
Share on other sites

The left/right mouse clicks work just right on my pc too. No problems at all. I really like your Airbus panels :-)Greetz,Steven

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this