/****************************************************************************/
/* Copyright (c) 2000 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : Setpoint.h                                                    */
/* Author   :                                                               */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 02/07/2000                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
#ifndef _SETPOINT_H
#define _SETPOINT_H

#include "ourTypes.h"
#include "Behavior.h"
#include "DynamicControlIF.h"

#define SetpointBehaviorName "setpoint"

#define NullLegDuration -1.0

class FloatAttribute;
class AngleAttribute;

/*
CLASS 
Setpoint

DESCRIPTION
This behavior sets heading, depth or pitch, and speed of the vehicle.
Vertical mode can be either Pitch or Depth. Behavior is active for
specified number of "legs"; each leg has a specified duration, and
heading is incremented by specified amount after each leg.

Attribute       Type               Meaning
---------       ----               -------
heading         angle              Commanded heading
speed           double             Commanded speed
verticalMode    VerticalMode       Either "depth" or "pitch"
depth           double             Commanded depth if verticalMode is "depth"
pitch           angle              Commanded pitch if verticalMode is "pitch"
legDuration     integer            Duration of each leg 
maxLegs         integer            Maximum number of legs
headingInc      angle              Increment heading by this amount after 
                                   each leg
AUTHOR
Tom O'Reilly
*/
class Setpoint : public Behavior {

public:

  Setpoint();

  virtual ~Setpoint();

  virtual void execute();
  Boolean shouldBehaviorStart( void );
  virtual Boolean validInput();

protected:

  // Desired heading; will get incremented after each leg
  double _heading;

  // Desired speed
  double _speed;

  // Vertical mode 
  DynamicControlIF::VerticalMode _verticalMode;

  // Desired depth if verticalMode is Depth
  double _depth;

  // Desired pitch if verticalMode is Pitch
  double _pitch;

  // Maximumm number of legs to do
  long _maxLegs;

  // Duration (secs) of each leg
  long _legDuration;

  // Increment heading by this amount after each leg
  double _headingIncrement;

  // Number of legs completed
  int _legsCompleted;

  // Starting time of current leg
  double _legStartTime;

  FloatAttribute *_depthAttribute;
  AngleAttribute *_pitchAttribute;
};



#endif
