diff --git a/buzz_scripts/include/barrier.bzz b/buzz_scripts/include/barrier.bzz index 8c55806..dbf5978 100644 --- a/buzz_scripts/include/barrier.bzz +++ b/buzz_scripts/include/barrier.bzz @@ -8,6 +8,7 @@ # Constants # BARRIER_VSTIG = 11 +BARRIER_TIMEOUT = 200 # in steps # # Sets a barrier @@ -29,14 +30,12 @@ function barrier_ready() { # # Executes the barrier # -BARRIER_TIMEOUT = 200 timeW=0 function barrier_wait(threshold, transf, resumef, bdt) { - #barrier.get(id) barrier.put(id, 1) UAVSTATE = "BARRIERWAIT" - if(bdt!=-1) - neighbors.broadcast("cmd", brd) + + barrier.get(id) if(barrier.size() >= threshold) { # getlowest() transf() @@ -44,14 +43,16 @@ function barrier_wait(threshold, transf, resumef, bdt) { barrier = nil resumef() timeW=0 - } + } else if(bdt!=-1) + neighbors.broadcast("cmd", bdt) + timeW = timeW+1 } -# get the lowest id of the fleet, but requires too much bandwidth +# get the lowest id of the fleet, but requires too much bandwidth... function getlowest(){ - Lid = 20; - u=20 + Lid = 15; + u=15 while(u>=0){ tab = barrier.get(u) if(tab!=nil){ diff --git a/buzz_scripts/include/uavstates.bzz b/buzz_scripts/include/uavstates.bzz index 180c6cc..8b5a9dd 100644 --- a/buzz_scripts/include/uavstates.bzz +++ b/buzz_scripts/include/uavstates.bzz @@ -28,7 +28,7 @@ function takeoff() { statef=takeoff if( flight.status == 2 and position.altitude >= TARGET_ALTITUDE-TARGET_ALTITUDE/20.0) { - barrier_set(ROBOTS,action,land,22) + barrier_set(ROBOTS,action,land,-1) barrier_ready() } else { diff --git a/buzz_scripts/include/vstigenv.bzz b/buzz_scripts/include/vstigenv.bzz index c983fcc..7fd8e42 100644 --- a/buzz_scripts/include/vstigenv.bzz +++ b/buzz_scripts/include/vstigenv.bzz @@ -1,16 +1,29 @@ -STATUS_VSTIG = 10 -GROUND_VSTIG = 11 +######################################## +# +# FLEET V.STIGMERGY-RELATED FUNCTIONS +# +######################################## +# +# Constants +# +STATUS_VSTIG = 20 +GROUND_VSTIG = 21 +HIGHEST_ROBOTID = 14 WAIT4STEP = 10 -v_status = {} -v_ground = {} + +# +# Init var +# +var v_status = {} +var v_ground = {} b_updating = 0 +counter=WAIT4STEP function uav_initstig() { v_status = stigmergy.create(STATUS_VSTIG) v_ground = stigmergy.create(GROUND_VSTIG) } -counter=WAIT4STEP function uav_updatestig() { # TODO: Push values on update only. if(counter<=0) { @@ -78,7 +91,7 @@ function stattab_print() { if(v_status.size()>0) { if(b_updating==0) { u=0 - while(u<8){ + while(u0) { if(b_updating==0) { u=0 - while(u<8){ + while(u