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

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

set MODE = ACTIVE {
  DEPLOY = true
} INACTIVE

set MODE = STATION-KEEPING {
  MODE = ACTIVE
  STATION_KEEP = true
}

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

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

//---------------------------------------------
Behavior = BHV_StationKeep
{
  name		= station-keep
  pwt		= 100
  condition	= MODE==STATION-KEEPING

	center_activate = true
	inner_radius = 5
	outer_radius = 10
	outer_speed = 1.0
	transit_speed = 1.3
	swing_time = 7
	hibernation_radius = 25
	visual_hints = vertex_size=0, edge_color=blue
}
//----------------------------------------------
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
//	   points = 50,-25 : 0,-45 : 0, -70: 50,-50  // square along dock
	   points = 50,-25 : 0,-45 : 12, -70:48,-85: 62,-50  // home plate

        repeat = 1800
         order = normal


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

//----------------------------------------------
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
  updates    = CONTACT_INFO
  endflag    = CONTACT_RESOLVED = $[CONTACT]
  templating = spawn

  activeflag   = AVOIDING=true
  inactiveflag = AVOIDING=false


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

        pwt_outer_dist = 30
        pwt_inner_dist = 4
        completed_dist = 50
     min_util_cpa_dist = 2
     max_util_cpa_dist = 7
             pwt_grade = linear
   bearing_line_config = white:0, green:0.65, yellow:0.8, red:1.0
}

//-----------------------------------------------
Behavior = BHV_OpRegion
{
  name		= opregion
  pwt		= 100
  condition	= MODE==ACTIVE


  polygon = -220, -120 : -100, -430 : 380, -240 : 254, 46 : 112, 21 
  trigger_entry_time = 1
  trigger_exit_time = 1

  visual_hints = edge_size=1
}