Aikido
util.hpp
Go to the documentation of this file.
1 #ifndef AIKIDO_CONTROL_UTIL_HPP_
2 #define AIKIDO_CONTROL_UTIL_HPP_
3 
4 #include <set>
5 
6 #include <dart/dynamics/DegreeOfFreedom.hpp>
7 #include <dart/dynamics/MetaSkeleton.hpp>
8 
9 namespace aikido {
10 namespace control {
11 
13 inline std::vector<std::string> skeletonToDofNames(
14  dart::dynamics::ConstMetaSkeletonPtr skeleton)
15 {
16  std::vector<std::string> names;
17  if (!skeleton)
18  return names;
19  names.reserve(skeleton->getNumDofs());
20  for (const auto& dof : skeleton->getDofs())
21  {
22  names.push_back(dof->getName());
23  }
24  return names;
25 }
26 
29 inline std::set<ExecutorType> concatenateTypes(
30  std::set<ExecutorType> first, std::set<ExecutorType> second)
31 {
32  std::set<ExecutorType> ret;
33  ret.insert(first.begin(), first.end());
34  ret.insert(second.begin(), second.end());
35  return ret;
36 }
37 
40 template <typename T>
41 inline T checkNull(T obj)
42 {
43  if (!obj)
44  {
45  throw std::invalid_argument("Object is null.");
46  }
47  return obj;
48 }
49 
50 } // namespace control
51 } // namespace aikido
52 
53 #endif // AIKIDO_CONTROL_UTIL_HPP_
aikido
Format of serialized trajectory in YAML.
Definition: algorithm.hpp:4
aikido::control::checkNull
T checkNull(T obj)
Check if Ptr is null Useful for initializer Lists.
Definition: util.hpp:41
aikido::control::concatenateTypes
std::set< ExecutorType > concatenateTypes(std::set< ExecutorType > first, std::set< ExecutorType > second)
Concatenate two sets of ExecutorTypes Useful for initializer-list constructors.
Definition: util.hpp:29
aikido::control::skeletonToDofNames
std::vector< std::string > skeletonToDofNames(dart::dynamics::ConstMetaSkeletonPtr skeleton)
Get joint names from skeleton for Executor intiialization.
Definition: util.hpp:13