2018-09-07 01:56:17 -03:00
include "update.bzz"
# don't use a stigmergy id=11 with this header, for barrier
# it requires an 'action' function to be defined here.
include "act/states.bzz"
2018-11-04 17:27:11 -04:00
include "utils/table.bzz"
2018-11-11 16:11:41 -04:00
#include "plan/rrtstar.bzz"
2018-09-07 01:56:17 -03:00
include "taskallocate/graphformGPS.bzz"
2018-11-11 16:11:41 -04:00
#include "taskallocate/bidding.bzz"
2018-09-07 01:56:17 -03:00
include "vstigenv.bzz"
2018-09-26 12:49:58 -03:00
#include "timesync.bzz"
2018-09-11 01:02:20 -03:00
include "utils/takeoff_heights.bzz"
2018-09-07 01:56:17 -03:00
#State launched after takeoff
2016-02-11 12:40:13 -04:00
2019-02-14 14:18:07 -04:00
AUTO_LAUNCH_STATE = "IDLE"
2018-10-29 02:47:39 -03:00
LAND_AFTER_BARRIER_EXPIRE = 1 # if set to be 1 , the robots will land after barrier expire; if set to be 0, the robots will carry on to AUTO_LAUNCH_STATE.
2018-09-07 01:56:17 -03:00
#####
# Vehicule type:
# 0 -> outdoor flying vehicle
# 1 -> indoor flying vehicle
# 2 -> outdoor wheeled vehicle
# 3 -> indoor wheeled vehicle
2018-11-05 15:50:24 -04:00
if(id==0) # No network ID=0, it's the groundstation/charging station.
V_TYPE = 2
else
V_TYPE = 0
2018-09-07 01:56:17 -03:00
# Executed once at init time.
function init() {
init_stig()
init_swarm()
2018-11-11 16:11:41 -04:00
#init_bidding()
2018-09-27 13:18:43 -03:00
2018-09-26 23:31:44 -03:00
TARGET_ALTITUDE = takeoff_heights[id]
2018-09-28 00:59:54 -03:00
2018-09-07 01:56:17 -03:00
# start the swarm command listener
nei_cmd_listen()
# Starting state: TURNEDOFF to wait for user input.
2019-02-14 14:18:07 -04:00
BVMSTATE = "TURNEDOFF"
2018-09-07 01:56:17 -03:00
}
# Executed at each time step.
function step() {
# listen to Remote Controller
rc_cmd_listen()
# update the vstig (status/net/batt/...)
2018-11-05 05:11:02 -04:00
uav_updatestig()
2018-09-07 01:56:17 -03:00
#
# State machine
#
if(BVMSTATE=="TURNEDOFF")
statef=turnedoff
else if(BVMSTATE=="CUSFUN")
statef=cusfun
2019-01-08 15:26:38 -04:00
else if(BVMSTATE == "YOLO_DEMO")
statef=yolo_demo
2018-09-07 01:56:17 -03:00
else if(BVMSTATE=="STOP") # ends on turnedoff
statef=stop
else if(BVMSTATE=="LAUNCH") # ends on AUTO_LAUNCH_STATE
2018-10-17 20:05:13 -03:00
if(LAND_AFTER_BARRIER_EXPIRE == 1)
statef=launch
else
statef=launch_switch
2018-09-07 01:56:17 -03:00
else if(BVMSTATE=="GOHOME") # ends on AUTO_LAUNCH_STATE
statef=goinghome
2018-11-07 13:01:40 -04:00
else if(BVMSTATE=="WAYPOINT")
2018-10-18 23:18:12 -03:00
statef=indiWP
2018-09-07 01:56:17 -03:00
else if(BVMSTATE=="IDLE")
statef=idle
else if(BVMSTATE=="AGGREGATE")
statef=aggregate
2018-11-06 05:01:16 -04:00
else if(BVMSTATE=="POTENTIAL")
statef=lennardjones
2018-09-07 01:56:17 -03:00
else if(BVMSTATE=="PURSUIT")
statef=pursuit
else if(BVMSTATE=="TASK_ALLOCATE") # or bidding ?
2019-04-10 15:14:19 -03:00
statef=graph_state
2018-10-22 15:35:09 -03:00
else if(BVMSTATE=="BIDDING") # check the absolute path of the waypointlist csv file in bidding.bzz
2018-10-17 20:05:13 -03:00
statef=bidding
2018-11-07 11:24:06 -04:00
else if(BVMSTATE=="DEPLOY") # check the absolute path of the waypointlist csv file in bidding.bzz
statef=voronoicentroid
2018-09-07 01:56:17 -03:00
else if(BVMSTATE=="PATHPLAN") # ends on navigate, defined in rrtstar
statef=rrtstar
else if(BVMSTATE=="NAVIGATE") # ends on idle, defined in rrtstar
statef=navigate
else if(BVMSTATE == "FOLLOW") #TODO: not tested in new structure
statef=follow
else if(BVMSTATE == "PICTURE") #TODO: not tested in new structure
statef=take_picture
statef()
log("Current state: ", BVMSTATE)
2019-01-08 15:26:38 -04:00
2018-09-07 01:56:17 -03:00
}
# Executed once when the robot (or the simulator) is reset.
function reset() {
}
# Executed once at the end of experiment.
function destroy() {
2018-10-17 20:05:13 -03:00
close_bidding()
2018-11-21 07:53:33 -04:00
discomp_destroy()
2018-09-07 01:56:17 -03:00
}