//-------------------------------------------------
// NAME: M. Benjamin, MIT MechE
// FILE: alpha.moos
//-------------------------------------------------

ServerHost = localhost
ServerPort = 9005
Community  = alpha
Simulator = true
	
MOOSTimeWarp = 1

// Forest Lake
LatOrigin  = 43.825300 
LongOrigin = -70.330400 

// MIT Sailing Pavilion (use this one)
//LatOrigin  = 42.358456 
//LongOrigin = -71.087589


//------------------------------------------
// Antler configuration block

ProcessConfig = ANTLER
{
  MSBetweenLaunches = 200

  Run = MOOSDB		     @ NewConsole = false
  Run = pMarineViewer	 @ NewConsole = false
  Run = uSimMarineV22  @ NewConsole = false
  Run = pNodeReporter	 @ NewConsole = false
  Run = pMarinePIDV22	 @ NewConsole = false
  Run = pHelmIvP	     @ NewConsole = false
  Run = uProcessWatch	 @ NewConsole = false
  Run = pRealm         @ NewConsole = false
  Run = pLogger        @ NewConsole = false
  Run = pOdometry      @ NewConsole = false
}

//------------------------------------------
// pRealm config block

ProcessConfig = pRealm
{
  AppTick   = 4
  CommsTick = 4

	hist_var = FEEDBACK_MSG

	msg_max_hist = 20
	
	scope_set = name=events, vars=NEXT_POINT:PREV_POINT:RF_NEXT:RF_PREV:CURR_TIME
	scope_set = name=events, vars=CYCLE_STATUS:INDEX
	scope_set = name=events2, vars=WPTS_TOTAL:CYCLES_REMAINING:WPTS_REMAIN
	scope_set = name=bflags, vars=CFLAG:WFLAG:EFLAG
}

	
//------------------------------------------
// uProcessWatch config block

ProcessConfig = uProcessWatch
{
  AppTick   = 4
  CommsTick = 4

  summary_wait = 5

  nowatch   = uXMS*
  nowatch   = uMAC*
  nowatch   = uPokeDB*
  nowatch   = uTermCommand*
  watch_all = true
}


//------------------------------------------
// pLogger config block

ProcessConfig = pLogger
{
  AppTick   = 8
  CommsTick = 8

  AsyncLog = true

  // For variables that are published in a bundle on their first post,
  // explicitly declare their logging request

  Log = IVPHELM_LIFE_EVENT @ 0 NOSYNC
  Log = APP_LOG @ 0 NOSYNC
  Log = NODE_COUNT @ 0 NOSYNC
  Log = PROC_COUNT @ 0 NOSYNC

//  file = alpha

  //LogAuxSrc = true
  WildCardLogging = true
  WildCardOmitPattern = *_STATUS
  //WildCardOmitPattern = DB_VARSUMMARY
  //WildCardOmitPattern = DB_RWSUMMARY
  //WildCardOmitPattern = APPCAST
  //WildCardExclusionLog = true
}

//------------------------------------------
// uSimMarineV22 config block

ProcessConfig = uSimMarineV22
{

  AppTick	  = 8
  CommsTick	= 8
 
	app_logging = true
	
  start_x       = 95
  start_y       = -30
  start_speed   = 0
  start_heading = 90

	max_acceleration = 0.25

	//wind_conditions = spd=3.3, dir=180
	//polar_plot = 0,0: 20,40: 45,65: 90,80: 110,90: 135,83: 150,83: 165,60: 180,50
	
	turn_spd_map_full_speed = 4
	turn_spd_map_null_speed = 0.5
	turn_spd_map_full_rate  = 100
	turn_spd_map_null_rate  = 2
	
  prefix        = NAV
  turn_rate     = 40
  thrust_map    = 0:0, 20:1, 40:2, 60:3, 80:4, 100:5
}

//------------------------------------------
// pHelmIvP config block

ProcessConfig = pHelmIvP
{
  MaxAppTick = 10
  AppTick    = 4
  CommsTick  = 4

  term_report_interval = 0

	app_logging = true
	
  bhv_dir_not_found_ok = true
  //ivp_behavior_dir = /Users/ddmikerb

	verbose = terse
	
  behaviors  = alpha.bhv
  domain     = course:0:359:360
  domain     = speed:0:4:21
}

//------------------------------------------
// pMarinePIDV22 config block

ProcessConfig = pMarinePIDV22
{
  AppTick    = 10
  CommsTick  = 10

  verbose       = true
  depth_control = false

  // SIM_INSTABILITY = 20

  // Yaw PID controller
  yaw_pid_kp		 = 1.2
  yaw_pid_kd		 = 0.0
  yaw_pid_ki		 = 0.3
  yaw_pid_integral_limit = 0.07

  // Speed PID controller
  speed_pid_kp		 = 1.0
  speed_pid_kd		 = 0.0
  speed_pid_ki		 = 0.0
  speed_pid_integral_limit = 0.07

  //MAXIMUMS
  maxrudder    = 100
  maxthrust    = 100

  // A non-zero SPEED_FACTOR overrides use of SPEED_PID
  // Will set DESIRED_THRUST = DESIRED_SPEED * SPEED_FACTOR
  speed_factor = 20
}

//------------------------------------------
// pMarineViewer config block

ProcessConfig = pMarineViewer
{
  AppTick    = 4
  CommsTick  = 4

  set_pan_x   = -90
  set_pan_y   = -280
  zoom        = 0.95
  tiff_file   = forrest19.tif
  //tiff_file = MIT_SP.tif
  //tiff_file = null.tif

  // log_the_image = true
	
	// app_logging = true

  vehicle_shape_scale  = 1.5
  hash_delta           = 50
  hash_shade           = 0.4
  hash_viewable        = true

  trails_point_size   = 1

	//full_screen = true
	
  stale_report_thresh = 10
  stale_remove_thresh = 20

  // Appcast configuration
  appcast_height       = 75
  appcast_width        = 30
  appcast_viewable     = true
  appcast_color_scheme = indigo
  nodes_font_size      = xlarge
  procs_font_size      = xlarge
  appcast_font_size    = large
  
  scope = PHELMIVP_PID
  scope = DB_UPTIME
	
	left_context[return] = RETURN_POINT = points = $(XPOS),$(YPOS)
	
	action = USM_ENABLED=false
	action = USM_TURN_RATE = 70
	action = USM_TURN_RATE = 50
	action = USM_TURN_RATE = 30
	action = USM_TURN_RATE = 10
	action = USM_TURN_RATE = 5
	action = USM_TURN_RATE = 2
	
  button_one = DEPLOY # DEPLOY=true
  button_one = MOOS_MANUAL_OVERRIDE=false # RETURN=false
  button_two = RETURN:T # RETURN=true
  button_three = RETURN:F # RETURN=false

  button_four = REVERSE # WPT_UPDATE=order=toggle

  //button_5 = ARROW # VIEW_ARROW="ctrx=20,ctry=-40,ang=135,bwid=10,blen=30,hwid=20,hlen=10,label=a,fill_color=yellow,fill_transparency=0.2,edge_color=off"
  button_5 = ARROW # VIEW_ARROW="ctrx=20,ctry=-40,ang=135,bwid=10,blen=30,hwid=20,hlen=10,label=a"
  button_6 = ARROW # VIEW_ARROW="ctrx=20,ctry=-40,ang=270,bwid=10,blen=30,hwid=20,hlen=10,label=a,fill_color=white,fill_transparency=0.1,edge_color=off"

	button_7 = DEPLOY:F # DEPLOY=false 
	button_8 = RESET-HASH # RESET_MHASH=true
	button_9 = RESET_IX # WPT_UPDATE=currix=0

	}

//------------------------------------------
// pNodeReporter config block

ProcessConfig = pNodeReporter
{
//  MaxAppTick = 2
  AppTick  	 = 2
  CommsTick	 = 2

	app_logging = true
	
  platform_type   = kayak
  platform_length = 4
	//platform_color = pink
	
	rider = var=WFLAG, policy=always, rfld=mflagx
	rider = var=CFLAG, policy=10
}