6#include <unordered_map>
68 const auto iter = m_index_map.find(name);
69 return (iter != m_index_map.end());
76 [[nodiscard]]
size_t size()
const
78 return m_index_map.size();
82 std::unordered_map<size_t, std::string> m_name_map;
83 std::unordered_map<std::string, size_t> m_index_map;
109 return m_bodies.
add(index, name);
120 return m_joints.
add(index, name);
172 return m_bodies.
size();
181 return m_joints.
size();
185 std::string m_robot_name;
199 const std::string existing_name =
get_name(index, name_err);
201 const size_t existing_index =
get_index(name, index_err);
205 m_index_map[name] = index;
206 m_name_map[index] = name;
209 (existing_name == name) &&
211 (existing_index == index))
226 if (
const auto iter = m_index_map.find(name); iter == m_index_map.end())
233 index = iter->second;
240 std::string name = {};
241 if (
const auto iter = m_name_map.find(index); iter == m_name_map.end())
Name map relating names to object indices.
Definition fsb_urdf_name_map.h:33
size_t get_index(const std::string &name, NameMapError &err) const
Get index of named object.
Definition fsb_urdf_name_map.h:223
NameMapError add(size_t index, const std::string &name)
Add named object with index.
Definition fsb_urdf_name_map.h:194
std::string get_name(size_t index, NameMapError &err) const
Get name of indexed object.
Definition fsb_urdf_name_map.h:238
size_t size() const
Get number of name-index pairs in map.
Definition fsb_urdf_name_map.h:76
bool name_exists(const std::string &name) const
Check if name exists in map.
Definition fsb_urdf_name_map.h:66
Name-index map of joints and bodies in rigid body tree.
Definition fsb_urdf_name_map.h:88
size_t get_num_joints() const
Get number of joints in map.
Definition fsb_urdf_name_map.h:179
void set_robot_name(const std::string &name)
Set robot name.
Definition fsb_urdf_name_map.h:96
size_t get_body_index(const std::string &name, NameMapError &err) const
Get index of body in tree.
Definition fsb_urdf_name_map.h:129
bool joint_exists(const std::string &name) const
Check if joint name is set in map.
Definition fsb_urdf_name_map.h:161
NameMapError add_joint(const size_t index, const std::string &name)
Definition fsb_urdf_name_map.h:118
NameMapError add_body(const size_t index, const std::string &name)
Definition fsb_urdf_name_map.h:107
size_t get_joint_index(const std::string &name, NameMapError &err) const
Get index of joint in body tree.
Definition fsb_urdf_name_map.h:141
bool body_exists(const std::string &name) const
Check if body name is set in map.
Definition fsb_urdf_name_map.h:151
size_t get_num_bodies() const
Get number of bodies in map.
Definition fsb_urdf_name_map.h:170
NameMapError
Name map errors.
Definition fsb_urdf_name_map.h:20
@ EXISTS
Joint or body already exists.
@ NOT_FOUND
Joint or body name not found.