2017-09-06 00:48:50 -03:00
|
|
|
include "update.bzz"
|
2018-04-27 12:42:59 -03:00
|
|
|
# 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"
|
|
|
|
include "vstigenv.bzz"
|
|
|
|
|
|
|
|
#State launched after takeoff
|
|
|
|
AUTO_LAUNCH_STATE = "ACTION"
|
2017-09-06 00:48:50 -03:00
|
|
|
|
|
|
|
function action() {
|
2018-04-27 12:42:59 -03:00
|
|
|
BVMSTATE = "ACTION"
|
2017-09-06 00:48:50 -03:00
|
|
|
uav_storegoal(-1.0,-1.0,-1.0)
|
2018-04-27 12:42:59 -03:00
|
|
|
goto_gps(picture)
|
2017-09-06 00:48:50 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
# Executed once at init time.
|
|
|
|
function init() {
|
2018-04-27 12:42:59 -03:00
|
|
|
init_stig()
|
|
|
|
init_swarm()
|
|
|
|
|
|
|
|
# Starting state: TURNEDOFF to wait for user input.
|
|
|
|
BVMSTATE = "TURNEDOFF"
|
2017-09-06 00:48:50 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
# Executed at each time step.
|
|
|
|
function step() {
|
2018-04-27 12:42:59 -03:00
|
|
|
rc_cmd_listen()
|
|
|
|
|
|
|
|
# update the vstig (status/net/batt/...)
|
|
|
|
# uav_updatestig()
|
|
|
|
|
|
|
|
#
|
|
|
|
# State machine
|
|
|
|
#
|
|
|
|
if(BVMSTATE=="TURNEDOFF")
|
|
|
|
statef=turnedoff
|
|
|
|
else if(BVMSTATE=="STOP") # ends on turnedoff
|
|
|
|
statef=stop
|
|
|
|
else if(BVMSTATE=="LAUNCH") # ends on AUTO_LAUNCH_STATE
|
|
|
|
statef=launch
|
|
|
|
else if(BVMSTATE=="IDLE")
|
|
|
|
statef=idle
|
|
|
|
else if(BVMSTATE=="ACTION")
|
|
|
|
statef=action
|
2017-09-06 00:48:50 -03:00
|
|
|
|
|
|
|
statef()
|
|
|
|
|
2018-04-27 12:42:59 -03:00
|
|
|
log("Current state: ", BVMSTATE)
|
2017-09-06 00:48:50 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
# Executed once when the robot (or the simulator) is reset.
|
|
|
|
function reset() {
|
|
|
|
}
|
|
|
|
|
|
|
|
# Executed once at the end of experiment.
|
|
|
|
function destroy() {
|
|
|
|
}
|