PC Drone Delivery Network
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
WHAT IS IT?
This is a model designed to compare different Drone Protocols (DP) for a network of delivery drones. These DP's can then be compared to conventional trucking means using the sister model. Future in sky (in aeris) networks could use this to select the apropriate DP for their service.
HOW IT WORKS
There are 3 major actors in this model: Houses, Warehouses and Drones. Houses request deliveries, which originate at a warehouse and are fulfilled by a drone. The drone is red when delivering to a house, and black when returning. Each button has the drones try a different DP.
If two drones are on the same patch at the same altitude, they crash and fail to make a delivery.
HOW TO USE IT
Basics: Hit Setup, then click a button and observe the DP.
Advanced: After setup, the user can select between a variety of DP's. These are grouped into Autonomous DP's and Non-Autonomous DP's that simulate a comuniation to an Air Traffic Managment System.
The user has the option to select a limit to the number of drones a warehouse can use to make deliveries. If drones crash, then they are unusable and no longer available.
Autonomous DP DESCRIPTIONS: Go - This is the simplest of all DP's. In this protocol, drones decide on one of 5 altitudes for flight and fly at this altitude. Drones fly directly to delivery location and right back to the warehouse
Simple Drone Routing - Drones fly directly to an from the delivery destinations. Their altitudes are based on the direction they are flying, ie. east at 200 ft, West 300 ft.
North South Routing - All drones fly directly to destination. After delivery they fly either North or South towards the latitude of the warehouse. At this point they turn and face it and orderly enter the warehouse. Drones still select altitude based off heading.
SWAS Routing - All drones fly directly to their destination and return by flying to either the direct N,S,E,W of the warehouse, then turning and enterting the landing pattern. Drones select altitude based on heading.
stoch SWAS - Similar to SWAS routing, however a little stochasity has been added to the altitude. These drone still select altitude based on heading, however when they are generated they select either a 20 40 or 60 ft displacement of their height. This adds a level of randomness to the height they fly at, while still avoiding head on collisions by precluding two oppositely oriented drones from flying at the right height.
NON-Autonomous DP:
ATMS SWAS: Identical to the SWAS method, however these drones check the patches ahead of them and to the right (where other drones are always coming from) for other drones. If they find them they do not move forward. This emulates an ATMS where the drones query the ATMS for nearby drones locations.
Hardcore ATMS SWAS: Same as above but checks patches ahead at a greater distance. This would require more transmission bandwidth in an in aeris network than the previous.
KINK: An ultra hardcore ATMS SWAS method. In this, so many patches ahead are checked that drones often get kinked up and become unable to move.
Stoch ATMS SWAS: A SWAS ATMS method with stochasity added to the altitude.
THINGS TO NOTICE
Often, collisions occur while retuning to the warehouse. As large numbers of drones converge on an area, this is inevitable. Autonomous DP's in this model often manage the flight altitude of the drones based on the direction they are moving.
THINGS TO TRY
The best way to see the general patterns of the DP's is to turn the house-frequency wayyy up and watch thousands of the little guys fly the pattern.
EXTENDING THE MODEL
we need to add flight times for drones performance metrics DP master control ReTestable
NETLOGO FEATURES
(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)
RELATED MODELS
(models in the NetLogo Models Library and elsewhere which are of related interest) 1.https://www.researchgate.net/publication/215499161ADiscreteStochasticProcessforCoverageAnalysisofAutonomousUAV_Networks 2.http://www.ida.liu.se/labs/rtslab/publications/2006/kuiperICWMC2006.pdf 3.http://ccl.northwestern.edu/netlogo/models/community/DroneNET
- http://groups.csail.mit.edu/robotics-center/public_papers/Barry15a.pdf
- NetLogo itself: Wilensky, U. 1999. NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern University. Evanston, IL. <- Big shoutout to Uri, thanks for all the work you put into this program.
CREDITS AND REFERENCES
John H Stewart did all of it - appdev@tacmap.org
Comments and Questions
;;;This is a model for PC DP optimization ;C. Emeka, J. Stewart, G. Craig ;;create "classes" ; breed [drones drone] breed [rtDrones rtDrone] ;deprecated breed [trucks truck] breed [houses house] breed [warehouses warehouse] ;;class attributes drones-own[ destination load-status takeoff-status balogna ;;im using this for a super balogna reason,, don't hate its adequately named i cant get the if else to work lol. collision altitude secondary dsp ] ;truck stuff trucks-own[ destination load-status takeoff-status balogna secondary ] ;returing drones so the ATMS can distinguis between returning and delivering drones ;I really wish NetLogo had a get turtles at patches at patch method, then this wouldnt be neccessary rtDrones-own[ destination load-status takeoff-status balogna ;;im using this for a super balogna reason,, don't hate chinny its adequately named i cant get the if else to work lol. collision altitude secondary ] warehouses-own[ tarmac ] ;;create global variables globals[ ;routes is a list of all networked drones routes routes LastPos ;; postion for collision detection collision-count ; collision count - includes at least 2 drones alt ; should be a local variable but i don't know how to make those colCount ; should be local, but don't know how to mske those chance; global for random? WTF ARE THERE NO LOCAL VARIABLES in the POS???,, let chance random xx doesnt work baseY ; this is the y cord of the base/warehouse baseX ; this is the x cord of the base/warehouse totes ; totes is totes the number of drones drone-Count ; needed for the number of drones begining deliveries ATMS; locX; used for kink ATMS locY; used for kink ATMS ;maxDrones ; slider can be used to set the max number of drones curDrones ; number of drones in the air currently flightTime ; total flight time flightTotes ; cause locals dont work,, groan ;;truck globals truck-Count truckTotes curTrucks ] ;setup method called on setup button pressed to setup clear-all set flightTime 0; set curDrones 0 setup-patches set-default-shape houses "house" set-default-shape trucks "truck" set totes 1 ;; CREATE-ORDERED-distributes the houses evenly create-houses number-of-houses [ setxy random-xcor random-ycor fd max-pxcor ] set-default-shape warehouses "bug" create-warehouses 1 [setxy random-xcor random-ycor fd max-pxcor ] ask warehouses[ set baseY ycor set baseX xcor ] ;create-drones number-of-drones [ ; setxy random-xcor random-ycor ; set color red ; set destination one-of houses ; set load-status "en-route" ; set takeoff-status false ; face destination ; set collision false ; ;give an arbitrary height for now ; set chance random 5 ; set altitude chance * 100 ; set secondary false ;] set ATMS true; reset-ticks end ;;reset drones on the warehouse to reset-drones set totes 1 ; I'm making it one to avoid the divide by zero error. *****************************ALL FINAL CALCS MUST ACCOUNT FOR TGIS or not cause set collision-count 0 set flightTime 0 ask drones[die] set curDrones 0 reset-ticks end ;;sets up patches, called from setup method to setup-patches ask patches[set pcolor green] end ;this method uses the delivery frequency to randomly have houses make a request form the warehouse. ;and by that I mean that the percent is used to caluclalate a number of houses going to request and then a corespondinng number of drones are made ;make-Drones creates the requested number of drones with a random house as a destination ;also checks if the maxDroneOnIsOne is one to see if there is a limit to the number of drones ;the no limit is most useful to see the general movement pattern of a DP to request-delivery set drone-Count 0 ask houses[ set chance random 10000 if-else maxDroneOnIsOne = 1[ if houseFrequency > chance and curDrones < maxDrones[ set drone-Count drone-Count + 1 ;set curDrones curDrones + 1 ]] ;else maxDroneOnIsOne is not one, so there is no drone limit [ if houseFrequency > chance [ set drone-Count drone-Count + 1 ;set curDrones curDrones + 1 ]] ] set totes drone-Count + totes ; set the total number of drones make-Drones end to make-Drones set curDrones curDrones + drone-Count ; this sets the current num create-drones drone-Count [ set xcor baseX set ycor baseY set color red ; set destination one-of houses set load-status "en-route" set takeoff-status false ; face destination set collision false ; ;give an arbitrary height for now set chance random 5 set altitude chance * 100 set secondary false set destination one-of houses face destination set dsp random 3 set dsp dsp * 10 ] end to countFlight ;each drone flying will add a flight time ;beware, flight time will be better for a network where lots of drones crash, as they wil stop flying. This statistic is deceptive set flightTotes 0 ask drones[ set flightTotes flightTotes + 1 ] set flightTime flightTotes + flightTime end ;;Below is the most basic Drone Protocol strategy, using randomly assigned flight altitudes. There are 5 options. 100, 200, 300, 400 and 500 ft. GPS altitude accuracy is within this slot system ;;When a new altitude is randomly selected at takeoff from warehouse, over time all aircraft will ALWAYS crash (except if there is an odd number) to go countFlight request-delivery ask drones[ ;; if at target, either return home or go to new house if distance destination = 0 [ set takeoff-status true set balogna true ;if you are at your destination and returning, the drone is done delvering,, die and decrease count if load-status = "return" [ die set curDrones curDrones - 1 ; ] if load-status = "en-route" and balogna = true [ set color black set destination one-of warehouses face destination set load-status "return" fd 2 ] ] ;; move towards target. once the distance is more than 1, ;; use move-to to land exactly on the target. if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ] ;;check for collisons btwn other drones if the drones have not landed ;set global LastPos to current patch and collision to false. If this patch set collision false set LastPos patch-here set alt altitude set colCount 0 if count drones-here > 1[ ask drones [ if patch-here = LastPos and alt = altitude[ set colCount colCount + 1] if colCount > 1[ set collision true ] ] ] if collision = true[ set collision-count collision-count + 1 ask drones[ if patch-here = LastPos and altitude = alt[ die ]]] ] tick end ;This is a simple routing strategy for drones. Drones traveling "East", or 0 to 180 degrees, will fly at 200 ft, drones with routes above 180 degrees wil be at 400 ;The main issue here is that drones aproaching the warehouse crash as they converge. A routing system to bring them to the warehouse in a convieient fashion is needed to goSimpleRouting countFlight request-delivery ask drones[ ;set altitude based off heading, if going mostly east cruise at 200, if west cruise 400 if-else heading <= 180[set altitude 200][set altitude 400] ;; if at target, either return home or go to new house if distance destination = 0 [ set takeoff-status true set balogna true if load-status = "return" [ die set curDrones curDrones - 1 ; ] if load-status = "en-route" and balogna = true [ set color black set destination one-of warehouses face destination set load-status "return" fd 2 ] ] ;; move towards target. once the distance is more than 1, ;; use move-to to land exactly on the target. if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ] ;;check for collisons btwn other drones if the drones have not landed ;set global LastPos to current patch and collision to false. If this patch set collision false set LastPos patch-here set alt altitude set colCount 0 if count drones-here > 1[ ask drones [ if patch-here = LastPos and alt = altitude[ set colCount colCount + 1] if colCount > 1[ set collision true ] ] ] if collision = true[ set collision-count collision-count + 1 ask drones[ if patch-here = LastPos and altitude = alt[ die ]]] ] tick end ;;this is an autonomous routing DP where drones deliver to their destination in a direct fashion, flying at 200 if going east and 400 at west ;when they are returning to the warehouse however, they can only fly directly North or South until they reach the latitude (x axis) of the warehouse. North at 100, South 300 ;When they reach the latitude of their home base they will turn to it, returning to the east/west altitude to goNSReturnRouting countFlight request-delivery ask drones[ ;if delivering, set altitude based off heading, if going mostly east cruise at 200, if west cruise 400 if load-status = "en-route"[ if-else heading <= 180[set altitude 200][set altitude 400]] ;; if at target, either return home or go to new house if distance destination = 0 [ set takeoff-status true set balogna true if load-status = "return" [ die set curDrones curDrones - 1 ; ] if load-status = "en-route" and balogna = true [ set color black set destination one-of warehouses face destination ;;this sets a north direction if the drone needs to go north if heading < 90 or heading > 270[set heading 0 set altitude 100] ;;this sets a southern direction if the drone needs to go south if heading > 90 and heading < 270[set heading 180 set altitude 300] set load-status "return" fd 2 ] ] ;; move towards target directly if en-route n if the distance is more than 1, ;; use move-to to land exactly on the target. if-else load-status = "en-route"[ if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ] ] ;else this is return, check if on latutude of warehouse n turn to face it if u are [ if-else abs (ycor - baseY) < 1 [face destination if-else heading <= 180[set altitude 200][set altitude 400] if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ]] ;else return to N/S [ if heading < 90 or heading > 270[set heading 0] ;;this sets a southern direction if the drone needs to go south if heading > 90 and heading < 270[set heading 180] if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ] ] ] ;;check for collisons btwn other drones if the drones have not landed ;set global LastPos to current patch and collision to false. If this patch set collision false set LastPos patch-here set alt altitude set colCount 0 if count drones-here > 1[ ask drones [ if patch-here = LastPos and alt = altitude[ set colCount colCount + 1] if colCount > 1[ set collision true ] ] ] if collision = true[ set collision-count collision-count + 1 ask drones[ if patch-here = LastPos and altitude = alt[ die ]]] ] tick end ;;this is a method that uses 4 quadrants to route drones ;yessssss ;it happens to form a symbol that is very triggering to a great deal of people to goNSEWReturnRouting countFlight request-delivery ask drones[ ;if delivering, set altitude based off heading, if going mostly east cruise at 200, if west cruise 400 if load-status = "en-route"[ if-else heading <= 180[set altitude 200][set altitude 400] ] ;; if at target, either return home or go to new house if distance destination = 0 [ set takeoff-status true set balogna true if load-status = "return" [ set curDrones curDrones - 1 ; die ] if load-status = "en-route" and balogna = true [ set color black set destination one-of warehouses face destination ;this would be a great time for an if else else else statement but netlogo is totally weak sometimes ;;if heading is less than 90, then it is in lower left queadrant,, go east than north if heading < 90 ; [set heading 90 set altitude 200 set secondary true] ;;if drone is in top left quadrant w/ heading greater than 90 but less than 180, go south than east if heading >= 90 and heading < 180 and secondary = false[set heading 180 set altitude 300 set secondary true] ;;if in the top righ quarant go west than south if heading >= 180 and heading < 270 and secondary = false[ set heading 270 set altitude 400 set secondary true ] ;if in bottom right, go north than west if heading >= 270 and secondary = false[ set heading 0 set altitude 100 set secondary true ] set load-status "return" ; fd 2 ] ] ;; move towards target directly if en-route n if the distance is more than 1, ;; use move-to to land exactly on the target. if-else load-status = "en-route"[ if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ] ] ;else this is return, check if on latutude/longitude of warehouse n turn to face it [ ;;if u are in vicinity of warehouse turn to if-else abs (ycor - baseY) < .5 or abs (xcor - baseX) < .5 [face destination ;;now the drone is in the second leg ;;its heading should be set perfectly so set altitude accordingly if abs (heading - 90) < 5 [set altitude 200] if abs (heading - 180) < 5[set altitude 300] if abs (heading - 270) < 5 [set altitude 400] if heading < 5 or abs (heading - 360) < 5[set altitude 100] if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ]] ;else return to N/S NOT NEEDED>>???? [ ;if heading < 90 or heading > 270[set heading 0] ;;this sets a southern direction if the drone needs to go south ;if heading > 90 and heading < 270[set heading 180] if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ] ] ] ;;check for collisons btwn other drones if the drones have not landed ;set global LastPos to current patch and collision to false. If this patch set collision false set LastPos patch-here set alt altitude set colCount 0 if count drones-here > 1[ ask drones [ if patch-here = LastPos and alt = altitude[ set colCount colCount + 1] if colCount > 1[ set collision true ] ] ] if collision = true[ set collision-count collision-count + 1 ask drones[ if patch-here = LastPos and altitude = alt[ die ]]] ] tick end to goNSReturnRoutingDP countFlight request-delivery ask drones[ ;if delivering, set altitude based off heading, if going mostly east cruise at 200, if west cruise 400 if load-status = "en-route"[ if-else heading <= 180[set altitude 200][set altitude 400]] ;; if at target, either return home or go to new house if distance destination = 0 [ set takeoff-status true set balogna true if load-status = "return" [ set color red set load-status "en-route" set destination one-of houses face destination set balogna false fd 2 ] if load-status = "en-route" and balogna = true [ set color black set destination one-of warehouses face destination ;;this sets a north direction if the drone needs to go north if heading < 90 or heading > 270[set heading 0 set altitude 100] ;;this sets a southern direction if the drone needs to go south if heading > 90 and heading < 270[set heading 180 set altitude 300] set load-status "return" fd 2 ] ] ;; move towards target directly if en-route n if the distance is more than 1, ;; use move-to to land exactly on the target. if-else load-status = "en-route"[ if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ] ] ;else this is return, check if on latutude of warehouse n turn to face it [ if-else abs (ycor - baseY) < 1 [face destination if-else heading <= 180[set altitude 200][set altitude 400] if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ]] ;else return to N/S [ if heading < 90 or heading > 270[set heading 0] ;;this sets a southern direction if the drone needs to go south if heading > 90 and heading < 270[set heading 180] if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ] ] ] ;;check for collisons btwn other drones if the drones have not landed ;set global LastPos to current patch and collision to false. If this patch set collision false set LastPos patch-here set alt altitude set colCount 0 if count drones-here > 1[ ask drones [ if patch-here = LastPos and alt = altitude[ set colCount colCount + 1] if colCount > 1[ set collision true ] ] ] if collision = true[ set collision-count collision-count + 1 ask drones[ if patch-here = LastPos and altitude = alt[ die ]]] ] tick end ;;different from other NSEW routing due to the ATMS, which prevents collisions when enetering the landing pattern to ATMSgoNSEWReturnRouting countFlight request-delivery ask drones[ ;if delivering, set altitude based off heading, if going mostly east cruise at 200, if west cruise 400 if load-status = "en-route"[ if-else heading <= 180[set altitude 200][set altitude 400] ] ;; if at target, either return home or go to new house if distance destination = 0 [ set takeoff-status true set balogna true if load-status = "return" [ set curDrones curDrones - 1 ; die ] if load-status = "en-route" and balogna = true [ set color black set destination one-of warehouses face destination ;this would be a great time for an if else else else statement but netlogo is totally weak sometimes ;;if heading is less than 90, then it is in lower left queadrant,, go east than north if heading < 90 ; [set heading 90 set altitude 200 set secondary true] ;;if drone is in top left quadrant w/ heading greater than 90 but less than 180, go south than east if heading >= 90 and heading < 180 and secondary = false[set heading 180 set altitude 300 set secondary true] ;;if in the top righ quarant go west than south if heading >= 180 and heading < 270 and secondary = false[ set heading 270 set altitude 400 set secondary true ] ;if in bottom right, go north than west if heading >= 270 and secondary = false[ set heading 0 set altitude 100 set secondary true ] set load-status "return" ; fd 2 ] ] ;; move towards target directly if en-route n if the distance is more than 1, ;; use move-to to land exactly on the target. if-else load-status = "en-route"[ if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ] ] ;else this is return, check if on latutude/longitude of warehouse n turn to face it [ ;;if u are in vicinity of warehouse turn to if-else abs (ycor - baseY) < .5 or abs (xcor - baseX) < .5 [face destination ;;now the drone is in the second leg ;;its heading should be set perfectly so set altitude accordingly if abs (heading - 90) < 5 [set altitude 200] if abs (heading - 180) < 5[set altitude 300] if abs (heading - 270) < 5 [set altitude 400] if heading < 5 or abs (heading - 360) < 5[set altitude 100] if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ]] ;else return to N/S NOT NEEDED>>???? [ ;if heading < 90 or heading > 270[set heading 0] ;;this sets a southern direction if the drone needs to go south ;if heading > 90 and heading < 270[set heading 180] if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ set ATMS true; ;;only move forward if no drone is on the landing route ask patch-ahead 1 [if count drones-here > 0[set ATMS false] ] if ATMS = true [fd 1] ] ] ] ;;check for collisons btwn other drones if the drones have not landed ;set global LastPos to current patch and collision to false. If this patch set collision false set LastPos patch-here set alt altitude set colCount 0 if count drones-here > 1[ ask drones [ if patch-here = LastPos and alt = altitude[ set colCount colCount + 1] if colCount > 1[ set collision true ] ] ] if collision = true[ set collision-count collision-count + 1 ask drones[ if patch-here = LastPos and altitude = alt[ die ]]] ] tick end ;this method gets a lil kinky tbh fam ;breeding and dying drones and returning drones all over the place ;which is neccessary for the returning drones to distinguish ;;different from other NSEW routing due to the ATMS, which prevents collisions when enetering the landing pattern to MultiATMSgoNSEWReturnRouting request-delivery ask drones[ ;if delivering, set altitude based off heading, if going mostly east cruise at 200, if west cruise 400 if load-status = "en-route"[ if-else heading <= 180[set altitude 200][set altitude 400] ] ;; if at target, either return home or go to new house if distance destination = 0 [ set takeoff-status true set balogna true if load-status = "return" [ set curDrones curDrones - 1 ; die ] if load-status = "en-route" and balogna = true [ set color black set destination one-of warehouses face destination ;this would be a great time for an if else else else statement but netlogo is totally weak sometimes ;;if heading is less than 90, then it is in lower left queadrant,, go east than north if heading < 90 ; [set heading 90 set altitude 200 set secondary true] ;;if drone is in top left quadrant w/ heading greater than 90 but less than 180, go south than east if heading >= 90 and heading < 180 and secondary = false[set heading 180 set altitude 300 set secondary true] ;;if in the top righ quarant go west than south if heading >= 180 and heading < 270 and secondary = false[ set heading 270 set altitude 400 set secondary true ] ;if in bottom right, go north than west if heading >= 270 and secondary = false[ set heading 0 set altitude 100 set secondary true ] set load-status "return" ; fd 2 ] ] ;; move towards target directly if en-route n if the distance is more than 1, ;; use move-to to land exactly on the target. if-else load-status = "en-route"[ if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ] ] ;else this is return, check if on latutude/longitude of warehouse n turn to face it [ ;;if u are in vicinity of warehouse turn to if-else abs (ycor - baseY) < .5 or abs (xcor - baseX) < .5 [face destination ;;now the drone is in the second leg ;;its heading should be set perfectly so set altitude accordingly if abs (heading - 90) < 5 [set altitude 200] if abs (heading - 180) < 5[set altitude 300] if abs (heading - 270) < 5 [set altitude 400] if heading < 5 or abs (heading - 360) < 5[set altitude 100] if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ]] ;else return to N/S NOT NEEDED>>???? [ ;if heading < 90 or heading > 270[set heading 0] ;;this sets a southern direction if the drone needs to go south ;if heading > 90 and heading < 270[set heading 180] if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ set ATMS true; ;;only move forward if no drone is on the landing route directly in front ;this method is more hardocre in avoidance and checks up to 3 patches ahead ask patch-ahead 1 [if count drones-here > 0[set ATMS false] ] ask patch-ahead 2 [if count drones-here > 0[set ATMS false] ] ask patch-ahead 3 [if count drones-here > 0[set ATMS false] ] ;check to the left and right, for drones and avoid if they are there ;doing a vairety of precautions to be safe ask patch-left-and-ahead 45 1[if count drones-here > 0 [set ATMS false]] ask patch-left-and-ahead 45 2[if count drones-here > 0 [set ATMS false]] ask patch-left-and-ahead 15 1[if count drones-here > 0 [set ATMS false]] ask patch-left-and-ahead 15 2[if count drones-here > 0 [set ATMS false]] ask patch-left-and-ahead 60 1[if count drones-here > 0 [set ATMS false]] ask patch-left-and-ahead 60 2[if count drones-here > 0 [set ATMS false]] ask patch-right-and-ahead 45 1[if count drones-here > 0 [set ATMS false]] ask patch-right-and-ahead 45 2[if count drones-here > 0 [set ATMS false]] ask patch-right-and-ahead 15 1[if count drones-here > 0 [set ATMS false]] ask patch-right-and-ahead 15 2[if count drones-here > 0 [set ATMS false]] ask patch-right-and-ahead 60 1[if count drones-here > 0 [set ATMS false]] ask patch-right-and-ahead 60 2[if count drones-here > 0 [set ATMS false]] if ATMS = true [fd 1] ] ] ] ;;check for collisons btwn other drones if the drones have not landed ;set global LastPos to current patch and collision to false. If this patch set collision false set LastPos patch-here set alt altitude set colCount 0 if count drones-here > 1[ ask drones [ if patch-here = LastPos and alt = altitude[ set colCount colCount + 1] if colCount > 1[ set collision true ] ] ] if collision = true[ set collision-count collision-count + 1 ask drones[ if patch-here = LastPos and altitude = alt[ die ]]] ] tick end ;this method gets a lil kinky tbh fam ;breeding and dying drones and returning drones all over the place ;which is neccessary for the returning drones to distinguish ;;different from other NSEW routing due to the ATMS, which prevents collisions when enetering the landing pattern ;the reason i think it is ok to use two types of turtles is that the differing flight heights should preclude a situation where counting the turtles in front and checking for collisions to kinkyATMSgoNSEWReturnRouting countFlight request-delivery ask drones[ ;if delivering, set altitude based off heading, if going mostly east cruise at 200, if west cruise 400 if load-status = "en-route"[ if-else heading <= 180[set altitude 200][set altitude 400] ] ;; if at target, either return home or go to new house if distance destination = 0 [ set takeoff-status true set balogna true if load-status = "return" [ set curDrones curDrones - 1 ; die ] if load-status = "en-route" and balogna = true [ ;;heres where its gettin kinky set locX xcor set locY ycor ;since we cant create turtles from inside the turtle context, call a method that will do it now that we have locX, locY set color black set destination one-of warehouses face destination ;this would be a great time for an if else else else statement but netlogo is totally weak sometimes ;;if heading is less than 90, then it is in lower left queadrant,, go east than north if heading < 90 ; [set heading 90 set altitude 200 set secondary true] ;;if drone is in top left quadrant w/ heading greater than 90 but less than 180, go south than east if heading >= 90 and heading < 180 and secondary = false[set heading 180 set altitude 300 set secondary true] ;;if in the top righ quarant go west than south if heading >= 180 and heading < 270 and secondary = false[ set heading 270 set altitude 400 set secondary true ] ;if in bottom right, go north than west if heading >= 270 and secondary = false[ set heading 0 set altitude 100 set secondary true ] set load-status "return" ; fd 2 ] ] ;; move towards target directly if en-route n if the distance is more than 1, ;; use move-to to land exactly on the target. if-else load-status = "en-route"[ if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ] ] ;else this is return, check if on latutude/longitude of warehouse n turn to face it [ ;;if u are in vicinity of warehouse turn to if-else abs (ycor - baseY) < .5 or abs (xcor - baseX) < .5 [face destination ;;now the drone is in the second leg ;;its heading should be set perfectly so set altitude accordingly if abs (heading - 90) < 5 [set altitude 200] if abs (heading - 180) < 5[set altitude 300] if abs (heading - 270) < 5 [set altitude 400] if heading < 5 or abs (heading - 360) < 5[set altitude 100] if distance destination < 1 [ ;added 4 comp die set curDrones curDrones - 1 move-to destination ] if distance destination >= 1 [ fd 1 ]] ;else return to N/S NOT NEEDED>>???? [ ;if heading < 90 or heading > 270[set heading 0] ;;this sets a southern direction if the drone needs to go south ;if heading > 90 and heading < 270[set heading 180] if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ let curDrone self set ATMS true; ;;only move forward if no drone is on the landing route directly in front ;this method is more hardocre in avoidance and checks up to 3 patches ahead ask patch-ahead 1 [if count drones-here > 0[set ATMS false] ] ask patch-ahead 2 [if count drones-here > 0[set ATMS false] ] ask patch-ahead 3 [if count drones-here > 0[set ATMS false] ] ;check to the left and right, for drones and avoid if they are there ;doing a vairety of precautions to be safe ; ask patch-left-and-ahead 45 1[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ;ask patch-left-and-ahead 45 2[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ;ask patch-left-and-ahead 15 1[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ; ask patch-left-and-ahead 15 2[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ;ask patch-left-and-ahead 60 1[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ;ask patch-left-and-ahead 60 2[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 45 1[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 45 2[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 15 1[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 15 2[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 60 1[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 60 2[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 75 1[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 75 2[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 90 1[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 90 2[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 90 3[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] if ATMS = true [fd 1] ] ] ] ;;check for collisons btwn other drones if the drones have not landed ;set global LastPos to current patch and collision to false. If this patch set collision false set LastPos patch-here set alt altitude set colCount 0 if count drones-here > 1[ ask drones [ if patch-here = LastPos and alt = altitude[ set colCount colCount + 1] if colCount > 1[ set collision true ] ] ] if collision = true[ set collision-count collision-count + 1 ask drones[ if patch-here = LastPos and altitude = alt[ die ]]] ] tick end ;;helper method to avoid context for the kinky DP to makeRtDrone create-rtDrones 1 [ set xcor locX set ycor locY set color black ; set destination one-of houses set load-status "return" set takeoff-status false ; face destination set collision false ; ;give an arbitrary height for now set chance random 5 set altitude chance * 100 set secondary false set destination one-of warehouses face destination ] end ;;this is a method that uses 4 quadrants to route drones ;yessssss ;it happens to form a symbol that is very triggering to a great deal of people to StochgoNSEWReturnRouting countFlight request-delivery ask drones[ ;if delivering, set altitude based off heading, if going mostly east cruise at 200, if west cruise 400 if load-status = "en-route"[ if-else heading <= 180[set altitude 200 + dsp][set altitude 400 + dsp] ] ;; if at target, either return home or go to new house if distance destination = 0 [ set takeoff-status true set balogna true if load-status = "return" [ set curDrones curDrones - 1 ; die ] if load-status = "en-route" and balogna = true [ set color black set destination one-of warehouses face destination ;this would be a great time for an if else else else statement but netlogo is totally weak sometimes ;;if heading is less than 90, then it is in lower left queadrant,, go east than north if heading < 90 ; [set heading 90 set altitude 200 + dsp set secondary true] ;;if drone is in top left quadrant w/ heading greater than 90 but less than 180, go south than east if heading >= 90 and heading < 180 and secondary = false[set heading 180 set altitude 300 + dsp set secondary true] ;;if in the top righ quarant go west than south if heading >= 180 and heading < 270 and secondary = false[ set heading 270 set altitude 400 + dsp set secondary true ] ;if in bottom right, go north than west if heading >= 270 and secondary = false[ set heading 0 set altitude 100 + dsp set secondary true ] set load-status "return" ; fd 2 ] ] ;; move towards target directly if en-route n if the distance is more than 1, ;; use move-to to land exactly on the target. if-else load-status = "en-route"[ if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ] ] ;else this is return, check if on latutude/longitude of warehouse n turn to face it [ ;;if u are in vicinity of warehouse turn to if-else abs (ycor - baseY) < .5 or abs (xcor - baseX) < .5 [face destination ;;now the drone is in the second leg ;;its heading should be set perfectly so set altitude accordingly if abs (heading - 90) < 5 [set altitude 200 + dsp] if abs (heading - 180) < 5[set altitude 300 + dsp] if abs (heading - 270) < 5 [set altitude 400 + dsp] if heading < 5 or abs (heading - 360) < 5[set altitude 100 + dsp] if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ]] ;else return to N/S NOT NEEDED>>???? [ ;if heading < 90 or heading > 270[set heading 0] ;;this sets a southern direction if the drone needs to go south ;if heading > 90 and heading < 270[set heading 180] if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ] ] ] ;;check for collisons btwn other drones if the drones have not landed ;set global LastPos to current patch and collision to false. If this patch set collision false set LastPos patch-here set alt altitude set colCount 0 if count drones-here > 1[ ask drones [ if patch-here = LastPos and alt = altitude[ set colCount colCount + 1] if colCount > 1[ set collision true ] ] ] if collision = true[ set collision-count collision-count + 1 ask drones[ if patch-here = LastPos and altitude = alt[ die ]]] ] tick end ;;different from other NSEW routing due to the ATMS, which prevents collisions when enetering the landing pattern to stochATMSgoNSEWReturnRouting countFlight request-delivery ask drones[ ;if delivering, set altitude based off heading, if going mostly east cruise at 200, if west cruise 400 if load-status = "en-route"[ if-else heading <= 180[set altitude 200 + dsp][set altitude 400 + dsp] ] ;; if at target, either return home or go to new house if distance destination = 0 [ set takeoff-status true set balogna true if load-status = "return" [ set curDrones curDrones - 1 ; die ] if load-status = "en-route" and balogna = true [ set color black set destination one-of warehouses face destination ;this would be a great time for an if else else else statement but netlogo is totally weak sometimes ;;if heading is less than 90, then it is in lower left queadrant,, go east than north if heading < 90 ; [set heading 90 set altitude 200 + dsp set secondary true] ;;if drone is in top left quadrant w/ heading greater than 90 but less than 180, go south than east if heading >= 90 and heading < 180 and secondary = false[set heading 180 set altitude 300 + dsp set secondary true] ;;if in the top righ quarant go west than south if heading >= 180 and heading < 270 and secondary = false[ set heading 270 set altitude 400 + dsp set secondary true ] ;if in bottom right, go north than west if heading >= 270 and secondary = false[ set heading 0 set altitude 100 + dsp set secondary true ] set load-status "return" ; fd 2 ] ] ;; move towards target directly if en-route n if the distance is more than 1, ;; use move-to to land exactly on the target. if-else load-status = "en-route"[ if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ] ] ;else this is return, check if on latutude/longitude of warehouse n turn to face it [ ;;if u are in vicinity of warehouse turn to if-else abs (ycor - baseY) < .5 or abs (xcor - baseX) < .5 [face destination ;;now the drone is in the second leg ;;its heading should be set perfectly so set altitude accordingly if abs (heading - 90) < 5 [set altitude 200] if abs (heading - 180) < 5[set altitude 300] if abs (heading - 270) < 5 [set altitude 400] if heading < 5 or abs (heading - 360) < 5[set altitude 100 + dsp] if distance destination < 1 [ move-to destination ] if distance destination >= 1 [ fd 1 ]] ;else return to N/S NOT NEEDED>>???? [ ;if heading < 90 or heading > 270[set heading 0] ;;this sets a southern direction if the drone needs to go south ;if heading > 90 and heading < 270[set heading 180] if distance destination < 1 [ if load-status = "return"[ set curDrones curDrones - 1 ; die] move-to destination ] if distance destination >= 1 [ let curDrone self set ATMS true; ;;only move forward if no drone is on the landing route ask patch-ahead 1 [if count drones-here > 0[set ATMS false] ] ask patch-ahead 2 [if count drones-here > 0[set ATMS false] ] ask patch-right-and-ahead 45 1[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 45 2[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 15 1[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 15 2[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 60 1[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 60 2[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 75 1[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 75 2[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 90 1[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 90 2[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] ask patch-right-and-ahead 90 3[if count drones-here with [altitude = [altitude] of curDrone] > 0 [set ATMS false]] if ATMS = true [fd 1] ] ] ] ;;check for collisons btwn other drones if the drones have not landed ;set global LastPos to current patch and collision to false. If this patch set collision false set LastPos patch-here set alt altitude set colCount 0 if count drones-here > 1[ ask drones [ if patch-here = LastPos and alt = altitude[ set colCount colCount + 1] if colCount > 1[ set collision true ] ] ] if collision = true[ set collision-count collision-count + 1 ask drones[ if patch-here = LastPos and altitude = alt[ die ]]] ] tick end ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;This is the truck Stuff my partner was supposed to make ; it is near completion, but commented out because I did not finish it and it makes everything more complicated ;I have made an analog to a truck delivery method ;to goTruck ; request-truck-delivery ;ask trucks[ ; ;; if at target, either return home or go to new house ;if distance destination = 0 ; [ set takeoff-status true ; ; set balogna true ;;if you are at your destination and returning, the drone is done delvering,, die and decrease count ;if load-status = "return" ;[ ;die ;set curDrones curDrones - 1 ; ; ] ; if load-status = "en-route" and balogna = true ; [ ; set color black ; set destination one-of warehouses ; face destination ; set load-status "return" ; fd 2 ; ; ] ;] ;; move towards target. once the distance is more than 1, ;; use move-to to land exactly on the target. ; if distance destination < 1 ; [ ; ; move-to destination ; ; ; ] ;if distance destination >= 1 ; [ ; face destination ; ; fd 1 ; ] ; ; ; ;] ;tick ;end ;to request-truck-delivery ;-Count 0 ; ask houses[ ; set chance random 10000 ; if-else maxTruckIsOne = 1[ ; if houseFrequency > chance and curTrucks < maxTrucks[ ; set truck-Count truck-Count + 1 ; set curTrucks curTrucks + 1 ; ]] ;else maxDroneOnIsOne is not one, so there is no drone limit ; [ ; if houseFrequency > chance [ ; set truck-Count truck-Count + 1 ; set curTrucks curTrucks + 1 ; ]] ; ] ;set TruckTotes truck-Count + Trucktotes ; set the total number of Trucks ; make-Trucks ;end ;to make-Trucks ; set curTrucks curTrucks + truck-Count ; this sets the current num ;create-trucks truck-Count [ ; set xcor baseX ; set ycor baseY ; set color red ; set destination one-of houses ; set load-status "en-route" ; set takeoff-status false ; face destination ;set collision false ; ;give an arbitrary height for now ;set chance random 5 ;set altitude chance * 100 ;set secondary false ; set destination one-of houses ; face destination ;s;et dsp random 3 ;set dsp dsp * 10 ; ] ;end;
There is only one version of this model, created over 9 years ago by John Stewart.
Attached files
No files
This model does not have any ancestors.
This model does not have any descendants.