Drake
WorldSimTreeBuilder< T > Class Template Reference

A helper class to construct robot world RigidBodyTree objects from model (URDF/SDF) files. More...

#include <drake/manipulation/util/world_sim_tree_builder.h>

Public Member Functions

 WorldSimTreeBuilder (bool compile_tree=true, std::unique_ptr< RigidBodyTree< T >> base_tree=nullptr)
 Constructs a WorldSimTreeBuilder object and specifies whether a call to any of the add model instance functions should compile the tree. More...
 
 ~WorldSimTreeBuilder ()
 
int AddFixedModelInstance (const std::string &model_name, const Eigen::Vector3d &xyz, const Eigen::Vector3d &rpy=Eigen::Vector3d::Zero())
 Adds a fixed model instance specified by its name, model_name, to the RigidBodyTree being built at the pose specified by position xyz and orientation rpy. More...
 
int AddFloatingModelInstance (const std::string &model_name, const Eigen::Vector3d &xyz, const Eigen::Vector3d &rpy=Eigen::Vector3d::Zero())
 Adds a floating model instance specified by its name, model_name, to the RigidBodyTree being built at the pose specified by position xyz and orientation rpy. More...
 
int AddModelInstanceToFrame (const std::string &model_name, std::shared_ptr< RigidBodyFrame< T >> weld_to_frame, const drake::multibody::joints::FloatingBaseType floating_base_type=drake::multibody::joints::kFixed)
 Adds a model instance specified by its model name, model_name, to the RigidBodyTree being built. More...
 
int AddModelInstanceToFrame (const std::string &model_name, const std::string &weld_to_body_name, int weld_to_body_model_instance_id, const std::string &frame_name, const Eigen::Isometry3d &X_BF, const drake::multibody::joints::FloatingBaseType floating_base_type)
 Adds a model instance specified by its model name, model_name, to the RigidBodyTree being built. More...
 
void AddGround ()
 Adds a flat terrain to the simulation. More...
 
 WorldSimTreeBuilder (const WorldSimTreeBuilder< T > &other)=delete
 
WorldSimTreeBuilderoperator= (const WorldSimTreeBuilder< T > &other)=delete
 
void StoreModel (const std::string &model_name, const std::string &absolute_model_path)
 Adds a model to the internal model database. More...
 
void StoreDrakeModel (const std::string &model_name, const std::string &model_path)
 Like StoreModel, but uses FindResourceOrThrow to search inside the drake resource search path. More...
 
std::unique_ptr< RigidBodyTree< T > > Build (void)
 Gets a unique pointer to the RigidBodyTree that was built. More...
 
const RigidBodyTree< T > & tree () const
 Returns the (not yet built) tree. More...
 
RigidBodyTree< T > * mutable_tree ()
 Returns a pointer to the (not yet built) mutable tree. More...
 
ModelInstanceInfo< Tget_model_info_for_instance (int id)
 
systems::CompliantContactModelParameters contact_model_parameters () const
 The compliant contact model parameters to use with the default material parameters; these values should be passed to the plant. More...
 
systems::CompliantMaterial default_contact_material () const
 

Detailed Description

template<typename T>
class drake::manipulation::util::WorldSimTreeBuilder< T >

A helper class to construct robot world RigidBodyTree objects from model (URDF/SDF) files.

Models (e.g., robots, objects for manipulation, etc.) can be stored and added to the tree to be built.

Template Parameters
Tmust be a valid Eigen ScalarType.

Instantiated templates for the following ScalarTypes are provided:

  • double

Constructor & Destructor Documentation

WorldSimTreeBuilder ( bool  compile_tree = true,
std::unique_ptr< RigidBodyTree< T >>  base_tree = nullptr 
)

Constructs a WorldSimTreeBuilder object and specifies whether a call to any of the add model instance functions should compile the tree.

Setting compile_tree to false will cause the parser to bypass tree compilation such that modifications to the recently parsed tree can be made at run time (e.g., accessing/modifying collision filters declared in the corresponding urdf/sdf file). The user is responsible for calling compile() on the tree. Take the following snippet as an example:

auto tree_builder = std::make_unique<WorldSimTreeBuilder<double>>(false);
tree_builder->StoreDrakeModel("mymodel", kModelUrdf);
tree_builder->AddFixedModelInstance("mymodel", Eigen::Vector3d::Zero());
auto mtree = tree_builder->mutable_tree();
// modify the tree here
mtree->compile();
Parameters
compile_treeSpecifies whether the tree should be automatically compiled. Defaults to true.
base_treeIf not null, new models will be added to this tree instead of to an empty tree.
WorldSimTreeBuilder ( const WorldSimTreeBuilder< T > &  other)
delete

Member Function Documentation

int AddFixedModelInstance ( const std::string &  model_name,
const Eigen::Vector3d &  xyz,
const Eigen::Vector3d &  rpy = Eigen::Vector3d::Zero() 
)

Adds a fixed model instance specified by its name, model_name, to the RigidBodyTree being built at the pose specified by position xyz and orientation rpy.

The model name must have been previously loaded via a call to StoreModel().

Returns
model_instance_id of the object that is added.
int AddFloatingModelInstance ( const std::string &  model_name,
const Eigen::Vector3d &  xyz,
const Eigen::Vector3d &  rpy = Eigen::Vector3d::Zero() 
)

Adds a floating model instance specified by its name, model_name, to the RigidBodyTree being built at the pose specified by position xyz and orientation rpy.

The model name must have been previously loaded via a call to StoreModel().

Returns
model_instance_id of the object that is added.
void AddGround ( )

Adds a flat terrain to the simulation.

int AddModelInstanceToFrame ( const std::string &  model_name,
std::shared_ptr< RigidBodyFrame< T >>  weld_to_frame,
const drake::multibody::joints::FloatingBaseType  floating_base_type = drake::multibody::joints::kFixed 
)

Adds a model instance specified by its model name, model_name, to the RigidBodyTree being built.

The model instance is connected to the existing world based on a weld_to_frame using a joint of type floating_base_type. The model name must have been previously loaded via a call to StoreModel().

Returns
model_instance_id of the object that is added.
int AddModelInstanceToFrame ( const std::string &  model_name,
const std::string &  weld_to_body_name,
int  weld_to_body_model_instance_id,
const std::string &  frame_name,
const Eigen::Isometry3d &  X_BF,
const drake::multibody::joints::FloatingBaseType  floating_base_type 
)

Adds a model instance specified by its model name, model_name, to the RigidBodyTree being built.

The model instance is welded to a new frame F constructed within this function. This new frame F is fixed on a body of name weld_to_body_name, with a transformation to this body as X_BF, where B is the body frame. The new frame is named frame_name. The model instance is connected to the body using a joint of type floating_base_type. The model name must have been previously loaded via a call to StoreModel(). The function will search for the body with name weld_to_body_name, on the model with ID weld_to_body_model_instance_id.

Parameters
model_nameThe model with this name will be added to the tree.
weld_to_body_nameThe added model will be welded to a body with this name.
weld_to_body_model_instance_idThe added model will be welded to a body with this model instance ID.
frame_nameThe name of the newly added frame.
X_BFThe pose of the newly added frame F in the added body frame B.
floating_base_typeThe type of the joint to weld the added model to the frame F on the body B.
Returns
model_instance_id of the object that is added.
std::unique_ptr<RigidBodyTree<T> > Build ( void  )
inline

Gets a unique pointer to the RigidBodyTree that was built.

This method can only be called if it was not previously called. Ownership of the manufactured RigidBodyTree is transferred to the calling code. The instance of this class should be discarded after this method is called.

systems::CompliantContactModelParameters contact_model_parameters ( ) const
inline

The compliant contact model parameters to use with the default material parameters; these values should be passed to the plant.

systems::CompliantMaterial default_contact_material ( ) const
inline
ModelInstanceInfo<T> get_model_info_for_instance ( int  id)
inline
RigidBodyTree<T>* mutable_tree ( )
inline

Returns a pointer to the (not yet built) mutable tree.

This is useful when one needs to programmatically modify a recently parsed, uncompiled tree (e.g., accessing/modifying collision filters declared in the corresponding urdf/sdf file).

Precondition
Build() must not have been called yet.
WorldSimTreeBuilder& operator= ( const WorldSimTreeBuilder< T > &  other)
delete
void StoreDrakeModel ( const std::string &  model_name,
const std::string &  model_path 
)

Like StoreModel, but uses FindResourceOrThrow to search inside the drake resource search path.

void StoreModel ( const std::string &  model_name,
const std::string &  absolute_model_path 
)

Adds a model to the internal model database.

Models are described by model_name coupled with URDF/SDF paths in absolute_model_path. Instances of these models can then be added to the world via the various AddFoo() methods provided by this class. Note that model_name is user-selectable but must be unique among all of the models that are stored.

See also
AddObjectToFrame
AddFloatingObject
AddFixedObject
const RigidBodyTree<T>& tree ( ) const
inline

Returns the (not yet built) tree.

Precondition
Build() must not have been called yet.

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