LCOV - code coverage report
Current view: top level - include/ros_end_effector/GraspingActions - ActionComposed.h (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 1 1 100.0 %
Date: 2021-10-05 16:55:17 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (C) 2020 IIT-HHCM
       3             :  * Author: Davide Torielli
       4             :  * email:  davide.torielli@iit.it
       5             :  *
       6             :  * Licensed under the Apache License, Version 2.0 (the "License");
       7             :  * you may not use this file except in compliance with the License.
       8             :  * You may obtain a copy of the License at
       9             :  *
      10             :  *     http://www.apache.org/licenses/LICENSE-2.0
      11             :  *
      12             :  * Unless required by applicable law or agreed to in writing, software
      13             :  * distributed under the License is distributed on an "AS IS" BASIS,
      14             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      15             :  * See the License for the specific language governing permissions and
      16             :  * limitations under the License.
      17             :  */
      18             : 
      19             : #ifndef __ROSEE_ACTIONCOMPOSED_H
      20             : #define __ROSEE_ACTIONCOMPOSED_H
      21             : 
      22             : #include <vector>
      23             : #include <string>
      24             : #include <ros_end_effector/GraspingActions/ActionGeneric.h>
      25             : #include <ros_end_effector/Utils.h>
      26             : #include <yaml-cpp/yaml.h>
      27             : #include <memory>
      28             : 
      29             : 
      30             : namespace ROSEE{
      31             : 
      32             : /**
      33             :  * @brief A ActionComposed, which is formed by one or more Primitives (or even other composed).
      34             :  * It is useful for example to create an action that grasp only with bending the tips (e.g. to take a dish from above) 
      35             :  * If the ActionComposed has the boolean value \ref independent to true, it means that include indipendent sub-actions, 
      36             :  * so, each joint is used by at maximum by ONLY ONE of the sub-action inside.
      37             :  * In this case the \ref jointsInvolvedCount will contain only 0 or 1 values.
      38             :  * If the ActionComposed is not \ref independent, each joint position is calculated as the mean of all the joint 
      39             :  * position of the contained sub-actions that uses that joint. So each mean can include different primitives, so we used the
      40             :  * \ref jointsInvolvedCount vector to store the number of sub action that use each joint.
      41             :  * 
      42             :  * @todo A removeAction function? difficult to implement, and useless?
      43             :  */
      44         120 : class ActionComposed : public ActionGeneric
      45             : {
      46             :     
      47             : public: 
      48             :     typedef std::shared_ptr<ActionComposed> Ptr;
      49             :     typedef std::shared_ptr<const ActionComposed> ConstPtr;
      50             :     
      51             :     ActionComposed();
      52             :     ActionComposed(std::string name);
      53             :     ActionComposed(std::string name, bool independent);
      54             :     /** @brief Copy costructor 
      55             :      */
      56             :     ActionComposed (const ActionComposed &other);
      57             : 
      58             :     
      59             :     /**
      60             :      * @brief
      61             :      * @return unsigned int the number of the actions that compose this one
      62             :      */
      63             :     unsigned int numberOfInnerActions () const;
      64             :     
      65             :     /**
      66             :      * @brief
      67             :      * @return bool true if this action must contain only independent primitives
      68             :      */
      69             :     bool isIndependent () const;
      70             :     
      71             :     /**
      72             :      * @brief
      73             :      * @return std::vector <std::string> all the names that compose this action
      74             :      */
      75             :     std::vector <std::string> getInnerActionsNames() const ;
      76             :     
      77             :     /**
      78             :      * @brief Print info about this action (name, jointpos, inner actions names, and other)
      79             :      */
      80             :     virtual void print () const override;
      81             :     
      82             :     /**
      83             :      * @brief Emit info in a file with yaml format
      84             :      * @param out a YAML::Emitter& object to emit the infos
      85             :      */    
      86             :     virtual void emitYaml ( YAML::Emitter& out) const override;
      87             :     
      88             :     /**
      89             :      * @brief Fill the internal data with infos taken from yaml file. 
      90             :      * @param yamlIt a yamlt iterator to a node which has loaded the file
      91             :      * @return false if some error happened
      92             :      */
      93             :     virtual bool fillFromYaml(  YAML::const_iterator yamlIt ) override;
      94             :     
      95             :     /** 
      96             :      * @brief Function to add another action to this one. 
      97             :      * @param action The action to be added to the ActionComposed
      98             :      * @param jointPosScaleFactor How much scale the joint position values for the action to be inserted. Default to 1
      99             :      * @param jointPosIndex (default == 0) the wanted jointPos or \p action to insert. Error the index is greater than the number
     100             :      *      of joint pos in the \p action. First element has index 0. 
     101             :      * @return False if the ActionComposed is \ref independent and we try to add an action that is dependent from one of the already present
     102             :      */
     103             :     virtual bool sumAction ( ROSEE::Action::Ptr action , double jointPosScaleFactor = 1.0, unsigned int jointPosIndex = 0 );
     104             :     
     105             :     /**
     106             :      * @brief Check if the action composed is empty
     107             :      * 
     108             :      * @return true if empty, false otherwise
     109             :      */
     110             :     bool empty();
     111             :     
     112             : protected:
     113             :     std::vector < std::string > innerActionsNames;
     114             :     unsigned int nInnerActions;
     115             :         
     116             :     bool independent; //true if each primitive must set different joint states
     117             : 
     118             :     bool checkIndependency ( ROSEE::Action::Ptr action );
     119             : 
     120             :     
     121             : };
     122             : }
     123             : 
     124             : #endif // __ROSEE_ACTIONCOMPOSED_H

Generated by: LCOV version 1.13