LCOV - code coverage report
Current view: top level - include/ros_end_effector/GraspingActions - ActionTrig.h (source / functions) Hit Total Coverage
Test: main_coverage.info Lines: 1 1 100.0 %
Date: 2021-10-05 16:55:17 Functions: 3 4 75.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_ACTIONTRIG_H
      20             : #define __ROSEE_ACTIONTRIG_H
      21             : 
      22             : #include <ros_end_effector/GraspingActions/ActionPrimitive.h>
      23             : #include <yaml-cpp/yaml.h>
      24             : #include <iostream>
      25             : 
      26             : namespace ROSEE {
      27             : 
      28             : /**
      29             :  * @brief The action of moving some joints (see later) of a single finger in a full clousure position 
      30             :  * towards the palm. 
      31             :  * The action is unique (joints involved in a certain position: the bound) so \ref maxStoredActionStates == 1 always
      32             :  * Described by:
      33             :  *  - a tip (that is inside \ref fingersInvolved ): the tip of the finger that is involved in the action. So \ref nFingersInvolved == 1
      34             :  *  - JointStates position: which set the joints of the finger to a bound to make the finger closes, 
      35             :  *    and all the other non-involved joints to zero
      36             :  *  - Optional info \ref type (even if is a member of the base class, here is particular). The Trig, TipFlex
      37             :  *    and FingFlex have indentical structure, so ther is no necessity to create different classes, but necessity of only
      38             :  *    discriminate the objects using the \ref Type.
      39             :  * 
      40             :  * Actually, there are 3 types of action for this class
      41             :  *  - Trig: The action of fully closing a finger towards the parlm 
      42             :  *      (i.e. all joints of a finger set to respective bounds)
      43             :  *  - TipFlex: The action of fully closing the last part of finger, maintaining the proximal phalanges still
      44             :  *      (i.e. the last actuated joint of a finger set to its bound)
      45             :  *  - FingFlex: The action of fully closing the first part of a finger, maintaing the distal phalanges still, 
      46             :  *      like moving a human finger maintaining it right
      47             :  *      (i.e. the first actuated joint of a finger set to its bound)
      48             :  * For each tip:
      49             :  *   note that having a Trig does not mean that we have also the tip and the fing flex, because for them at least
      50             :  *   2 actuated joint (not continuos) in the finger must exist.
      51             :  *   If exist a TipFlex, also a FingFlex exist, and viceversa. If they exist, also a trig exist
      52             :  *   The "sum" of TipFlex and "FingFlex" is equal to the Trig only if the number of actuated not continuos joint
      53             :  *   in the finger is 2
      54             :  * 
      55             :  * @todo instead of tip , use the finger name for the Trig (i.e. the defined srdf group).
      56             :  * 
      57             :  * @note We have to understand the direction of joints to make the finger full close. Because full close position
      58             :  * can be linked to both lower or upper bound of each joint involved. 
      59             :  * The method to solve this is to go in the max range of the joint, because usually a finger has more motion
      60             :  * towards the palm respect the opposite (like humans). We consider the default joint pos to 0.
      61             :  * @warning so, take care of joint limits: they must include the 0. Has it sense to have joint limits both
      62             :  * positive or both negative (not including the 0) ?
      63             :  */
      64        3365 : class ActionTrig : public ActionPrimitive 
      65             : {
      66             : 
      67             : public:
      68             :     
      69             :     typedef std::map < std::string, ActionTrig > Map;
      70             : 
      71             :     ActionTrig (std::string actionName, ActionPrimitive::Type);
      72             :     ActionTrig (std::string actionName, ActionPrimitive::Type, std::string tip, JointPos);
      73             :     
      74             :     /** 
      75             :      * @brief Overriden get from the pure virtual function of the base class \ref ActionPrimitive 
      76             :      * The signature must be equal, even if here we have set and vector of only one element. For this class
      77             :      * this function simply return a vector which contain a single element. 
      78             :      */
      79             :     std::vector < JointPos > getAllJointPos() const override;
      80             :     
      81             :     /**
      82             :      * @brief Necessary method to know the key used by the maps which store all the Actions of one type. Used by \ref YamlWorker
      83             :      * @return for this class, it return the finger name, inserted in a single-element set because father signature say so
      84             :      */
      85             :     std::set < std::string> getKeyElements () const override;
      86             : 
      87             :     
      88             :     /** 
      89             :      * @brief Overriden get from the pure virtual function of the base class \ref Action 
      90             :      */
      91             :     JointPos getJointPos () const override;
      92             :     void setJointPos (JointPos);
      93             : 
      94             :     /** 
      95             :      * @brief Specific method of trig to simply return a string instead of the full vector \ref fingersInvolved that in this case 
      96             :      * contains only one element
      97             :      */
      98             :     std::string getFingerInvolved () const;
      99             :     void setFingerInvolved ( std::string );
     100             : 
     101             :     // we are ok with the default functions of the base class ActionPrimitive
     102             :     //void printAction () const override;
     103             :     //void emitYaml ( YAML::Emitter&) override;
     104             :     bool fillFromYaml( YAML::const_iterator yamlIt ) override;
     105             :     
     106             : private:
     107             :     JointPos jointPos;
     108             : };
     109             : 
     110             : }
     111             : 
     112             : #endif // __ROSEE_ACTIONTRIG_H

Generated by: LCOV version 1.13