File: MultiBodyNameMap.hpp

package info (click to toggle)
bullet 2.87%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 14,272 kB
  • sloc: cpp: 204,241; ansic: 12,100; lisp: 12,017; python: 593; makefile: 136; sh: 8
file content (54 lines) | stat: -rw-r--r-- 1,893 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef MULTIBODYNAMEMAP_HPP_
#define MULTIBODYNAMEMAP_HPP_

#include "BulletInverseDynamics/IDConfig.hpp"
#include <string>
#include <map>

namespace btInverseDynamics {

/// \brief The MultiBodyNameMap class
/// Utility class that stores a maps from body/joint indices to/from body and joint names
class MultiBodyNameMap {
public:
    MultiBodyNameMap();
    /// add a body to the map
    /// @param index of the body
    /// @param name name of the body
    /// @return 0 on success, -1 on failure
    int addBody(const int index, const std::string& name);
    /// add a joint to the map
    /// @param index of the joint
    /// @param name name of the joint
    /// @return 0 on success, -1 on failure
    int addJoint(const int index, const std::string& name);
    /// get body name from index
    /// @param index of the body
    /// @param body_name name of the body
    /// @return 0 on success, -1 on failure
    int getBodyName(const int index, std::string* name) const;
    /// get joint name from index
    /// @param index of the joint
    /// @param joint_name name of the joint
    /// @return 0 on success, -1 on failure
    int getJointName(const int index, std::string* name) const;
    /// get body index from name
    /// @param index of the body
    /// @param name name of the body
    /// @return 0 on success, -1 on failure
    int getBodyIndex(const std::string& name, int* index) const;
    /// get joint index from name
    /// @param index of the joint
    /// @param name name of the joint
    /// @return 0 on success, -1 on failure
    int getJointIndex(const std::string& name, int* index) const;

private:
    std::map<int, std::string> m_index_to_joint_name;
    std::map<int, std::string> m_index_to_body_name;

    std::map<std::string, int> m_joint_name_to_index;
    std::map<std::string, int> m_body_name_to_index;
};
}
#endif  // MULTIBODYNAMEMAP_HPP_