Board index FlightGear Development Canvas

Canvas RADAR driver for MapStructure (was: Mirage 2000-5)

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

Canvas RADAR driver for MapStructure (was: Mirage 2000-5)

Postby Hooray » Mon Nov 02, 2015 1:03 pm

5H1N0B1 wrote in Mon Nov 02, 2015 12:08 pm:The way I coded the radar is independant of the displaying because my first goal is missile implementation, but it can be/should be re used in anyway you want.


Yes, I do remember - we we were once talking about coming up with a dedicated/separate "Radar" class that could be reused elsewhere, including not just other aircraft, but also missiles, and possibly ground stations.
I have not yet looked at your code - but in the original m2000-5/Canvas thread, we were talking about the "TFC" (=traffic) layer which is processing AI/MP properties and returns a list (vector) of nodes to the caller (MapStructure layer) - you could basically integrate your radar2.nas code there and it should just work if you don't have any explicit aircraft dependencies/assumptions in it.
To be on the safe side, you may want to hook this up to tanker.nas and/or some other scripted AI object that can be radar-guided.
You could also get in touch with Red Leader who has been working on a dedicated framework for scriptable AI objects.

The instrument/visualization side of this can be greatly simplified if you only use a single MapStructure layer that loads your radar2.nas code to simulate your own radar. Note that, due the way MapStructure is structured, you don't even need to have an actual aircraft to load/use your radar2.nas code - you could just as well test the code in standalone mode using a GUI dialog, which is how this works:

http://wiki.flightgear.org/Canvas_Snipp ... o_a_Canvas
Image

The steps for searching/filtering AI/MP traffic nodes can be seen in $FG_ROOT/Nasal/canvas/map/TFC.lcontroller - there, you can find a searchCmd_default() function which is handling all the search logic - you could basically yank/replace this with your own code.

Alternatively, you can copy the TFC (=traffic) files and use them as a template for your own "RADAR" layer.

If you are interested in focusing on just the radar, I can help you work out the details for using MapStructure - regardless of any particular aircraft/use-case, so that other aircraft developers can reuse your radar code elsewhere, including AI missiles etc.

The whole process is covered at: http://wiki.flightgear.org/Canvas_MapSt ... new_Layers
The radar/atc specifics we discussed a while ago, would still apply: http://wiki.flightgear.org/Canvas_Radar ... ADAR_Layer

If you want me to help with the MapStructure side of this, so that your code can be easily reused elsewhere, I basically need a self-contained Nasal file that has no external dependencies, and which provides a class with a search function - where I only need to pass in:

  • my current position
  • range to search
  • type of traffic/echos (i.e. MP/AI or both)

For starters, that is everything I need - and you should ideally provide a method that returns a vector of objects (traffic echos), with each target inheriting from geo.Coord or having a corresponding member.

As long as this is in place, it would only take a few minutes to reuse your code in a MapStructure layer - so that this can be used for arbitrary purposes - in fact, the way MapStructure works, you can even add a virtual radar instance to existing MP/AI traffic and "see" their radar view, which is how this works (showing virtual NDs for different AI aircraft):

Subject: How to display Airport Chart?
Hooray wrote:Since I wanted to test if the navdisplay.mfd file has been sufficiently decoupled from the main aircraft/use, I put a quick hack together:

Image

compare groundspeed/headings etc in the main aircraft and in the canvas window.
(this is the same backend code, just with a driver hash to use AI traffic as the data source, rather than the main FG aircraft - and it's working NICELY, this is even superior to the built-in map dialog ! obviously AI aircraft doesn't have any cockpit buttons, so I had to use the property browser to set up the ND...)
Image
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Mirage 2000-5

Postby 5H1N0B1 » Mon Nov 02, 2015 1:46 pm

This a little another subject than the 2000 but:
In fact the code already have a vector of object called "target" that heavily use geo.coord.
So all you need is a simplified function :
Code: Select all
Search(myPosition in geo.coord,rangeSearch in nm, typeSearched)


Note that before doing that you will have to create a Radar with all the parameters you want : radar.new(default_range, Hazimuth, Vazimuth, HaveDoppler, isLinkedToCurrentAircraft, writeInpropertyTree, isHeatSearching, isRwr etc...)

Actually this can be done very quick. The parameters I need in the new function are already in new fonction but entered by hand.
Then you will have to understand that your searchFunction will just run 1 update. so you will have to repeat it each time you need the information but you shouldn't refresh it more than 12 time/sec
The target object will have all information you need on each target.

Perhaps an admin/we can move this post and the 2 last post on the canvas topic ?
(This one is dedicated to the mirage)
See you.
5H1N0B1
5H1N0B1
"Each day, with every person you meet, there is something to learn"
5H1N0B1
 
Posts: 222
Joined: Thu Aug 30, 2012 10:36 am
Location: France
Callsign: 5H1N0B1
IRC name: _5H1N0B1
Version: GIT
OS: Ubuntu

Re: Canvas RADAR driver for MapStructure (was: Mirage 2000-5

Postby Hooray » Mon Nov 02, 2015 1:53 pm

that's not a problem - the searchCmd() function will be invoked whenever the display needs to be updated, using either events (e.g. button clicked) or a timer.
So that's the right place to update your radar, too.

Having a dedicated method that returns all objects within range of the radar would still make sense - for better encapsulation, it is not a good idea for the MapStructure layer to directly access any fields without going through public methods (functions) - especially should you change anything internally, so it is better to provide methods in form of a public interface that can be invoked by front-end code like MapStructure.

Maybe you could post sample code on using radar2.nas via the Nasal Console (with just the ufo loaded)?

You can load it using io.load_nasal(path);
with path pointing to your m2000/Nasal/radar2.nas file
and then add your code to create a new instance and call the search function.

I can then take it from there

(you may want to use a text editor for putting this together instead of the console, because the console is a bit awkward for actual coding - but you can use copy/paste once you have a piece of code that works)

http://wiki.flightgear.org/Nasal_Console

See $FG_ROOT/Nasal/io.nas for io.load_nasal(filename);
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Canvas RADAR driver for MapStructure (was: Mirage 2000-5

Postby 5H1N0B1 » Mon Nov 02, 2015 2:09 pm

Maybe you could post sample code on using radar2.nas via the Nasal Console (with just the ufo loaded)?

Ok I'll try, but anyway I still have to make the function.

Having a dedicated method that returns all objects within range of the radar would still make sense - for better encapsulation, it is not a good idea for the MapStructure layer to directly access any fields without going through public methods (functions) - especially should you change anything internally, so it is better to provide methods in form of a public interface that can be invoked by front-end code like MapStructure.

I didn't understand anything. It's probably due to my lack of english speaking. So what does the search function should return ?
5H1N0B1
"Each day, with every person you meet, there is something to learn"
5H1N0B1
 
Posts: 222
Joined: Thu Aug 30, 2012 10:36 am
Location: France
Callsign: 5H1N0B1
IRC name: _5H1N0B1
Version: GIT
OS: Ubuntu

Re: Canvas RADAR driver for MapStructure (was: Mirage 2000-5

Postby Hooray » Mon Nov 02, 2015 2:14 pm

I don't speak much French, so I used google translate for this:

Il est préférable pour le code non - radar de ne pas accéder à des variables internes . Ceci est important afin que le code externe ne dépend pas des choses internes . Par exemple , si vous changez le sens / nom ou le type d'une variable . Telle est la raison pour laquelle il est préférable de fournir une interface publique que vous ne changerez pas . L'interface publique serait 2-3 fonctions qui fournissent ce qui est nécessaire .
De cette façon , peu importe ce que vous changez en interne , aussi longtemps que l'interface publique ne change pas , le code externe ( radar2.nas extérieur ) va continuer à travailler . Ceci est communément appelé «encapsulation» -Parce que vous protégez les détails de mise en œuvre internes et fournir un ensemble de fonctions publiques , afin que le code externe ne jamais avoir à accéder aux structures de données internes .

Concrètement, cela signifie que MapStructure (ou d'autres aéronefs ) auront jamais besoin de savoir quelque chose sur vos internes de code - aussi longtemps que vous avez un peu de fonctions publiques qui fournissent ce qui est nécessaire , les choses continueront de fonctionner correctement .

https://fr.wikipedia.org/wiki/Encapsula ... nn%C3%A9es

La fonction de recherche doit retourner un tableau ( vecteur dans nasale ) des objets qui sont soit héritées de la classe geo.Coord , ou qui ont un champ / méthode correspondante pour acquérir la position ( lat, lon , alt )

De cette façon , la méthode searchCmd () dans MapStructure peut appeler directement votre fonction de recherche - de préférence , il sera également accepter la position de recherche actuelle , ainsi que la gamme à rechercher

Mais la première étape commence fgfs l'aide de l' ovni . Et puis en ouvrant la boîte de dialogue nasale de sorte que vous pouvez exécuter io.load_nasal ( ) afin de charger radar2.nas partir de votre dossier de m2000 ( voir la fenêtre de démarrage pour les erreurs ) .
Une fois que cela fonctionne, vous pouvez créer un objet de Radar et exécuter une recherche simple , par exemple en utilisant debug.dump () pour imprimer les résultats .


(sorry, if that sounds even more ridiculous ...)
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Mirage 2000-5

Postby Johan G » Mon Nov 02, 2015 4:07 pm

5H1N0B1 wrote in Mon Nov 02, 2015 1:46 pm:Note that before doing that you will have to create a Radar with all the parameters you want : radar.new(default_range, Hazimuth, Vazimuth, HaveDoppler, isLinkedToCurrentAircraft, writeInpropertyTree, isHeatSearching, isRwr etc...)

I am probably a bit late, but should not Hazimuth and Vazimuth be Azimuth and Elevation?
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: Canvas RADAR driver for MapStructure (was: Mirage 2000-5

Postby 5H1N0B1 » Mon Nov 02, 2015 4:39 pm

Yeah. perhaps,but anyways this is just an example. and as I said, the example is enough detailled here.
For me Horizontal - azimuth is like a flat cone with a center and to angle each side of this center. (actually an azimuth filed)
And here the same for Vertical - azimuth... the same but vertical. So close to en elevation but not so much
and Also, the center of each one can be parametred...so...
Call it like you prefer :)
5H1N0B1
"Each day, with every person you meet, there is something to learn"
5H1N0B1
 
Posts: 222
Joined: Thu Aug 30, 2012 10:36 am
Location: France
Callsign: 5H1N0B1
IRC name: _5H1N0B1
Version: GIT
OS: Ubuntu

Re: Canvas RADAR driver for MapStructure (was: Mirage 2000-5

Postby Hooray » Tue Nov 03, 2015 5:41 pm

I think Johan misunderstood, i.e. you are basically passing hazimuth/vazimuth as specs for the antenna probably ?
If so, it would actually make sense to eventually move antenna modeling to a different class, just like your radar is not aircraft/missile specific - so that people can model different antennas without having to touch your radar class - i.e. by creating an antenna object and passing that to the constructor when calling radar.new(...)
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Canvas RADAR driver for MapStructure (was: Mirage 2000-5

Postby 5H1N0B1 » Tue Nov 03, 2015 6:04 pm

Yes indeed. It's not yet in the actual code, and antenna spec are defined by hand in the radar code. But I plan to put all the spec defined by the parameters we would write when we call radar.new(parameters)
So then all specification will be out of the radar code. The radar code itself will just be independant. And this is what I'm planning to do next :) (surely before the search fonction you need).
This will be cool.
5H1N0B1
"Each day, with every person you meet, there is something to learn"
5H1N0B1
 
Posts: 222
Joined: Thu Aug 30, 2012 10:36 am
Location: France
Callsign: 5H1N0B1
IRC name: _5H1N0B1
Version: GIT
OS: Ubuntu

Re: Canvas RADAR driver for MapStructure (was: Mirage 2000-5

Postby Hooray » Tue Nov 03, 2015 6:43 pm

The search function should be straightforward to add - as long as the radar class itself does not have any dependencies to other aircraft, i.e. it should be developed so that it works without any particular aircraft, but also so that it can support multiple independent instances (objects) - imagine having 10 different AI missiles each with their own radar object running at the same time.
If done properly, there will be no conflict between any of the "instances" (objects) - i.e. they will all co-exist without any variables/state shared.
The best way to accomplish this is to use a GUI dialog (or the Nasal console) to develop/test the radar class, and create independent instances, e.g. linked to AI missiles (see Red Leader's code on the wiki).

The existing TFC layer can already be used to display such missiles as "traffic":
http://wiki.flightgear.org/Scripted_AI_Objects
Image

Besides, I didn't see any terrain sampling in your code, but vitos mentioned that he's using terrain sampling to hide objects behind mountains ?
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Canvas RADAR driver for MapStructure (was: Mirage 2000-5

Postby wkitty42 » Tue Nov 03, 2015 7:51 pm

Hooray wrote in Tue Nov 03, 2015 5:41 pm:I think Johan misunderstood, i.e. you are basically passing hazimuth/vazimuth as specs for the antenna probably ?
If so, it would actually make sense to eventually move antenna modeling to a different class, just like your radar is not aircraft/missile specific - so that people can model different antennas without having to touch your radar class - i.e. by creating an antenna object and passing that to the constructor when calling radar.new(...)

i can just see the large antennas dish(es) at KXTA (Area 51) pointing and swiveling as craft approach ;)
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9146
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: Canvas RADAR driver for MapStructure (was: Mirage 2000-5

Postby Hooray » Tue Nov 03, 2015 7:53 pm

the radar class would also be a natural fit for any aircraft wanting to do virtual ATC, e.g. AWACS-style aircraft - but also people wanting to fly missions trying to circumvent the ground stations
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Canvas RADAR driver for MapStructure (was: Mirage 2000-5

Postby 5H1N0B1 » Tue Nov 03, 2015 8:09 pm

I didn't see vitos code, but to my understanding, there is only one way to achieve this and it's indeed sampling.

The fonction I made here is named "isNotBehindTerrain". It create a line between radar-target. on this line a point with coord is calculated and compared to its geo.elevation.
It's relatively time consuming so it MUST be the very last test done, in order to eliminate all previous case.

Anyways, the idea is indeed to make multiple radar running in parallel. I still have a tiny work to do before it can be used :
1-complete a proper "new"
2-make your search function.
3-define method in order to organize the type of detector we have.(I mean what test have to be done, if this is a radar, or heat seeking, or RWR, eye seeking etc...)

But this will become cool.
5H1N0B1
5H1N0B1
"Each day, with every person you meet, there is something to learn"
5H1N0B1
 
Posts: 222
Joined: Thu Aug 30, 2012 10:36 am
Location: France
Callsign: 5H1N0B1
IRC name: _5H1N0B1
Version: GIT
OS: Ubuntu

Re: Canvas RADAR driver for MapStructure (was: Mirage 2000-5

Postby Hooray » Tue Nov 03, 2015 8:16 pm

yeah, it will probably involve geodinfo() calls - like you say, you would sample terrain along a line - analogous to how wave lift is computed, and analogous to how omega95's VSD code works

Such a radar class could then even be used for creating a simple scripted ATC controller for a GCA (ground-controlled approach)
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Canvas RADAR driver for MapStructure (was: Mirage 2000-5

Postby 5H1N0B1 » Wed Jan 13, 2016 8:34 am

I'm working on it.
Actually, this is very possible to make the function "Update" return a target object, itself containing geo.coord.
If my memory is good, the idea is to call the update function with a geo.coord, but in fact I'll nedd a little more :
something more like that :
Code: Select all
var myRadar = radar.new (everything) <-Still in progress

and then
Code: Select all
myRadar.update(myAircraftGeoCoord, myAircraftHeading, myAircraftPitch);

I do not know where to add the type of detected object (aircraft, carrier, multiplayer,missile etc...) but I thnik the better is in the "new".

I'll let you know.
5H1N0B1
"Each day, with every person you meet, there is something to learn"
5H1N0B1
 
Posts: 222
Joined: Thu Aug 30, 2012 10:36 am
Location: France
Callsign: 5H1N0B1
IRC name: _5H1N0B1
Version: GIT
OS: Ubuntu

Next

Return to Canvas

Who is online

Users browsing this forum: No registered users and 3 guests