From ebffbaa4d220377da2f528e26d2ef0a625d4424b Mon Sep 17 00:00:00 2001 From: Joseph Mirabel <jmirabel@laas.fr> Date: Fri, 4 Jul 2014 14:55:09 +0200 Subject: [PATCH] Add graph header files. --- CMakeLists.txt | 3 + .../graph/gripper-state-selector.hh | 37 ++++++++++ .../hpp/manipulation/graph/gripper-state.hh | 60 +++++++++++++++++ .../manipulation/graph/gripper-transition.hh | 67 +++++++++++++++++++ 4 files changed, 167 insertions(+) create mode 100644 include/hpp/manipulation/graph/gripper-state-selector.hh create mode 100644 include/hpp/manipulation/graph/gripper-state.hh create mode 100644 include/hpp/manipulation/graph/gripper-transition.hh diff --git a/CMakeLists.txt b/CMakeLists.txt index bca6860a..1d59f002 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,9 @@ SET (${PROJECT_NAME}_HEADERS include/hpp/manipulation/object.hh include/hpp/manipulation/problem-solver.hh include/hpp/manipulation/robot.hh + include/hpp/manipulation/graph/gripper-state.hh + include/hpp/manipulation/graph/gripper-transition.hh + include/hpp/manipulation/graph/gripper-state-selector.hh ) # Add dependency toward hpp-model library in pkg-config file. diff --git a/include/hpp/manipulation/graph/gripper-state-selector.hh b/include/hpp/manipulation/graph/gripper-state-selector.hh new file mode 100644 index 00000000..602a88dc --- /dev/null +++ b/include/hpp/manipulation/graph/gripper-state-selector.hh @@ -0,0 +1,37 @@ +// Copyright (c) 2014, LAAS-CNRS +// Authors: Joseph Mirabel (joseph.mirabel@laas.fr) +// +// This file is part of hpp-manipulation. +// hpp-manipulation is free software: you can redistribute it +// and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version +// 3 of the License, or (at your option) any later version. +// +// hpp-manipulation is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Lesser Public License for more details. You should have +// received a copy of the GNU Lesser General Public License along with +// hpp-manipulation. If not, see <http://www.gnu.org/licenses/>. + +#include "hpp/manipulation/fwd.hh" +#include "hpp/manipulation/graph/gripper-state.hh" + +namespace hpp { + namespace manipulation { + namespace graph { + /// This class is used to get the state of a configuration. States have to + /// be ordered because a configuration can be in several states. + class HPP_MANIPULATION_DLLAPI GripperStateSelector + { + public: + /// Returns the state of a configuration. + virtual GripperState getState(const Configuration_t config) const; + + private: + /// List of the states of one gripper, ordered by priority. + std::vector< GripperState > orderedStates_; + } + } // ----- End of namespace graph ----- + } // ----- End of namespace manipulation ----- +} // ----- End of namespace hpp ----- diff --git a/include/hpp/manipulation/graph/gripper-state.hh b/include/hpp/manipulation/graph/gripper-state.hh new file mode 100644 index 00000000..9a23a6fc --- /dev/null +++ b/include/hpp/manipulation/graph/gripper-state.hh @@ -0,0 +1,60 @@ +// Copyright (c) 2014, LAAS-CNRS +// Authors: Joseph Mirabel (joseph.mirabel@laas.fr) +// +// This file is part of hpp-manipulation. +// hpp-manipulation is free software: you can redistribute it +// and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version +// 3 of the License, or (at your option) any later version. +// +// hpp-manipulation is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Lesser Public License for more details. You should have +// received a copy of the GNU Lesser General Public License along with +// hpp-manipulation. If not, see <http://www.gnu.org/licenses/>. + +#ifndef HPP_MANIPULATION_GRAPH_GRIPPER_STATE_HH +# define HPP_MANIPULATION_GRAPH_GRIPPER_STATE_HH + +#include <hpp/core/constraints-set.hh> + +#include "hpp/manipulation/fwd.hh" + +namespace hpp { + namespace manipulation { + namespace graph { + /// State of a gripper. + /// + /// Nodes of the graph of constraints. There is one + /// graph for each gripper. + class HPP_MANIPULATION_DLLAPI GripperState + { + public: + /// Check whether the configuration is in this state. + /// \return True if this state contains this configuration + /// \param config The configuration to be tested. + /// \note You should note use that to know in which states a + /// configuration is. This only checks if the configuration satisfies + /// the constraints. Instead, use the class GripperStateSelector. + virtual bool contains(const Configuration_t config) const; + + protected: + typedef hpp::core::ConstraintSet ConstraintSet; + + private: + /// List of possible motions from this state (i.e. the outgoing + /// vertices). + std::vector<GripperTransition*> neighbors_; + + /// Set of constraints to be statisfied. + ConstraintSet* constraints_; + + /// A selector that will implement the selection of the next state. + GripperStateSelector* selector_; + }; // class GripperState + } // namespace graph + } // namespace manipulation +} // namespace hpp + +#endif // HPP_MANIPULATION_GRAPH_GRIPPER_STATE_HH diff --git a/include/hpp/manipulation/graph/gripper-transition.hh b/include/hpp/manipulation/graph/gripper-transition.hh new file mode 100644 index 00000000..d49bfcf0 --- /dev/null +++ b/include/hpp/manipulation/graph/gripper-transition.hh @@ -0,0 +1,67 @@ +// Copyright (c) 2014, LAAS-CNRS +// Authors: Joseph Mirabel (joseph.mirabel@laas.fr) +// +// This file is part of hpp-manipulation. +// hpp-manipulation is free software: you can redistribute it +// and/or modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation, either version +// 3 of the License, or (at your option) any later version. +// +// hpp-manipulation is distributed in the hope that it will be +// useful, but WITHOUT ANY WARRANTY; without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Lesser Public License for more details. You should have +// received a copy of the GNU Lesser General Public License along with +// hpp-manipulation. If not, see <http://www.gnu.org/licenses/>. + +#ifndef HPP_MANIPULATION_GRAPH_GRIPPER_TRANSITION_HH +# define HPP_MANIPULATION_GRAPH_GRIPPER_TRANSITION_HH + +#include <hpp/core/constraints-set.hh> + +#include "hpp/manipulation/fwd.hh" +#include "hpp/manipulation/graph/gripper-state.hh" + +namespace hpp { + namespace manipulation { + namespace graph { + /// Transition between states of a gripper. + /// + /// Vertices of the graph of constraints. + class HPP_MANIPULATION_DLLAPI GripperTransition + { + public: + /// Projector to project onto the same leaf as config. + /// \return The initialized projector. + /// \param config Configuration that will initialize the projector. + ConfigProjector* configurationProjector(model::Configuration_t config); + + /// Projector to project a path. + /// \return The initialized projector. + /// \param config Configuration that will initialize the projector. + ConfigProjector* pathProjector(model::Configuration_t config); + + protected: + typedef hpp::core::ConstraintSet ConstraintSet; + typedef hpp::core::ConfigProjector ConfigProjector; + + private: + /// The two ends of the transition. + GripperState* startState, endState; + + /// Set of constraints to be statisfied. + ConstraintSet* constraints_; + + /// Projectors ensuring that a path between q_near and q_proj is + /// valid regarding the manipulation rules. + ConfigProjector* configurationProjector_; + + /// Projectors ensuring that a path between two configurations in + /// the same leaf lies in the leaf. + ConfigProjector* pathProjector_; + }; // class GripperState + } // namespace graph + } // namespace manipulation +} // namespace hpp + +#endif // HPP_MANIPULATION_GRAPH_GRIPPER_TRANSITION_HH -- GitLab