//--------    FILE: delta.bhv   -------------

initialize   DEPLOY   = false
initialize   RETURN   = false
initialize   SURVEY   = false
initialize   RETREAT_LOITER = false
initialize   PSURFACE = true

//========================================================
// Hierarchical Mode Declarations
//  o ROOT                     o ROOT
//  |--o INACTIVE              |--o PSURFACING
//  |--o ACTIVE                |--o NOT_PSURFACING
//     |--o RETREAT_LOITER
//     |--o SURVEYING
//     |--o RETURNING
//========================================================


Set MODE = ACTIVE {
  DEPLOY = true
} INACTIVE

set MODE = RETREAT_LOITER {
  MODE = ACTIVE
  SAFETY_RETREAT = true
} 

set MODE = SURVEYING {
  MODE = ACTIVE
  SURVEY = true
} RETURNING


//----------------------------------------------
Behavior = BHV_Loiter
{
  name      = loiter
  pwt       = 100
  condition = MODE == RETREAT_LOITER
  updates   = UP_RETREAT
  perpetual = true
  endflag   = SAFETY_RETREAT = false

   post_suffix = A
         speed = 1.3
     clockwise = false
        radius = 4.0
     nm_radius = 15.0
       polygon = radial:: x=20, y=-80, radius=20, pts=8, snap=1, label=DUDLEY_LOITER
  visual_hints = nextpt_color=red, nextpt_lcolor=khaki
  visual_hints = edge_color=khaki, vertex_color=white
  visual_hints = edge_size=1, vertex_size=4
}


//----------------------------------------------
Behavior = BHV_Waypoint
{
  name       = waypt_return
  pwt        = 100
  condition  = MODE == RETURNING
  updates    = UPDATES_RETURN
  perpetual  = true
  endflag    = RETURNING = false
  endflag    = DEPLOY = false

       speed = 2.0
      radius = 2.0
   nm_radius = 8.0
       point = 0,0
}

//----------------------------------------------
Behavior = BHV_PeriodicSurface
{
  name             = bhv_periodic_surface
  pwt              = 1000
  condition        = (MODE == LOITERING)
  //condition        = (MODE == LOITERING) or (MODE == RETURNING)
  condition        = PSURFACE = true

               period = 120
     zero_speed_depth = 2
  max_time_at_surface = 60
         ascent_speed = 1.0
         ascent_grade = fullspeed
}

//----------------------------------------------
Behavior = BHV_ConstantDepth
{
  name      = bhv_const_depth
  pwt       = 100
  duration  = no-time-limit
  condition = MODE==ACTIVE

      depth = 15
}

//----------------------------------------------
Behavior = BHV_Waypoint
{
  name      = waypt_survey
  pwt       = 100
  condition = MODE==SURVEYING
  perpetual = true
  updates   = SURVEY_UPDATES
  endflag   = SURVEY = false

     cycleflag = SURVEY = false
          lead = 8
   lead_damper = 1
         speed = 2.0   // meters per second
        radius = 8.0
        points = format=lawnmower, label=dudley_survey, x=80, y=-80, width=70, height=30, lane_width=8, rows=north-south, degs=30
        repeat = 1
  visual_hints = nextpt_color=red, nextpt_lcolor=khaki
  visual_hints = vertex_color=yellow, line_color=white
  visual_hints = vertex_size=2, edge_size=1
}