C
C#ā€¢10mo ago
Kuno

How to implement map of an aerodrome and aircraft traffic on that ?

Hi, I'm working on a microservice that is called "Ground control", which responsible for ground traffic of aircrafts on the aerodrome. Presumably, it will use the http or RabbitMQ, but I've no way of knowing about how to do some things from business logic: 1) how to implement a map with all taxiways, runways and aprons (which data structures is appropriate, which frameworks or libraries can be useful ?) 2) how to implement aircraft moving from A to B (from A taxiway to another taxiway B, for example. Which algorithm is better for that ?) 3) how to define the communication contract between my microservice and GUI ? (should GUI has an interface of my commands or there is another solutions ?) I added the aerodrome scheme for better understanding
No description
69 Replies
Pobiega
Pobiegaā€¢10mo ago
Is this homework or a work project?
Kuno
KunoOPā€¢10mo ago
homework
Pobiega
Pobiegaā€¢10mo ago
Well, you won't be drawing anything in the microservice imho, rather just send data to the gui And to be frank, this is a fairly advanced homework. Should you really be asking for outside help on something like this? that said, consider the following: * Do you need exact position information or is "at stands", "on runway" etc good enough? * Do you OWN the data, or do you get updates from somewhere else?
Kuno
KunoOPā€¢10mo ago
* I guess "at concrete taxiway" or "at concrete apron" is enough * I only use arrival/departure data from a database, but rest data under my control
Pobiega
Pobiegaā€¢10mo ago
okay. is it realtime or does something else control the "speed" of the simulation?
Kuno
KunoOPā€¢10mo ago
realtime Just my teacher doesn't want to help and I don't fully understand how to perform this task. Should I ask for it in other forums ?
HtmlCompiler
HtmlCompilerā€¢10mo ago
were you given some data, some interfaces, or you have to do everything?
Kuno
KunoOPā€¢10mo ago
No, I'm responsible for all
Pobiega
Pobiegaā€¢10mo ago
Are you responsible for making the GUI too?
Kuno
KunoOPā€¢10mo ago
No, I have to place aircrafts and control their traffic by commands But the whole aerodrome have to be created inside my service
Pobiega
Pobiegaā€¢10mo ago
There are endless posibilities of modelling this, and which ones are suitable all depends on the requirements Is the layout of the aerodrome fixed?
Kuno
KunoOPā€¢10mo ago
Yes it is
Pobiega
Pobiegaā€¢10mo ago
So the simplest possible idea I can think of then would just be to have a List<Aircraft>, where each Aircraft has a .Position property that keeps track of where they are. Its extremely simplified, but if you dont need granular positions, that does the trick An alternative is to model each area of the aerodrome as an object, and each area keeps track of the aircraft in them do you have to simulate takeoffs and landings? ie that they take time and colissions are real etc?
Kuno
KunoOPā€¢10mo ago
To be honest I have to do, but for landing and takeoffs is responsible a local control not the ground one. And collisions must to be, of course
Pobiega
Pobiegaā€¢10mo ago
then it sounds like "at apron" is not good enough
Kuno
KunoOPā€¢10mo ago
yep
Pobiega
Pobiegaā€¢10mo ago
you need to actually keep track of their actual position, heading etc This is very much not trivial stuff tbh. I'm thinking a directional graph datastructure to represent the pathways between the different areas, and you can use dijkstra to find the ways to move around it you'll still need to figure out how to deal with collisions etc you'll likely need semaphores or something to keep track of what areas are currently in use like an aircraft trying to move from the stands to the ramp will need the apron AND the ramp to be clear before it can leave the taxiway outside the stands and once it enters the apron, no aircraft may leave the ramp, because they would block
Kuno
KunoOPā€¢10mo ago
And likely I will have something like Graph<AerodromePart> ?
Pobiega
Pobiegaā€¢10mo ago
if you go that way, sure but it'll be fairly complicated. What areas cause blockages in other areas etc must be carefully analyzed and set up
Kuno
KunoOPā€¢10mo ago
Okay, thank you for help
Pobiega
Pobiegaā€¢10mo ago
the graph would primarily be used to pathfind. potentially, you could keep track of what areas are "in use" etc too, so pathfinding fails when they are blocked as an alternative, you could set up pre-calculated paths
Kuno
KunoOPā€¢10mo ago
I got it. May be i will add some rules for entering in every taxiway or apron
Pobiega
Pobiegaā€¢10mo ago
yeah, you kinda must
bighugemassive3
bighugemassive3ā€¢10mo ago
Is the GUI just like a preview of the data on a server? Like the position of planes or something like that?
Kuno
KunoOPā€¢10mo ago
Yes it is At least I don't know how to do it in another way
bighugemassive3
bighugemassive3ā€¢10mo ago
The server can send packets to the GUIs that are listening, and those packets could contain position data for all the planes, and then the GUI can be responsible for "animating" the actual plane positions This is what games do, where the server sends position updates and the client presents them. The client tries to predict where a thing might be in the future, which can be done simply by calculating the position change between the last and current packet to calculate the velocity The faster the updates are, the more accurate the representation would be obviously Kinda random example but in GTA5 online, if you open the mini map and look at someone whose flying a jet far away from you, you can see the jet teleporting every second because from a long distance, position updates are slow, but the game still tries to predict and interpolate its movement
Kuno
KunoOPā€¢10mo ago
I don't clearly understand which part of aerodrome I have to send for updating
bighugemassive3
bighugemassive3ā€¢10mo ago
I assume just plane position and direction/rotation data right?
Kuno
KunoOPā€¢10mo ago
Probably yes for basic functional, it can be enough And my program does have a several threads, right ?
Pobiega
Pobiegaā€¢10mo ago
yeah, since the aerodrome layout is static you prob wont send it at all. At a later stage you might include semaphore information in your "payload" to the GUI I'd lean towards using async/await over threads. its a nicer abstraction. maybe use websockets to push data from the server to the client
Kuno
KunoOPā€¢10mo ago
could you explain how semaphore has to work, in several words ? I'm just unfamiliar with them
Pobiega
Pobiegaā€¢10mo ago
you know stoplights? those are semaphores. so the idea would be that when an aircraft crosses a certain point, the lights "turn red" so no other aircraft tries to enter essentially, each time an aircraft tries to transition from one area to another, it checks if the area is open if it is, it moves in. if its not, it waits and retries later
Kuno
KunoOPā€¢10mo ago
I was going to do that by state of each aerodrome item
Pobiega
Pobiegaā€¢10mo ago
sure, that works sortof depends on the type of item a taxiway can have multiple planes on it so you'll need to break it up into several sections
Kuno
KunoOPā€¢10mo ago
Are there other ways to implement a semaphore ?
Pobiega
Pobiegaā€¢10mo ago
depends entirely on your overall architecture just having a bool on each part might be enough
Kuno
KunoOPā€¢10mo ago
To sum up: - Aerodrome is represented as a directional graph - For moving I use the Dijkstra algorithm - Each aerodrome item has a 'state' used to control the traffic - Every time (guess 30 times in a second) I will send all planes' positions to the gui Am I right ?
Pobiega
Pobiegaā€¢10mo ago
30 times per second seems outrageous I was thinking maybe 1-2 times per second tops and for PATHFINDING you use dijkstra, the actual moving will need to be handled in a different way
Kuno
KunoOPā€¢10mo ago
actual moving is have to be implemented in program, or it is better to delegate that to the gui?
Pobiega
Pobiegaā€¢10mo ago
program or well, maybe thats not strictly needed if you use enough segments since only one plane can be in each segment anyways
Kuno
KunoOPā€¢10mo ago
Just I guess I can send to the gui like "Move Plane#1 to this taxiway" and gui will do the animation during specific amount of seconds
Pobiega
Pobiegaā€¢10mo ago
yeah, you'll just send a list of all aircraft and their position. Shouldnt need more then that tbh idk if you've seen actual ground control instruments, but they are not animated šŸ˜› the plane icons dont move smoothly, they jump
Kuno
KunoOPā€¢10mo ago
I didn't know šŸ™‚
Pobiega
Pobiegaā€¢10mo ago
doing smooth animations will be a lot of work for very little gain just let the planes teleport small distances imho, its more than fine šŸ™‚
Kuno
KunoOPā€¢10mo ago
Okay, thank you guys for your help! It was helpful!
leowest
leowestā€¢10mo ago
I mean shouldn't u be able to have more planes on hangars and docks? @Kuno out of curiosity do they also give u an image without all the numbers and planes on it? if so animating it might be easier then u think in WPF I would imagine the taxiway would be limited per segment but hangars and docks by the amount the can fit
Kuno
KunoOPā€¢10mo ago
Regarding planes hangars... i would just teleport them inside and then make them dissapeared I pull number and may be model from database
leowest
leowestā€¢10mo ago
I mean there is also ramp, apron, stands but u get the idea they give u an image per section? im referring to the visual u have because that could be used on the GUI if u had it without the details on it and planes
Kuno
KunoOPā€¢10mo ago
image of plane ?
leowest
leowestā€¢10mo ago
of the airport like u have a the top of your thread but without anything on it
Kuno
KunoOPā€¢10mo ago
I use this image just for understanding, idk. You are talking about using this image (without any signs) as a visual map in WPF ?
bighugemassive3
bighugemassive3ā€¢10mo ago
You could use images instead of drawing using vector art
leowest
leowestā€¢10mo ago
imagine u remove all the numbers, planes and names from the image, u get an empty airport then you can add objects based on the information u receive so you're populating the stuff based on the information your API sends in
Kuno
KunoOPā€¢10mo ago
and add (x,y) relatively to the objects on map to visualize?
bighugemassive3
bighugemassive3ā€¢10mo ago
You would have packets that represents when a plane arrives and departs, and when you gets sent an arrival packet you would also expect the server to start sending you position and rotation data, and you can use that to change the positions and rotatinos of the GUI components But if the server sends position data as geo coordinates then you'd have to convert that to regular x,y coords
Kuno
KunoOPā€¢10mo ago
Just the visualization is not my task I would try to do that for testing
bighugemassive3
bighugemassive3ā€¢10mo ago
Your software actually instructs the planes/pilots where to go?
Kuno
KunoOPā€¢10mo ago
Yes
bighugemassive3
bighugemassive3ā€¢10mo ago
Ahh i thought you were just writing a thing to visualise the data not actually create the data per se So you just receive when a plane arrives/departs? And then you control where that plane goes when it arrives?
Kuno
KunoOPā€¢10mo ago
Yep Ground and Local Control in the airport
bighugemassive3
bighugemassive3ā€¢10mo ago
When you receive that plane arrived packet, that's where you need to do something with the plane? In that case, I don't know exactly what goes on in real airports but i'd assume they go right to that place where passengers can exit near the terminals maybe
Kuno
KunoOPā€¢10mo ago
Local Control is responsible for landing and takeoffs Ground Control for providing a safe path to the apron
bighugemassive3
bighugemassive3ā€¢10mo ago
If there's a scheduled location that each plane goes to after, then you'd just send an instruction to that plane to say "go <here>". Otherwise, you'd look through all available aircraft stands maybe? then find a free one according to the database When a plane takes up that place, you'd update the database accordingly
Kuno
KunoOPā€¢10mo ago
I would rather use List<T> for stands, instead a database
bighugemassive3
bighugemassive3ā€¢10mo ago
public class Airport {
public Runway Runway;
public List<Stand> Stands;
}

public class Stand {
// the plane using this stand currently
public Aircraft Aircraft;
}

public class Runway {
public List<Aircraft> PlanesOnRunway;
}
public class Airport {
public Runway Runway;
public List<Stand> Stands;
}

public class Stand {
// the plane using this stand currently
public Aircraft Aircraft;
}

public class Runway {
public List<Aircraft> PlanesOnRunway;
}
Is this kinda what you're trying to make?
public class Airport {
public Runway Runway;
public List<Stand> Stands;

public void OnAircraftArrived(Aircraft plane) {
if (plane.TargetStandId == -1) {
foreach (Stand stand in this.Stands) {
if (stand.Aircraft == null) {
stand.Aircraft = plane
plane.SendTargetStandInstruction(stand.Id);
break;
}
}
}
}
}
public class Airport {
public Runway Runway;
public List<Stand> Stands;

public void OnAircraftArrived(Aircraft plane) {
if (plane.TargetStandId == -1) {
foreach (Stand stand in this.Stands) {
if (stand.Aircraft == null) {
stand.Aircraft = plane
plane.SendTargetStandInstruction(stand.Id);
break;
}
}
}
}
}
Just some make up code, not sure if that's what you're trying to actually do though Then if you want to visualise the airport with something like unity, then tbh the best bet would be to contain the entire airport and all planes as their own objects (states), and then you'd create the respective unity engine game objects that listen for when data is updated (e.g. the plane position changes, raise an event to let you update the unity object position and so on)
leowest
leowestā€¢10mo ago
yep just saying that depending on how smoothly u want it to be its not too hard of a task, that is on WPF
leowest
leowestā€¢10mo ago
with storyboard u can do some really cool thngs on WPF
HtmlCompiler
HtmlCompilerā€¢10mo ago
this project remembers me of a sample program that uses orleans https://learn.microsoft.com/en-us/samples/dotnet/samples/orleans-gps-device-tracker-sample/ maybe it can be of use
Orleans GPS device tracker sample - Code Samples
An Orleans sample demonstrating how to use GPS device tracker.
Kuno
KunoOPā€¢10mo ago
Okay, it will speak with person, who is responsible for that, cause Iā€™m not familiar with Unity Interesting, I would give it a try for testing
Want results from more Discord servers?
Add your server