DesignerTrajectoryHolder.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2015-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package ArmarXGuiPlugins::RobotTrajectoryDesigner::Manager
19  * @author Luca Quaer
20  * @date 2018
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #ifndef DESIGNERTRAJECTORYHOLDER_H
26 #define DESIGNERTRAJECTORYHOLDER_H
27 
28 #include <map>
29 
30 #include <VirtualRobot/RobotNodeSet.h>
31 
33 #include "../Model/DesignerTrajectory.h"
34 
35 
36 //using DesignerTrajectoryPtr = std::shared_ptr<armarx::DesignerTrajectory>;
37 
38 namespace armarx
39 {
40  /**
41  * @brief The DesignerTrajectoryHolder class enables creating, deleting and getting
42  * DesignerTrajectorManagers, which are unambiguously assigned to a RobotNodeSet.
43  *
44  * @see DesignerTrajectoryManager
45  */
46 
48  {
49  private:
50  ////////////////////////////////////////////////////////////////////////////////////////////
51  /// Attributes
52  ////////////////////////////////////////////////////////////////////////////////////////////
53  /*struct mapComparator
54  {
55  bool operator()(VirtualRobot::RobotNodeSetPtr lhs, VirtualRobot::RobotNodeSetPtr rhs) const
56  {
57  return lhs->getName().compare(rhs->getName());
58  }
59  };*/
60 
61  std::map < std::string, DesignerTrajectoryManagerPtr>
62  designerTrajectories;
63  EnvironmentPtr environment;
64 
65 
66  TrajectoryPtr mergeTrajectories(unsigned int fps);
67  public:
68  ////////////////////////////////////////////////////////////////////////////////////////////
69  /// Constructor(s)
70  ////////////////////////////////////////////////////////////////////////////////////////////
72 
73  ////////////////////////////////////////////////////////////////////////////////////////////
74  /// Public functions
75  ////////////////////////////////////////////////////////////////////////////////////////////
76  /**
77  * @brief If the given RobotNodeSet is not already assigned to a DesignerTrajectoryManager
78  * a DesignerTrajectoryManager is created and assigned to this RobotNodeSet,
79  * else nothing happens.
80  * @param rns RobotNodeSet
81  * @return true, if the given RobotNodeSet was not already assigned to a
82  * DesignerTrajectoryManager;
83  * false, if the given RobotNodeSet was already assigned to a
84  * DesignerTrajectoryManager.
85  */
86  bool createDesignerTrajectoryManager(std::string rnsName);
87 
88  /**
89  * @brief Deletes the DesignerTrajectoryManager assigned to the given RobotNodeSet.
90  * @param rns RobotNodeSet
91  * @return true, if DesignerTrajectoryManager existed and was successfully deleted;
92  * false, if no DesignerTrajectoryManager was assigned to the given RobotNodeSet
93  */
94  bool deleteDesignerTrajectoryManager(std::string rnsName);
95 
96  /**
97  * @brief Returns the DesignerTrajectoryManager assigned to the given RobotNodeSet.
98  * @param rns RobotNodeSet
99  * @return DesignerTrajectoryManager assigned to the given RobotNodeSet.
100  */
102 
103  //bool import(const DesignerTrajectory& designerTrajectory, bool force);
104  /**
105  * @brief Imports the given DesignerTrajectory.
106  *
107  * The DesignerTrajectory holds a RobotNodeSet. If this RobotNodeSet is not assigned to
108  * a DesignerTrajectoryManager then a new DesignerTrajectoryManager is created with the
109  * given DesignerTrajectory (return true).
110  * If the DesignerTrajectory's RobotNodeSet is already assigned to a
111  * DesignerTrajectoryManager there are two options:
112  * - If force is true (default), the existing DesignerTrajectoryManager gets overridden by a
113  * new DesignerTrajectoryManager created with the given DesignerTrajectory (return true).
114  * - If force is false, nothing happens (return false).
115  *
116  * @param designerTrajectory new DesignerTrajectory
117  * @param force Boolean indicating wheather to force the import or not
118  * @return (see detailed function description)
119  */
120  bool import(DesignerTrajectoryPtr designerTrajectory, bool force);
121 
122  /**
123  * @brief Checks if there is already a DesignerTrajectoryManager assigned to the given
124  * RobotNodeSet.
125  * @param rns RobotNodeSet
126  * @return true, if a DesignerTrajectoryManager assigned to the given RobotNodeSet exists;
127  * false, if no DesignerTrajectoryManager is assigned to the given RobotNodeSet
128  */
129  bool rnsExists(std::string rnsName);
130 
131  /**
132  * @brief Checks if the given RobotNodeSet is part of a RobotNodeSet to which a
133  * DesignerTrajectoryManager is assigned to
134  * @param rns RobotNodeSet
135  * @return true, if the given RobotNodeSet is part of a existing one;
136  * false, if the given RobotNodeSet is not part of a existing one
137  */
138  bool rnsIsPartOfExistingRns(std::string rnsName);
139 
140  /**
141  * @brief isInCollision Checks if the given collision models (active and body) collide
142  * for the jointangle configurations given in the trajectory
143  * @param t trajectory combining all trajectories represented by the managers
144  * @param activeColModelName the collision model of the RobotNodeSet which gets manipulated
145  * @param bodyColModelsNames the collision models to check against
146  * @param fps resolution for collision checking in frames per second
147  * @return true in case of a collision
148  */
149  bool isInCollision(std::string activeColModelName,
150  std::vector<std::string> bodyColModelsNames,
151  unsigned int fps);
152 
153  };
154 
155  ////////////////////////////////////////////////////////////////////////////////////////////////
156  /// Typedefinitions
157  ////////////////////////////////////////////////////////////////////////////////////////////////
158  using DesignerTrajectoryHolderPtr = std::shared_ptr<armarx::DesignerTrajectoryHolder>;
159 }
160 
161 #endif // DESIGNERTRAJECTORYHOLDER_H
armarx::DesignerTrajectoryHolder::rnsExists
bool rnsExists(std::string rnsName)
Checks if there is already a DesignerTrajectoryManager assigned to the given RobotNodeSet.
Definition: DesignerTrajectoryHolder.cpp:129
armarx::DesignerTrajectoryHolderPtr
std::shared_ptr< armarx::DesignerTrajectoryHolder > DesignerTrajectoryHolderPtr
Typedefinitions.
Definition: DesignerTrajectoryHolder.h:158
armarx::DesignerTrajectoryHolder::deleteDesignerTrajectoryManager
bool deleteDesignerTrajectoryManager(std::string rnsName)
Deletes the DesignerTrajectoryManager assigned to the given RobotNodeSet.
Definition: DesignerTrajectoryHolder.cpp:66
IceInternal::Handle< Trajectory >
armarx::EnvironmentPtr
std::shared_ptr< Environment > EnvironmentPtr
Definition: Environment.h:29
armarx::DesignerTrajectoryHolder::DesignerTrajectoryHolder
DesignerTrajectoryHolder(EnvironmentPtr environment)
Constructor(s)
Definition: DesignerTrajectoryHolder.cpp:36
armarx::DesignerTrajectoryHolder::isInCollision
bool isInCollision(std::string activeColModelName, std::vector< std::string > bodyColModelsNames, unsigned int fps)
isInCollision Checks if the given collision models (active and body) collide for the jointangle confi...
Definition: DesignerTrajectoryHolder.cpp:186
armarx::DesignerTrajectoryHolder::createDesignerTrajectoryManager
bool createDesignerTrajectoryManager(std::string rnsName)
Public functions.
Definition: DesignerTrajectoryHolder.cpp:45
armarx::DesignerTrajectoryHolder
The DesignerTrajectoryHolder class enables creating, deleting and getting DesignerTrajectorManagers,...
Definition: DesignerTrajectoryHolder.h:47
armarx::DesignerTrajectoryHolder::getTrajectoryManager
DesignerTrajectoryManagerPtr getTrajectoryManager(std::string rnsName)
Returns the DesignerTrajectoryManager assigned to the given RobotNodeSet.
Definition: DesignerTrajectoryHolder.cpp:90
armarx::DesignerTrajectoryManagerPtr
std::shared_ptr< armarx::DesignerTrajectoryManager > DesignerTrajectoryManagerPtr
Typedefinitions.
Definition: DesignerTrajectoryManager.h:399
armarx::DesignerTrajectoryPtr
std::shared_ptr< DesignerTrajectory > DesignerTrajectoryPtr
Definition: DesignerTrajectory.h:165
armarx::DesignerTrajectoryHolder::rnsIsPartOfExistingRns
bool rnsIsPartOfExistingRns(std::string rnsName)
Checks if the given RobotNodeSet is part of a RobotNodeSet to which a DesignerTrajectoryManager is as...
Definition: DesignerTrajectoryHolder.cpp:144
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
DesignerTrajectoryManager.h