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

initialize   DEPLOY = false
initialize   RETURN = false

set MODE = POSE-FIXING {
  DEPLOY = hold
} INACTIVE

set MODE = ACTIVE {
  DEPLOY = true
} 

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


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

  idleflag  = WPTING = idle
  runflag   = WPTING = running
  endflag   = WPTING = end
  inactiveflag = WPTING = inactive

	wptflag   = DEPLOY = hold
	wptflag   = HOLD_POINT = x=$[NX],y=$[NY]

  UPDATES   = WPT_UPDATE
  perpetual = true

               lead = 8
        lead_damper = 1
              speed = 2   // 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 = 0

    wpt_dist_to_prev = SURVEY_DIST_TO_PREV
    wpt_dist_to_next = SURVEY_DIST_TO_NEXT

    visual_hints = nextpt_color=yellow
    visual_hints = nextpt_vertex_size=8
    visual_hints = nextpt_lcolor=gray70
    visual_hints = vertex_color=dodger_blue, edge_color=white
    visual_hints = vertex_size=5, 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 = 1.5
  capture_radius = 2.0
     slip_radius = 8.0
          points = 0,-20
 }

//----------------------------------------------
Behavior=BHV_ConstantSpeed
{
  name       = slow_in_turn
  pwt        = 500
  condition  = ((SURVEY_DIST_TO_NEXT < 25) and (SURVEY_DIST_TO_NEXT > 0)) or ((SURVEY_DIST_TO_PREV < 20) and (SURVEY_DIST_TO_PREV > 0))
  condition  = DEPLOY = true
  perpetual  = true

           speed = 1.0
        duration = no-time-limit
 }