Drake
RigidBodyTreeAliasGroups< T > Class Template Reference

This class provides a way to create aliases to groups of RigidBody or DrakeJoint objects. More...

#include <drake/multibody/rigid_body_tree_alias_groups.h>

Collaboration diagram for RigidBodyTreeAliasGroups< T >:
[legend]

Public Member Functions

 RigidBodyTreeAliasGroups (const RigidBodyTree< T > *tree)
 Constructor for RigidBodyTreeAliasGroups. More...
 
void LoadFromFile (const std::string &path)
 Parses body groups and joint groups from a config file. More...
 
void AddBodyGroup (const std::string &group_name, const std::vector< std::string > &body_names)
 Creates a body group named group_name whose elements have names from body_names. More...
 
void AddJointGroup (const std::string &group_name, const std::vector< std::string > &joint_names)
 Creates a joint group named group_name whose elements have names from joint_names. More...
 
bool has_body_group (const std::string &group_name) const
 
bool has_joint_group (const std::string &group_name) const
 
bool has_position_group (const std::string &group_name) const
 
bool has_velocity_group (const std::string &group_name) const
 
const std::vector< const RigidBody< T > * > & get_body_group (const std::string &group_name) const
 Returns the body group identified by group_name. More...
 
const RigidBody< T > * get_body (const std::string &group_name) const
 Returns the body aliased by group_name. More...
 
const std::vector< const DrakeJoint * > & get_joint_group (const std::string &group_name) const
 Returns the joint group identified by group_name. More...
 
const std::vector< int > & get_position_group (const std::string &group_name) const
 Returns the generalized position indices associated with the joint group identified by group_name. More...
 
const std::vector< int > & get_velocity_group (const std::string &group_name) const
 Returns the generalized velocity indices associated with the joint group identified by group_name. More...
 
const std::unordered_map< std::string, std::vector< const RigidBody< T > * > > & get_body_groups () const
 
const std::unordered_map< std::string, std::vector< const DrakeJoint * > > & get_joint_groups () const
 
const std::unordered_map< std::string, std::vector< int > > & get_position_groups () const
 
const std::unordered_map< std::string, std::vector< int > > & get_velocity_groups () const
 
const RigidBodyTree< T > & get_tree () const
 
Does not allow copy, move, or assignment
 RigidBodyTreeAliasGroups (const RigidBodyTreeAliasGroups &)=delete
 
RigidBodyTreeAliasGroupsoperator= (const RigidBodyTreeAliasGroups &)=delete
 
 RigidBodyTreeAliasGroups (RigidBodyTreeAliasGroups &&)=delete
 
RigidBodyTreeAliasGroupsoperator= (RigidBodyTreeAliasGroups &&)=delete
 

Static Public Attributes

static constexpr char kBodyGroupsKeyword [] = "body_groups"
 
static constexpr char kJointGroupsKeyword [] = "joint_groups"
 

Detailed Description

template<typename T>
class RigidBodyTreeAliasGroups< T >

This class provides a way to create aliases to groups of RigidBody or DrakeJoint objects.

The creation of these groups can be done either programmatically or via an AliasGroups protobuf config file.

For example, suppose we have a RigidBodyTree with 6 links named [link0 ~ link5], and 6 joints [base, joint0 ~ joint4]. We can "rename" link0 to be robot_base by creating a body group named robot_base with one entry link0, and accessing the first element in this body group. Alias names for groups of joints can also be similarly created. Furthermore, the corresponding indices to the generalized position and velocity are computed and accessible through an instance of this class.

Body groups and joint groups are independent, so a body group can have the same name of a joint group. However, all body groups have unique group names, and so do all joint groups. For each body or joint group, its members are unique. A body or joint can belong to many groups. When adding new members to an existing group, the new members will be appended to the existing group.

Constructor & Destructor Documentation

RigidBodyTreeAliasGroups ( const RigidBodyTree< T > *  tree)
inlineexplicit

Constructor for RigidBodyTreeAliasGroups.

Parameters
treePointer to the RigidBodyTree, which is aliased internally. So tree needs to outlive this object.

Member Function Documentation

void AddBodyGroup ( const std::string &  group_name,
const std::vector< std::string > &  body_names 
)

Creates a body group named group_name whose elements have names from body_names.

If a group named group_name already exists, body_names is appended to the end of the existing group. The resulting group will not have duplicated elements.

Parameters
group_nameName of the body group, can be arbitrary.
body_namesVector of body names, must be present in the RigidBodyTree passed to the constructor.
Exceptions
std::logic_errorif elements in body_names cannot be found in the RigidBodyTree referenced at construction time.

Here is the call graph for this function:

Here is the caller graph for this function:

void AddJointGroup ( const std::string &  group_name,
const std::vector< std::string > &  joint_names 
)

Creates a joint group named group_name whose elements have names from joint_names.

If a group named group_name already exists, joint_names is appended to the end of the existing group. The resulting group will not have duplicated elements.

Parameters
group_nameName of the joint group, can be arbitrary.
joint_namesVector of joint names, must be present in the RigidBodyTree passed to the constructor.
Exceptions
std::logic_errorif elements in joint_names cannot be found in the RigidBodyTree referenced at construction time.

Here is the call graph for this function:

Here is the caller graph for this function:

const RigidBody<T>* get_body ( const std::string &  group_name) const
inline

Returns the body aliased by group_name.

The body group referenced by group_name must contain exactly one element.

Here is the caller graph for this function:

const std::vector<const RigidBody<T>*>& get_body_group ( const std::string &  group_name) const
inline

Returns the body group identified by group_name.

Exceptions
std::out_of_rangeif group_name is not found.

Here is the caller graph for this function:

const std::unordered_map<std::string, std::vector<const RigidBody<T>*> >& get_body_groups ( ) const
inline
const std::vector<const DrakeJoint*>& get_joint_group ( const std::string &  group_name) const
inline

Returns the joint group identified by group_name.

Exceptions
std::out_of_rangeif group_name is not found.
const std::unordered_map<std::string, std::vector<const DrakeJoint*> >& get_joint_groups ( ) const
inline
const std::vector<int>& get_position_group ( const std::string &  group_name) const
inline

Returns the generalized position indices associated with the joint group identified by group_name.

Exceptions
std::out_of_rangeif group_name is not found.
const std::unordered_map<std::string, std::vector<int> >& get_position_groups ( ) const
inline
const RigidBodyTree<T>& get_tree ( ) const
inline

Here is the caller graph for this function:

const std::vector<int>& get_velocity_group ( const std::string &  group_name) const
inline

Returns the generalized velocity indices associated with the joint group identified by group_name.

Exceptions
std::out_of_rangeif group_name is not found.

Here is the caller graph for this function:

const std::unordered_map<std::string, std::vector<int> >& get_velocity_groups ( ) const
inline
bool has_body_group ( const std::string &  group_name) const
inline

Here is the caller graph for this function:

bool has_joint_group ( const std::string &  group_name) const
inline
bool has_position_group ( const std::string &  group_name) const
inline
bool has_velocity_group ( const std::string &  group_name) const
inline

Here is the caller graph for this function:

void LoadFromFile ( const std::string &  path)

Parses body groups and joint groups from a config file.

Parameters
configPath to text-format AliasGroups file.
Exceptions
std::logic_errorif body_namei or joint_namei cannot be found in the RigidBodyTree provided at construction time.
std::runtime_errorif joint names or body names cannot be parsed correctly.

Here is the call graph for this function:

Here is the caller graph for this function:

RigidBodyTreeAliasGroups& operator= ( RigidBodyTreeAliasGroups< T > &&  )
delete
RigidBodyTreeAliasGroups& operator= ( const RigidBodyTreeAliasGroups< T > &  )
delete

Member Data Documentation

constexpr char kBodyGroupsKeyword = "body_groups"
static
constexpr char kJointGroupsKeyword = "joint_groups"
static

The documentation for this class was generated from the following files: