Board index FlightGear Support Interfacing

Generic Protocol Input Control  Topic is solved

Connecting two computers, using generic protocol, connecting with Matlab?

Generic Protocol Input Control  

Postby joef1993 » Fri Jan 06, 2017 1:16 pm

I'm attempting to set the throttle level value through generic protocol input. The contents of the protocol file are:

Code: Select all
<PropertyList>
<generic>
    <input>
      <line_separator>newline</line_separator>
      <var_separator>tab</var_separator>
       
      <chunk>
         <node>/controls/engines/engine/throttle</node>
         <type>double</type>
         <format>%f</format>
      </chunk>
      
   </input>
</generic>
</PropertyList>


I start flightgear with the following:

Code: Select all
fgfs --generic=socket,in,1,127.0.0.1,52867,udp,UDP_Write


And the program I run with Matlab is:

Code: Select all
u = udp('localhost',52867,'localport',5000);
fopen(u);

while(1)
fwrite(u, '0.55');
end


I can see the value 0.55 being output using sockettest, but the value does not change in FG. From reading through threads on similar topics I understand that the physical throttle controller may be overriding the value read into FG, is that the case here? Is there a simple way to check that the protocol is working, perhaps a different variable?
joef1993
 
Posts: 12
Joined: Wed Oct 19, 2016 10:08 am

Re: Generic Protocol Input Control

Postby curt » Fri Jan 06, 2017 2:10 pm

In your protocol xml file you could change the <node> value from /controls/engines/engine/throttle to something like <node>/my-throttle</node>

Then use the property browser to see if that value is being updated. I wouldn't expect FlightGear to override the external throttle setting unless you have a joystick plugged in or some other internal autopilot active and running.

Best regards,

Curt.
Aerospace Engineering and Mechanics
University of Minnesota
curt
Administrator
 
Posts: 1106
Joined: Thu Jan 01, 1970 12:00 am
Location: Minneapolis, MN

Re: Generic Protocol Input Control

Postby joef1993 » Sat Jan 07, 2017 12:45 pm

Hi Curt,

Thanks for your reply. Having changed the node to your example, it now shows up in the property browser so I know the protocol is being loaded correctly. I've then tried to output the values to FG but it does not show, so I'm thinking its something to do with the formatting of the values that I want to send. Using SocketTest, listening to port 52867, the sniffer reads the value of 0.55 repeatedly - I guess FG doesn't like this?

Thanks,
joef1993
 
Posts: 12
Joined: Wed Oct 19, 2016 10:08 am

Re: Generic Protocol Input Control

Postby tauchergreg » Sat Jan 07, 2017 1:30 pm

hi joef1993,

I start flightgear with the following:

Code: Select all
fgfs --generic=socket,in,1,127.0.0.1,52867,udp,UDP_Write

can you try this:

fgfs --generic=socket,in,1,,52867,udp,UDP_Write

regrads,
greg
C160 Transall , Twin Otter DHC6, both with small modification
EF2000
ETMN & EDXN under development
User avatar
tauchergreg
 
Posts: 58
Joined: Tue Jul 03, 2012 7:36 am
Location: near ETMN
Callsign: OFD001 ; BRT0192
Version: 20xx
OS: Linux & W7

Re: Generic Protocol Input Control

Postby joef1993 » Sat Jan 07, 2017 2:16 pm

Hi Greg, thanks for the reply. I've tried that and still no success. SocketTest still picks up the value though. This time however, I can run SocketTest at the same time as FG, whereas before I would get the error message that the address was already in use. I presume this is because FG is now looking at all addresses, rather than just 127.0.0.1?
joef1993
 
Posts: 12
Joined: Wed Oct 19, 2016 10:08 am

Re: Generic Protocol Input Control

Postby tauchergreg » Sat Jan 07, 2017 3:02 pm

hi joef1993,

please put this line as first line in your protocol file

<?xml version="1.0"?>

and try again.

have a look at this post maybe this can help you

viewtopic.php?f=24&t=24099&start=15#p274187


regrads,
greg
C160 Transall , Twin Otter DHC6, both with small modification
EF2000
ETMN & EDXN under development
User avatar
tauchergreg
 
Posts: 58
Joined: Tue Jul 03, 2012 7:36 am
Location: near ETMN
Callsign: OFD001 ; BRT0192
Version: 20xx
OS: Linux & W7

Re: Generic Protocol Input Control

Postby joef1993 » Sun Jan 08, 2017 12:47 am

Hi Greg, thanks for the reply. I missed out the first line when copying the code over so that line is actually in the xml file already. I'll take a look at that thread though, thanks.
joef1993
 
Posts: 12
Joined: Wed Oct 19, 2016 10:08 am

Re: Generic Protocol Input Control

Postby joef1993 » Mon Jan 09, 2017 12:55 am

Ok so I've narrowed this down to being the formatting of the data sent I believe. I'm using the following code:
Code: Select all
u = udp('localhost',52867,'localport',5000);
fopen(u);

while(1)
fprintf(u, 5);
end

A variable that I have set up in the property browser is set at '0' (none) initially, but when I run this code it then changed to '0' (int). Can anyone point me in the right direction of how the data should be formatted?
joef1993
 
Posts: 12
Joined: Wed Oct 19, 2016 10:08 am

Re: Generic Protocol Input Control

Postby joef1993 » Mon Jan 09, 2017 10:59 pm

All solved, used fprintf instead:

Code: Select all
u = udp('localhost',52867,'localport',5000);
fopen(u);

z = 0.99;

fprintf(u, '%f\n', z);

fclose(u);
joef1993
 
Posts: 12
Joined: Wed Oct 19, 2016 10:08 am

Re: Generic Protocol Input Control

Postby akram » Sun Nov 12, 2017 8:44 am

Could you please explaine how it had been solved in more detail.
I suffer from the same problem
akram
 
Posts: 1
Joined: Sun Nov 12, 2017 7:22 am


Return to Interfacing

Who is online

Users browsing this forum: No registered users and 1 guest