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

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