// Interface description in doxygen format
description {
  @brief Planar mobile robot

  The @p position2d interface is used to control mobile robot bases in 2D.
}

// interface data structures

/** position2d data */
typedef struct player_position2d_data
{
  /** position [m,m,rad] (x, y, yaw)*/
  player_pose2d_t pos;
  /** translational velocities [m/s,m/s,rad/s] (x, y, yaw)*/
  player_pose2d_t vel;
  /** Are the motors stalled? */
  uint8_t stall;
} player_position2d_data_t;

/** position 2d velocity command */
typedef struct player_position2d_cmd_vel
{
  /** translational velocities [m/s,m/s,rad/s] (x, y, yaw)*/
  player_pose2d_t vel;
  /** Motor state (FALSE is either off or locked, depending on the driver). */
  uint8_t state;
} player_position2d_cmd_vel_t;

/** position2d position command */
typedef struct player_position2d_cmd_pos
{
  /** position [m,m,rad] (x, y, yaw)*/
  player_pose2d_t pos;
  /** velocity at which to move to the position [m/s] or [rad/s] */
  player_pose2d_t vel;
  /** Motor state (FALSE is either off or locked, depending on the driver). */
  uint8_t state;
} player_position2d_cmd_pos_t;

/** position2d command setting velocity and steering angle */
typedef struct player_position2d_cmd_car
{
  /** forward velocity (m/s) */
  double velocity;
  /** relative turning angle (rad) */
  double angle;
} player_position2d_cmd_car_t;

/** position2d command setting velocity and heading */
typedef struct player_position2d_cmd_vel_head
{
  /** forward velocity (m/s) */
  double velocity;
  /** absolute turning angle (rad) */
  double angle;
} player_position2d_cmd_vel_head_t;

/** position2d geom */
typedef struct player_position2d_geom
{
  /** Pose of the robot base, in the robot cs (m, rad). */
  player_pose3d_t pose;
  /** Dimensions of the base (m). */
  player_bbox3d_t size;
} player_position2d_geom_t;

/** position2d power config */
typedef struct player_position2d_power_config
{
  /** FALSE for off, TRUE for on */
  uint8_t state;
} player_position2d_power_config_t;

/** position2d velocity mode config */
typedef struct player_position2d_velocity_mode_config
{
  /** driver-specific */
  uint32_t value;
} player_position2d_velocity_mode_config_t;


/** position2d position mode request */
typedef struct player_position2d_position_mode_req
{
  /** 0 for velocity mode, 1 for position mode */
  uint32_t state;
} player_position2d_position_mode_req_t;

/** set odometry */
typedef struct player_position2d_set_odom_req
{
  /** (x, y, yaw) [m, m, rad] */
  player_pose2d_t pose;
} player_position2d_set_odom_req_t;

/** position2d speed PID req */
typedef struct player_position2d_speed_pid_req
{
  /** PID parameters */
  float kp;
  /** PID parameters */
  float ki;
  /** PID parameters */
  float kd;
} player_position2d_speed_pid_req_t;

/** position2d position pid req */
typedef struct player_position2d_position_pid_req
{
  /** PID parameters */
  float kp;
  /** PID parameters */
  float ki;
  /** PID parameters */
  float kd;
} player_position2d_position_pid_req_t;

/** speed prof req */
typedef struct player_position2d_speed_prof_req
{
  /** max speed [m/s] */
  float speed;
  /** max acceleration [m/s^2] */
  float acc;
} player_position2d_speed_prof_req_t;
/** @} */



 // Interface Message definitions
  /** @brief Request/reply: geometry.

  To request robot geometry, send a null @ref PLAYER_POSITION2D_REQ_GET_GEOM
  request. */
  message { REQ, GET_GEOM, 1, player_position2d_geom_t };
  
  /** @brief Request/reply: Motor power.

  On some robots, the motor power can be turned on and off from software.
  To do so, send a @ref PLAYER_POSITION2D_REQ_MOTOR_POWER request with the
  format given below, and with the appropriate @p state (zero for motors
  off and non-zero for motors on).  Null response.

  Be VERY careful with this command!  You are very likely to start the
  robot running across the room at high speed with the battery charger
  still attached.
  */
  message { REQ, MOTOR_POWER, 2, player_position2d_power_config_t };
  
  /** @brief Request/reply: Change velocity control.

  Some robots offer different velocity control modes.  It can be changed by
  sending a @ref PLAYER_POSITION2D_REQ_VELOCITY_MODE request with the format
  given below, including the appropriate mode.  No matter which mode is
  used, the external client interface to the @p position device remains
  the same.  Null response.

The @ref driver_p2os driver offers two modes of velocity control:
  separate translational and rotational control and direct wheel control.
  When in the separate mode, the robot's microcontroller internally
  computes left and right wheel velocities based on the currently commanded
  translational and rotational velocities and then attenuates these values
  to match a nice predefined acceleration profile.  When in the direct
  mode, the microcontroller simply passes on the current left and right
  wheel velocities.  Essentially, the separate mode offers smoother but
  slower (lower acceleration) control, and the direct mode offers faster
  but jerkier (higher acceleration) control.  Player's default is to use
  the direct mode.  Set @a mode to zero for direct control and non-zero
  for separate control.

  For the @ref driver_reb driver, 0 is direct velocity control,
  1 is for velocity-based heading PD controller.
  */
  message { REQ, VELOCITY_MODE, 3, player_position2d_velocity_mode_config_t };
  
  /** @brief Request/reply: Change control mode.

  To change control mode, send a @ref PLAYER_POSITION2D_REQ_POSITION_MODE request.
  Null response.
  */
  message { REQ, POSITION_MODE, 4, player_position2d_position_mode_req_t };
  
  /** @brief Request/reply: Set odometry.

  To set the robot's odometry to a particular state, send a
  @ref PLAYER_POSITION2D_REQ_SET_ODOM request.  Null response. */
  message { REQ, SET_ODOM, 5, player_position2d_set_odom_req_t };
  
  /** @brief Request/reply: Reset odometry.

  To reset the robot's odometry to @f$(x, y, yaw) = (0,0,0)@f$, send
  a @ref PLAYER_POSITION2D_REQ_RESET_ODOM request.  Null response. */
  message { REQ, RESET_ODOM, 6, NULL };

  /** @brief Request/reply: Set velocity PID parameters.
  *
  * To set velocity PID parameters, send a @ref PLAYER_POSITION2D_REQ_SPEED_PID
  * request.  Null response.
  */
  message { REQ, SPEED_PID, 7, player_position2d_speed_pid_req_t };
  
  /** @brief Request/reply: Set position PID parameters.
  *
  * To set position PID parameters, send a
  * @ref PLAYER_POSITION2D_REQ_POSITION_PID
  * request.  Null response.
  */
  message { REQ, POSITION_PID, 8, player_position2d_position_pid_req_t };
  
  /** @brief Request/reply: Set linear speed profile parameters.
  *
  * To set linear speed profile parameters, send a
  * @ref PLAYER_POSITION2D_REQ_SPEED_PROF request.  Null response. */  
  message { REQ, SPEED_PROF, 9, player_position2d_speed_prof_req_t };

  /** @brief Data: state (@ref PLAYER_POSITION2D_DATA_STATE)

  The @p position interface returns data regarding the odometric pose and
  velocity of the robot, as well as motor stall information. */
  message { DATA, STATE, 1, player_position2d_data_t };
  
  /** @brief Data: geometry.

  This messages is published by drivers which can change their geometry 
  at run time */
  message { DATA, GEOM, 2, player_position2d_geom_t };
    
  /** @brief Command: velocity (@ref PLAYER_POSITION2D_CMD_VEL)

  The @p position interface accepts new velocities
  for the robot's motors (drivers may support position control, speed control,
  or both). */
  message { CMD, VEL, 1, player_position2d_cmd_vel_t };
  
  /** @brief Command: position (@ref PLAYER_POSITION2D_CMD_POS)

  The @p position interface accepts new positions
  for the robot's motors (drivers may support position control, speed control,
  or both). */
  message { CMD, POS, 2, player_position2d_cmd_pos_t };

  /** @brief Command: carlike (@ref PLAYER_POSITION2D_CMD_CAR)

  The @p position interface accepts carlike translational velocity + constant turn commands (speed and turning angle)
  for the robot's motors (only supported by some drivers). */
  message { CMD, CAR, 3, player_position2d_cmd_car_t };


  /** @brief Command: vel/head (@ref PLAYER_POSITION2D_CMD_VEL_HEAD)

  The @p position interface accepts translational velocity + absolute heading commands (speed and angular position) for the robot's motors (only supported by some drivers). */
  message { CMD, VEL_HEAD , 4, player_position2d_cmd_vel_head_t };
