MultiBodyNameMap.hpp 1.8 KB

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