diff --git a/CMakeLists.txt b/CMakeLists.txt index bca6860a52e449e9b5bfeabe67eabee3461bd178..1d59f0020c8a1d8c7379806261d09bc117934edf 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 0000000000000000000000000000000000000000..602a88dc5841d99e1e574598d8d039c240df269b --- /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 0000000000000000000000000000000000000000..9a23a6fca45986cad94074170c8c9364e2038087 --- /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 0000000000000000000000000000000000000000..d49bfcf080b17d4ec8fc7550bc472152e3571814 --- /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