/**
  * Request/reply: Set linear speed profile parameters. <br>
  * <br>
  * To set linear speed profile parameters, send a PLAYER_POSITION1D_SPEED_PROF request. Null
  * response.
  *
  * @param speed max speed [m/s]
  * @param acc max acceleration [m/s^2]
  */
 public void setSpeedProfileParams(float speed, float acc) {
   try {
     sendHeader(PLAYER_MSGTYPE_REQ, PLAYER_POSITION1D_REQ_SPEED_PROF, 8);
     XdrBufferEncodingStream xdr = new XdrBufferEncodingStream(8);
     xdr.beginEncoding(null, 0);
     xdr.xdrEncodeFloat(speed);
     xdr.xdrEncodeFloat(acc);
     xdr.endEncoding();
     os.write(xdr.getXdrData(), 0, xdr.getXdrLength());
     xdr.close();
     os.flush();
   } catch (IOException e) {
     throw new PlayerException("[Position1D] : Couldn't request SPEED_PROF: " + e.toString(), e);
   } catch (OncRpcException e) {
     throw new PlayerException(
         "[Position1D] : Error while XDR-encoding SPEED_PROF " + "request: " + e.toString(), e);
   }
 }
 /**
  * Request/reply: Set position PID parameters. <br>
  * <br>
  * To set position PID parameters, send a PLAYER_POSITION1D_POSITION_PID request. Null response.
  *
  * @param kp P parameter
  * @param ki I parameter
  * @param kd D parameter
  */
 public void setPositionPIDParams(float kp, float ki, float kd) {
   try {
     sendHeader(PLAYER_MSGTYPE_REQ, PLAYER_POSITION1D_REQ_POSITION_PID, 12);
     XdrBufferEncodingStream xdr = new XdrBufferEncodingStream(12);
     xdr.beginEncoding(null, 0);
     xdr.xdrEncodeFloat(kp);
     xdr.xdrEncodeFloat(ki);
     xdr.xdrEncodeFloat(kd);
     xdr.endEncoding();
     os.write(xdr.getXdrData(), 0, xdr.getXdrLength());
     xdr.close();
     os.flush();
   } catch (IOException e) {
     throw new PlayerException("[Position1D] : Couldn't request POSITION_PID: " + e.toString(), e);
   } catch (OncRpcException e) {
     throw new PlayerException(
         "[Position1D] : Error while XDR-encoding POSITION_PID " + "request: " + e.toString(), e);
   }
 }
 /**
  * The position1D interface accepts new positions and/or velocities for the robot's motors
  * (drivers may support position control, speed control or both). <br>
  * <br>
  * See the player_position1d_cmd_vel structure from player.h
  *
  * @param pp1dcv a PlayerPosition1dCmdVel structure holding the required data
  */
 public void setVelocity(PlayerPosition1dCmdVel pp1dcv) {
   try {
     sendHeader(PLAYER_MSGTYPE_CMD, PLAYER_POSITION1D_CMD_VEL, 8);
     XdrBufferEncodingStream xdr = new XdrBufferEncodingStream(8);
     xdr.beginEncoding(null, 0);
     xdr.xdrEncodeFloat(pp1dcv.getVel());
     xdr.xdrEncodeByte(pp1dcv.getState());
     xdr.endEncoding();
     os.write(xdr.getXdrData(), 0, xdr.getXdrLength());
     xdr.close();
     os.flush();
   } catch (IOException e) {
     throw new PlayerException(
         "[Position1D] : Couldn't send velocity command: " + e.toString(), e);
   } catch (OncRpcException e) {
     throw new PlayerException(
         "[Position1D] : Error while XDR-encoding position command: " + e.toString(), e);
   }
 }
 /**
  * The position1D interface accepts new positions and/or velocities for the robot's motors
  * (drivers may support position control, speed control or both). <br>
  * <br>
  * See the player_position1d_cmd_pos structure from player.h
  *
  * @param pos position data [m] or [rad]
  * @param vel velocity at which to move to the position [m/s] or [rad/s]
  * @param state motor state (zero is either off or locked, depending on the driver)
  */
 public void setPosition(float pos, float vel, int state) {
   try {
     sendHeader(PLAYER_MSGTYPE_CMD, PLAYER_POSITION1D_CMD_POS, 12);
     XdrBufferEncodingStream xdr = new XdrBufferEncodingStream(12);
     xdr.beginEncoding(null, 0);
     xdr.xdrEncodeFloat(pos);
     xdr.xdrEncodeFloat(vel);
     xdr.xdrEncodeByte((byte) state);
     xdr.endEncoding();
     os.write(xdr.getXdrData(), 0, xdr.getXdrLength());
     xdr.close();
     os.flush();
   } catch (IOException e) {
     throw new PlayerException(
         "[Position1D] : Couldn't send position command: " + e.toString(), e);
   } catch (OncRpcException e) {
     throw new PlayerException(
         "[Position1D] : Error while XDR-encoding position command: " + e.toString(), e);
   }
 }
 /**
  * Request/reply: Reset odometry. <br>
  * <br>
  * To set a robot's odometry to x = 0, send a PLAYER_POSITION1D_REQ_RESET_ODOM request. Null
  * response.
  *
  * @param value driver-specific
  */
 public void resetOdometry(int value) {
   try {
     sendHeader(PLAYER_MSGTYPE_REQ, PLAYER_POSITION1D_REQ_SET_ODOM, 4);
     XdrBufferEncodingStream xdr = new XdrBufferEncodingStream(4);
     xdr.beginEncoding(null, 0);
     xdr.xdrEncodeInt(value);
     xdr.endEncoding();
     os.write(xdr.getXdrData(), 0, xdr.getXdrLength());
     xdr.close();
     os.flush();
   } catch (IOException e) {
     throw new PlayerException("[Position1D] : Couldn't request RESET_ODOM: " + e.toString(), e);
   } catch (OncRpcException e) {
     throw new PlayerException(
         "[Position1D] : Error while XDR-encoding RESET_ODOM " + "request: " + e.toString(), e);
   }
 }
 /**
  * Request/reply: Motor power. <br>
  * <br>
  * On some robots, the motor power can be turned on and off from software. To do so, send a
  * PLAYER_POSITION1D_MOTOR_POWER request with the format given below, and with the appropriate
  * state (zero for motors off and non-zero for motors on). Null response. <br>
  * <br>
  * 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.
  *
  * @param state 0 for off, 1 for on
  */
 public void setMotorPower(int state) {
   try {
     sendHeader(PLAYER_MSGTYPE_REQ, PLAYER_POSITION1D_REQ_MOTOR_POWER, 4);
     XdrBufferEncodingStream xdr = new XdrBufferEncodingStream(4);
     xdr.beginEncoding(null, 0);
     xdr.xdrEncodeByte((byte) state);
     xdr.endEncoding();
     os.write(xdr.getXdrData(), 0, xdr.getXdrLength());
     xdr.close();
     os.flush();
   } catch (IOException e) {
     throw new PlayerException("[Position1D] : Couldn't request MOTOR_POWER: " + e.toString(), e);
   } catch (OncRpcException e) {
     throw new PlayerException(
         "[Position1D] : Error while XDR-encoding POWER request: " + e.toString(), e);
   }
 }
 /**
  * Request/reply: Change velocity control. <br>
  * <br>
  * Some robots offer different velocity control modes. It can be changed by sending a
  * PLAYER_POSITION1D_VELOCITY_MODE request with the format given below, including the appropriate
  * mode. No matter which mode is used, the external client interface to the position1d device
  * remains the same. Null response.
  *
  * @param mode driver-specific mode
  */
 public void setVelocityControl(int mode) {
   try {
     sendHeader(PLAYER_MSGTYPE_REQ, PLAYER_POSITION1D_REQ_VELOCITY_MODE, 4);
     XdrBufferEncodingStream xdr = new XdrBufferEncodingStream(4);
     xdr.beginEncoding(null, 0);
     xdr.xdrEncodeInt(mode);
     xdr.endEncoding();
     os.write(xdr.getXdrData(), 0, xdr.getXdrLength());
     xdr.close();
     os.flush();
   } catch (IOException e) {
     throw new PlayerException(
         "[Position1D] : Couldn't request VELOCITY_MODE: " + e.toString(), e);
   } catch (OncRpcException e) {
     throw new PlayerException(
         "[Position1D] : Error while XDR-encoding VELOCITY_MODE " + "request: " + e.toString(), e);
   }
 }