LCOV - code coverage report
Current view: top level - include/end_effector/GraspingActions - ActionPrimitive.h (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 1 1 100.0 %
Date: 2022-06-06 13:34:00 Functions: 1 2 50.0 %

          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_ACTIONPRIMITIVE_H
      20             : #define __ROSEE_ACTIONPRIMITIVE_H
      21             : 
      22             : #include <set>
      23             : #include <string>
      24             : #include <map>
      25             : #include <vector>
      26             : #include <iostream>
      27             : 
      28             : #include <end_effector/GraspingActions/Action.h>
      29             : 
      30             : #include <yaml-cpp/yaml.h>
      31             : 
      32             : 
      33             : namespace ROSEE{
      34             : 
      35             : /**
      36             :  * @brief Virtual class, Base of all the primitive actions. It has some implemented functions that a 
      37             :  * derived class can use, if you don't want to override to make them more action-specific.
      38             :  * All the primitives are defined by:
      39             :  *  - A set containing a fixed number (\ref nFingersInvolved ) of links/handparts, which are involved in
      40             :  *    the action. (e.g. two fingertips for a pinch)
      41             :  *  - JointStates position: hand configuration for which the 100% action happens. This is a member that
      42             :  *    all the derived class must have, but it can be store as it is (e.g. trigger) but also in a set 
      43             :  *    (if \ref maxStoredActionStates > 1) or in a set with some other info linked (e.g. in the pinch we have a
      44             :  *    pair JointPos - Contact stored in the set). So it is not a member of this base class
      45             :  *  - Optional info about the action (e.g. a moveit Contact class for the pinch). Being optional, 
      46             :  *    we don't have a member for this in this base class
      47             :  */
      48             : class ActionPrimitive : public Action
      49             : {
      50             :     
      51             : public:
      52             :     
      53             :     typedef std::shared_ptr<ActionPrimitive> Ptr;
      54             :     typedef std::shared_ptr<const ActionPrimitive> ConstPtr;
      55             : 
      56             :     /** 
      57             :      * @brief Enum useful to discriminate each primitive action when, for example, we want to parse a file 
      58             :      * @remind if you change this enum, change also the ROSEEControl.msg accordingly
      59             :      */
      60             :     enum Type {PinchTight, PinchLoose, MultiplePinchTight, Trig, TipFlex, FingFlex, SingleJointMultipleTips, None};
      61             :     /* destructor of base must be virtual */
      62       17640 :     virtual ~ActionPrimitive() {};
      63             : 
      64             :     /* virtual and not getters */
      65             :     Type getPrimitiveType() const;
      66             :     unsigned int getMaxStoredActionStates() const;
      67             :     unsigned int getnFingersInvolved() const;
      68             :     
      69             :     /**
      70             :      * @brief Depending on the primitive, we can use different "keys" to take info from yaml file when parsing
      71             :      * for example, trig and pinches are selected through fingersInvolved, while ActionSingleJointMultipleTips uses the joint name.
      72             :      * So each derived class must override this info, which for now is used only in \ref YamlWorker::parseYamlPrimitive() and also by map handler to get the primitive, also on send action test
      73             :      */
      74             :     virtual std::set < std::string> getKeyElements () const = 0;
      75             :     
      76             :     void setJointsInvolvedCount (ROSEE::JointsInvolvedCount jointsInvolvedCount ) ;    
      77             :     /* overridable functions, if we want to make them more action-specific*/
      78             :     virtual void emitYaml ( YAML::Emitter& ) const override;
      79             : 
      80             : protected:
      81             :     
      82             :     ActionPrimitive ( std::string name, unsigned int maxStoredActionStates, Type type );
      83             :  
      84             :     /**
      85             :      * @brief Protected costructor: object creable only by derived classes.
      86             :      * There is no default costructor (without arguments) because we want to set always these members
      87             :      */
      88             :     ActionPrimitive( std::string name, unsigned int nFingersInvolved, unsigned int maxStoredActionStates,
      89             :         Type type );
      90             :     
      91             :     /* e.g. two tips for the pinch*/
      92             :     unsigned int nFingersInvolved;
      93             :     
      94             :     /* the max number of action for each linksInvolved set that we want to store */
      95             :     const unsigned int maxStoredActionStates;
      96             :     
      97             :     const Type primitiveType;
      98             :         
      99             : 
     100             :     
     101             : };
     102             : 
     103             : /**
     104             :  * To print the action type enum as the real name (eg primitive) and not as the enum number
     105             :  * REmember to add here if new type are implemented
     106             :  */
     107             : 
     108             : //std::ostream& operator<<(std::ostream& out, const ActionPrimitive::Type type);
     109             : 
     110             : }
     111             : 
     112             : #endif // __ROSEE_ACTIONPRIMITIVE_H

Generated by: LCOV version 1.14