MultiBodyNameMap.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef MULTIBODYNAMEMAP_HPP_
  2. #define MULTIBODYNAMEMAP_HPP_
  3. #include "BulletInverseDynamics/IDConfig.hpp"
  4. #include <string>
  5. #include <map>
  6. namespace btInverseDynamics {
  7. /// \brief The MultiBodyNameMap class
  8. /// Utility class that stores a maps from body/joint indices to/from body and joint names
  9. class MultiBodyNameMap {
  10. public:
  11. MultiBodyNameMap();
  12. /// add a body to the map
  13. /// @param index of the body
  14. /// @param name name of the body
  15. /// @return 0 on success, -1 on failure
  16. int addBody(const int index, const std::string& name);
  17. /// add a joint to the map
  18. /// @param index of the joint
  19. /// @param name name of the joint
  20. /// @return 0 on success, -1 on failure
  21. int addJoint(const int index, const std::string& name);
  22. /// get body name from index
  23. /// @param index of the body
  24. /// @param body_name name of the body
  25. /// @return 0 on success, -1 on failure
  26. int getBodyName(const int index, std::string* name) const;
  27. /// get joint name from index
  28. /// @param index of the joint
  29. /// @param joint_name name of the joint
  30. /// @return 0 on success, -1 on failure
  31. int getJointName(const int index, std::string* name) const;
  32. /// get body index from name
  33. /// @param index of the body
  34. /// @param name name of the body
  35. /// @return 0 on success, -1 on failure
  36. int getBodyIndex(const std::string& name, int* index) const;
  37. /// get joint index from name
  38. /// @param index of the joint
  39. /// @param name name of the joint
  40. /// @return 0 on success, -1 on failure
  41. int getJointIndex(const std::string& name, int* index) const;
  42. private:
  43. std::map<int, std::string> m_index_to_joint_name;
  44. std::map<int, std::string> m_index_to_body_name;
  45. std::map<std::string, int> m_joint_name_to_index;
  46. std::map<std::string, int> m_body_name_to_index;
  47. };
  48. }
  49. #endif // MULTIBODYNAMEMAP_HPP_