This commit is contained in:
vivek-shankar 2017-08-30 21:03:33 -04:00
commit e7add61c97
4 changed files with 31 additions and 25 deletions

View File

@ -8,6 +8,7 @@
# Constants # Constants
# #
BARRIER_VSTIG = 11 BARRIER_VSTIG = 11
BARRIER_TIMEOUT = 200 # in steps
# #
# Sets a barrier # Sets a barrier
@ -29,14 +30,12 @@ function barrier_ready() {
# #
# Executes the barrier # Executes the barrier
# #
BARRIER_TIMEOUT = 200
timeW=0 timeW=0
function barrier_wait(threshold, transf, resumef, bdt) { function barrier_wait(threshold, transf, resumef, bdt) {
#barrier.get(id)
barrier.put(id, 1) barrier.put(id, 1)
UAVSTATE = "BARRIERWAIT" UAVSTATE = "BARRIERWAIT"
if(bdt!=-1)
neighbors.broadcast("cmd", brd) barrier.get(id)
if(barrier.size() >= threshold) { if(barrier.size() >= threshold) {
# getlowest() # getlowest()
transf() transf()
@ -44,14 +43,16 @@ function barrier_wait(threshold, transf, resumef, bdt) {
barrier = nil barrier = nil
resumef() resumef()
timeW=0 timeW=0
} } else if(bdt!=-1)
neighbors.broadcast("cmd", bdt)
timeW = timeW+1 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(){ function getlowest(){
Lid = 20; Lid = 15;
u=20 u=15
while(u>=0){ while(u>=0){
tab = barrier.get(u) tab = barrier.get(u)
if(tab!=nil){ if(tab!=nil){

View File

@ -28,7 +28,7 @@ function takeoff() {
statef=takeoff statef=takeoff
if( flight.status == 2 and position.altitude >= TARGET_ALTITUDE-TARGET_ALTITUDE/20.0) { 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() barrier_ready()
} }
else { else {

View File

@ -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 WAIT4STEP = 10
v_status = {}
v_ground = {} #
# Init var
#
var v_status = {}
var v_ground = {}
b_updating = 0 b_updating = 0
counter=WAIT4STEP
function uav_initstig() { function uav_initstig() {
v_status = stigmergy.create(STATUS_VSTIG) v_status = stigmergy.create(STATUS_VSTIG)
v_ground = stigmergy.create(GROUND_VSTIG) v_ground = stigmergy.create(GROUND_VSTIG)
} }
counter=WAIT4STEP
function uav_updatestig() { function uav_updatestig() {
# TODO: Push values on update only. # TODO: Push values on update only.
if(counter<=0) { if(counter<=0) {
@ -78,7 +91,7 @@ function stattab_print() {
if(v_status.size()>0) { if(v_status.size()>0) {
if(b_updating==0) { if(b_updating==0) {
u=0 u=0
while(u<8){ while(u<HIGHEST_ROBOTID){
tab = v_status.get(u) tab = v_status.get(u)
if(tab!=nil) if(tab!=nil)
unpackstatus(tab) unpackstatus(tab)
@ -92,7 +105,7 @@ function stattab_send() {
if(v_status.size()>0) { if(v_status.size()>0) {
if(b_updating==0) { if(b_updating==0) {
u=0 u=0
while(u<8){ while(u<HIGHEST_ROBOTID){
tab = v_status.get(u) tab = v_status.get(u)
if(tab!=nil){ if(tab!=nil){
recv_value=tab recv_value=tab

View File

@ -31,13 +31,5 @@ function stoprobot {
} }
function updaterobot { function updaterobot {
# rosrun robot_upstart install --logdir ~/ROS_WS/log/ robot_upstart/launch/m100buzzynocam.launch # rosrun robot_upstart install --logdir ~/ROS_WS/log/ robot_upstart/launch/m100buzzynocam.launch
rosrun robot_upstart install --logdir ~/ROS_WS/log/ dji_sdk_mistlab/launch/m100buzzy.launch rosrun robot_upstart install --logdir ~/ROS_WS/log/ dji_sdk_mistlab/launch_robot/m100buzzy.launch
}
function updaterobot {
# rosrun robot_upstart install --logdir ~/ROS_WS/log/ robot_upstart/launch/m100buzzynocam.launch
rosrun robot_upstart install --logdir ~/ROS_WS/log/ dji_sdk_mistlab/launch/m100buzzy.launch
}
function updaterobot {
# rosrun robot_upstart install --logdir ~/ROS_WS/log/ robot_upstart/launch/m100buzzynocam.launch
rosrun robot_upstart install --logdir ~/ROS_WS/log/ dji_sdk_mistlab/launch/m100buzzy.launch
} }