//--------    FILE: alpha.bhv   -------------

initialize   DEPLOY = false
initialize   RETURN = false
initialize   AVOID  = false
initialize   DELAY  = true

set MODE = ACTIVE {
  DEPLOY = true
} INACTIVE

set MODE = DELAYING {
  MODE = ACTIVE
  DELAY = true
  RETURN != true
} 

set MODE = SURVEYING {
  MODE = ACTIVE
  DELAY  != true
  RETURN != true
} 

set MODE = RETURNING {
  MODE = ACTIVE
  RETURN = true
} 


//----------------------------------------------
Behavior = BHV_Timer
{ 
  name = timer

  condition = MODE == DELAYING
  duration  = $(DELAYTIME)

  endflag = DELAY = false
}



//----------------------------------------------
Behavior = BHV_Waypoint
{ 
  name      = waypt_survey
  pwt       = 100
  condition = MODE==SURVEYING
  endflag   = RETURN = true
  UPDATES   = WPT_UPDATE
  perpetual = true

               lead = 8
        lead_damper = 1
              speed = $(SPEED)   // meters per second
       capture_line = true
     capture_radius = 5.0
        slip_radius = 15.0
             points = 60,-40 : 60,-160 : 150,-160 : 180,-100 : 150,-40
             repeat = 1800
              order = $(ORDER)

    visual_hints = nextpt_color=red, nextpt_lcolor=green
    visual_hints = vertex_color=blue, edge_color=pink
    visual_hints = vertex_size=4, edge_size=1
}

//----------------------------------------------
Behavior=BHV_Waypoint
{
  name       = waypt_return
  pwt        = 100
  condition  = MODE==RETURNING
  perpetual  = true
  endflag    = RETURN = false
  endflag    = DEPLOY = false
  endflag    = MISSION = complete

           speed = 2.0
  capture_radius = 2.0
     slip_radius = 8.0
          points = 0,0
}

//----------------------------------------------
Behavior = BHV_AvoidCollision
{
  name         = avdc_
  pwt          = 300
  condition    = MODE==ACTIVE
  condition    = AVOID=true
  activeflag   = AVOIDING=true
  inactiveflag = AVOIDING=false
  updates      = CONTACT_INFO
  endflag      = CONTACT_RESOLVED = $[CONTACT]
  templating   = spawn


             contact = to-be-set
    on_no_contact_ok = true
         extrapolate = false
               decay = 30,60

        pwt_outer_dist = 30
        pwt_inner_dist = 10
        completed_dist = 50
     min_util_cpa_dist = 1
     max_util_cpa_dist = 25
             pwt_grade = linear
   bearing_line_config = white:0, green:0.65, yellow:0.8, red:1.0
}