// Copyright (c) 2014 CNRS
// Author: Florent Lamiraux
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.

#ifndef HPP_MANIPULATION_CORBA_ROBOT_IDL
#define HPP_MANIPULATION_CORBA_ROBOT_IDL

#include <hpp/common.idl>

module hpp
{
  module corbaserver {
  module manipulation {
  interface Robot
  {
    ///  Insert robot model as a child of the root joint of the Device
    ///
    /// \param robotName key of the robot in ProblemSolver object map
    ///        (see hpp::manipulation::ProblemSolver::addRobot)
    /// \param rootJointType type of root joint among "anchor", "freeflyer",
    /// "planar",
    /// \param urdfName name of the urdf file. It may contain
    ///        "file://", or "package://" prefixes.
    /// \param srdfName name of the srdf file. It may contain
    ///        "file://", or "package://" prefixes.
    ///
    void insertRobotModel (in string robotName, in string rootJointType,
        in string urdfname, in string srdfname)
      raises (Error);

    /// \copydoc hpp::corbaserver::manipulation::Robot::insertRobotModel
    /// \param frameName existing frame onto which the robot should be loaded.
    void insertRobotModelOnFrame (in string robotName, in string frameName,
        in string rootJointType, in string urdfname, in string srdfname)
      raises (Error);

    ///  Insert robot model as a child of the root joint of the Device
    ///
    /// \param robotName key of the robot in ProblemSolver object map
    ///        (see hpp::manipulation::ProblemSolver::addRobot)
    /// \param rootJointType type of root joint among "anchor", "freeflyer",
    /// "planar",
    /// \param urdfString urdf file,
    /// \param srdfString srdf file. Can be empty.
    void insertRobotModelFromString (in string robotName, in string rootJointType,
        in string urdfString, in string srdfString)
      raises (Error);

    /// \copydoc hpp::corbaserver::manipulation::Robot::insertRobotModelFromString
    /// \param frameName existing frame onto which the robot should be loaded.
    void insertRobotModelOnFrameFromString (in string robotName, in string frameName,
        in string rootJointType, in string urdfString, in string srdfString)
      raises (Error);

    /// Load a SRDF for the robot. Several SRDF can thus be loaded for the same
    /// robot
    void insertRobotSRDFModel (in string robotName, in string srdfPath)
      raises (Error);

    /// Load a SRDF for the robot. Several SRDF can thus be loaded for the same
    /// robot
    void insertRobotSRDFModelFromString (in string robotName,
        in string srdfString) raises (Error);

    ///  Insert humanoid robot model as a child of the root joint of the Device
    ///
    /// \param robotName key of the robot in ProblemSolver object map
    ///        (see hpp::manipulation::ProblemSolver::addRobot)
    /// \param rootJointType type of root joint among "anchor", "freeflyer",
    /// "planar",
    /// \param urdfName name of the urdf file. It may contain
    ///        "file://", or "package://" prefixes.
    /// \param srdfName name of the srdf file. It may contain
    ///        "file://", or "package://" prefixes.
    ///
    void insertHumanoidModel (in string robotName, in string rootJointType,
        in string urdfname, in string srdfname)
      raises (Error);

    ///  Insert humanoid robot model as a child of the root joint of the Device
    ///
    /// \param robotName key of the robot in ProblemSolver object map
    ///        (see hpp::manipulation::ProblemSolver::addRobot)
    /// \param rootJointType type of root joint among "anchor", "freeflyer",
    /// "planar",
    /// \param urdfString urdf file,
    /// \param srdfString srdf file. Can be empty.
    ///
    void insertHumanoidModelFromString (in string robotName, in string rootJointType,
        in string urdfString, in string srdfString)
      raises (Error);

    /// Load model of the environment
    ///
    /// urdfName name of the urdf file describing the environment
    /// srdfName name of the srdf file describing the environment,
    /// prefix string added in front of object names.
    void loadEnvironmentModel (in string urdfName, in string srdfName,
                               in string prefix)
      raises (Error);

    /// Get the position of root joint of a robot in world frame
    /// \param robotName key of the robot in ProblemSolver object map.
    Transform_ getRootJointPosition (in string robotName)
      raises (Error);

    /// Set the position of root joint of a robot in world frame
    /// \param robotName key of the robot in ProblemSolver object map.
    /// \param position constant position of the root joint in world frame in
    ///        initial configuration.
    void setRootJointPosition (in string robotName, in Transform_ position)
      raises (Error);

    /// Add Gripper to a robot
    ///
    /// \param linkName name of the link (hpp::model::Body) holding the gripper,
    /// \param gripperName name of the gripper,
    /// \param handlePositioninJoint position of the handle in the joint frame.
    /// \param clearance clearance of the gripper
    void addGripper (in string linkName, in string gripperName,
                     in Transform_ handlePositioninJoint, in double clearance)
      raises (Error);

    /// Add \link hpp::manipulation::Handle Handle \endlink to an object
    ///
    /// \param linkName name of the link holding the handle,
    /// \param handleName name of the handle,
    /// \param localPosition position of the handle in the joint frame.
    /// \param clearance clearance of the gripper
    /// \param mask mask of the handle.
    void addHandle (in string linkName, in string handleName,
        in Transform_ localPosition, in double clearance, in boolSeq mask)
      raises (Error);

    /// Return the joint name in which a gripper is and the position relatively
    /// to the joint
    string getGripperPositionInJoint (in string gripperName,
        out Transform_ position)
      raises (hpp::Error);

    /// Return the joint name in which a handle is and the position relatively
    /// to the joint
    string getHandlePositionInJoint (in string handleName,
        out Transform_ position)
      raises (hpp::Error);

    /// Set handle position in joint frame
    void setHandlePositionInJoint (in string handleName,
        in Transform_ position)
      raises (hpp::Error);

  }; // interface Robot
  }; // module manipulation
  }; // module corbaserver
}; // module hpp

#endif // HPP_MANIPULATION_CORBA_ROBOT_IDL
