File: MultiBodyNameMap.hpp

package info (click to toggle)
bullet 3.06%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,012 kB
  • sloc: cpp: 243,705; lisp: 12,017; ansic: 11,175; python: 626; makefile: 133; sh: 75
file content (55 lines) | stat: -rw-r--r-- 1,819 bytes parent folder | download | duplicates (3)
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
55
#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;
};
}  // namespace btInverseDynamics
#endif  // MULTIBODYNAMEMAP_HPP_