Follow this link to skip to the main content

claraty::ME_Body Class Reference

#include <me_body.h>

Collaboration diagram for claraty::ME_Body:

Collaboration graph
[legend]
List of all members.

Public Member Functions

ME_Body model modification
void rename (std::string append)
bool set_this_iterator ()
void set_this_iterator (Tree< ME_Body >::Pre_Order_Iterator me_body_iterate)
void set_mech_model_tree (Tree< ME_Body > &_mech_model_tree)
void set_joint (ME_Joint &joint)
void set_reference_frame (Frame &ref_frame)
Framecreate_frame (std::string frame_name="")
void make_reference_frame (Frame &frame)
Mass_Propertiescreate_mass_properties ()
Bounding_Shapecreate_bounding_shape ()
Display_Graphicscreate_display_graphics ()
void rotate_center_of_mass (const Quaternion< double > &rotation)
void rotate_inertia_tensor (const Quaternion< double > &rotation)
void rotate_center_of_mass (const RMatrix< double > &rotation)
void rotate_inertia_tensor (const RMatrix< double > &rotation)
void set_ref_frame_absolute_rotation (const Quaternion< double > absolute_rotation)
ME_Body model querying
std::string get_name ()
bool is_ground_body ()
ME_Bodyget_parent ()
ME_Bodyget_parent (Tree< ME_Body > &check_tree)
bool has_parent ()
bool has_parent (Tree< ME_Body > &check_tree)
ME_Bodyget_body ()
ME_Bodyget_tree_body (std::string body_name)
ME_Jointget_joint ()
Frameget_reference_frame ()
std::vector< Frame * > & get_frame_vector ()
Frameget_frame (std::string frame_name)
Composite_Bounding_Shapeget_bounding_shape ()
Mass_Propertiesget_mass_properties ()
Display_Graphicsget_display_graphics ()
bool have_mass_properties ()
bool have_bounding_shape ()
bool have_display_graphics ()
Tree< ME_Body >::Iterator & get_this_iterator ()
int get_number_of_frames ()
Quaternion< double > & get_ref_frame_absolute_rotation ()
ME_Body compute forward kinematics
Transform get_relative_transform ()
Transform get_relative_transform (ME_Body &body)
Transform get_absolute_transform ()

Private Attributes

unsigned int _number_of_frames
std::string _name
Tree< ME_Body > & _mech_model_tree
Tree< ME_Body >::Iterator _this_iterator
ME_Joint _joint
std::vector< Frame * > _frame_vector
Mass_Properties_mass_properties
Composite_Bounding_Shape_composite_bounding_shape
Display_Graphics_display_graphics
Quaternion< double > _ref_frame_absolute_rotation

Friends

std::ostream & operator<< (std::ostream &os, ME_Body &me_body)

Detailed Description

Forward declaration of Mechanism_Model class

Definition at line 145 of file me_body.h.


Constructor & Destructor Documentation

claraty::ME_Body::ME_Body ( Tree< ME_Body > &  mm_tree  ) 

Constructor for a ME_Body object.

Parameters:
[in] mm_tree 

Definition at line 295 of file me_body.cc.

References _composite_bounding_shape, _joint, claraty::Composite_Bounding_Shape::insert(), claraty::ME_Joint::set_body(), and set_this_iterator().

00296   : _number_of_frames(0),
00297     _name(""),
00298     _mech_model_tree(mm_tree),
00299     _mass_properties(0),
00300     _composite_bounding_shape(0),
00301     _display_graphics(0)
00302 {
00303   _joint.set_body(this);
00304   if (!_composite_bounding_shape)
00305     {
00306       _composite_bounding_shape = new Composite_Bounding_Shape();
00307       Bounding_Shape * root_obj_params = new Bounding_Shape();
00308       _composite_bounding_shape->insert(root_obj_params);
00309     }
00310   set_this_iterator();
00311 }

Here is the call graph for this function:

claraty::ME_Body::ME_Body ( std::string  name,
Tree< ME_Body > &  mm_tree 
)

Constructor for a ME_Body object.

Parameters:
[in] name 
[in] mm_tree 

Definition at line 322 of file me_body.cc.

References _composite_bounding_shape, _joint, claraty::Composite_Bounding_Shape::insert(), claraty::ME_Joint::set_body(), and set_this_iterator().

00323   : _number_of_frames(0),
00324     _name(name),
00325     _mech_model_tree(mm_tree),
00326     _mass_properties(0),
00327     _composite_bounding_shape(0),
00328     _display_graphics(0)
00329 {
00330   _joint.set_body(this);
00331   if (!_composite_bounding_shape)
00332     {
00333       _composite_bounding_shape = new Composite_Bounding_Shape();
00334       Bounding_Shape * root_obj_params = new Bounding_Shape();
00335       _composite_bounding_shape->insert(root_obj_params);
00336     }
00337 
00338   set_this_iterator();
00339 }

Here is the call graph for this function:

claraty::ME_Body::ME_Body ( std::string  name,
Mechanism_Model mm,
std::string  parent_body_name = "ground" 
)

Constructor for a ME_Body object.

Parameters:
[in] name 
[in] mm 
[in] parent_body_name 

Definition at line 351 of file me_body.cc.

References _composite_bounding_shape, _joint, claraty::Mechanism_Model::add_body(), claraty::Composite_Bounding_Shape::insert(), claraty::ME_Joint::set_body(), and set_this_iterator().

00352   : _number_of_frames(0),
00353     _name(name),
00354     _mech_model_tree(mm.get_body_tree()),
00355     _mass_properties(0),
00356     _composite_bounding_shape(0),
00357     _display_graphics(0)
00358 {
00359   _joint.set_body(this);
00360   if (!_composite_bounding_shape)
00361     {
00362       _composite_bounding_shape = new Composite_Bounding_Shape();
00363       Bounding_Shape * root_obj_params = new Bounding_Shape();
00364       _composite_bounding_shape->insert(root_obj_params);
00365     }
00366 
00367   set_this_iterator();
00368 
00369   mm.add_body(*this, parent_body_name);
00370 }

Here is the call graph for this function:

claraty::ME_Body::ME_Body ( ME_Body me_body  ) 

Copy Constructor for a ME_Body object.

Parameters:
[in] me_body 

Definition at line 380 of file me_body.cc.

References _composite_bounding_shape, _display_graphics, _frame_vector, _joint, _mass_properties, _number_of_frames, claraty::Frame::set_body(), claraty::ME_Joint::set_body(), and set_this_iterator().

00381   :     _number_of_frames(0),
00382         _name(me_body._name),
00383         _mech_model_tree(me_body._mech_model_tree), 
00384         _mass_properties(0),
00385         _composite_bounding_shape(0),
00386         _display_graphics(0)
00387 {
00388   _joint = me_body._joint;
00389   _joint.set_body(this);
00390   
00391   std::vector<Frame *>::iterator frame_itr;
00392   Frame * frame;
00393 
00394   for (frame_itr = me_body._frame_vector.begin();
00395        frame_itr < me_body._frame_vector.end(); ++frame_itr)
00396     {
00397       frame = new Frame(**frame_itr);
00398       frame->set_body(this);
00399       ++_number_of_frames;
00400       _frame_vector.push_back(frame);
00401     }
00402   
00403   if (me_body._composite_bounding_shape)
00404     {
00405       _composite_bounding_shape =
00406         new Composite_Bounding_Shape(*me_body._composite_bounding_shape);
00407     }
00408   
00409   if (me_body._mass_properties!=0)
00410     {
00411     _mass_properties = new Mass_Properties(*(me_body._mass_properties));
00412     }
00413   
00414   if (me_body._display_graphics!=0)
00415     _display_graphics = new Display_Graphics(*(me_body._display_graphics));
00416   
00417   set_this_iterator();
00418 
00419 }

Here is the call graph for this function:

claraty::ME_Body::~ME_Body (  )  [virtual]

Destructor for a ME_Body object.

Definition at line 427 of file me_body.cc.

References _composite_bounding_shape, _display_graphics, _frame_vector, _mass_properties, claraty::Composite_Bounding_Shape::clear_tree(), and claraty::Composite_Bounding_Shape::empty().

00428 {
00429   if (_display_graphics)
00430     delete _display_graphics;
00431   
00432   if (!_composite_bounding_shape->empty())
00433     _composite_bounding_shape->clear_tree();
00434   
00435   if (_mass_properties)
00436     delete _mass_properties;
00437   
00438   // Now delete the vector of frames
00439   if (!_frame_vector.empty())
00440     _frame_vector.clear();      
00441   
00442 }

Here is the call graph for this function:

claraty::ME_Body::ME_Body ( Tree< ME_Body > &  mm_tree  ) 

Constructor for a ME_Body object.

Parameters:
[in] mm_tree 

Definition at line 295 of file me_body.cc.

References _composite_bounding_shape, _joint, claraty::Composite_Bounding_Shape::insert(), claraty::ME_Joint::set_body(), and set_this_iterator().

00296   : _number_of_frames(0),
00297     _name(""),
00298     _mech_model_tree(mm_tree),
00299     _mass_properties(0),
00300     _composite_bounding_shape(0),
00301     _display_graphics(0)
00302 {
00303   _joint.set_body(this);
00304   if (!_composite_bounding_shape)
00305     {
00306       _composite_bounding_shape = new Composite_Bounding_Shape();
00307       Bounding_Shape * root_obj_params = new Bounding_Shape();
00308       _composite_bounding_shape->insert(root_obj_params);
00309     }
00310   set_this_iterator();
00311 }

Here is the call graph for this function:

claraty::ME_Body::ME_Body ( std::string  name,
Tree< ME_Body > &  mm_tree 
)

Constructor for a ME_Body object.

Parameters:
[in] name 
[in] mm_tree 

Definition at line 322 of file me_body.cc.

References _composite_bounding_shape, _joint, claraty::Composite_Bounding_Shape::insert(), claraty::ME_Joint::set_body(), and set_this_iterator().

00323   : _number_of_frames(0),
00324     _name(name),
00325     _mech_model_tree(mm_tree),
00326     _mass_properties(0),
00327     _composite_bounding_shape(0),
00328     _display_graphics(0)
00329 {
00330   _joint.set_body(this);
00331   if (!_composite_bounding_shape)
00332     {
00333       _composite_bounding_shape = new Composite_Bounding_Shape();
00334       Bounding_Shape * root_obj_params = new Bounding_Shape();
00335       _composite_bounding_shape->insert(root_obj_params);
00336     }
00337 
00338   set_this_iterator();
00339 }

Here is the call graph for this function:

claraty::ME_Body::ME_Body ( std::string  name,
Mechanism_Model mm,
std::string  parent_body_name = "ground" 
)

Constructor for a ME_Body object.

Parameters:
[in] name 
[in] mm 
[in] parent_body_name 

Definition at line 351 of file me_body.cc.

References _composite_bounding_shape, _joint, claraty::Mechanism_Model::add_body(), claraty::Composite_Bounding_Shape::insert(), claraty::ME_Joint::set_body(), and set_this_iterator().

00352   : _number_of_frames(0),
00353     _name(name),
00354     _mech_model_tree(mm.get_body_tree()),
00355     _mass_properties(0),
00356     _composite_bounding_shape(0),
00357     _display_graphics(0)
00358 {
00359   _joint.set_body(this);
00360   if (!_composite_bounding_shape)
00361     {
00362       _composite_bounding_shape = new Composite_Bounding_Shape();
00363       Bounding_Shape * root_obj_params = new Bounding_Shape();
00364       _composite_bounding_shape->insert(root_obj_params);
00365     }
00366 
00367   set_this_iterator();
00368 
00369   mm.add_body(*this, parent_body_name);
00370 }

Here is the call graph for this function:

claraty::ME_Body::ME_Body ( ME_Body me_body  ) 

Copy Constructor for a ME_Body object.

Parameters:
[in] me_body 

Definition at line 380 of file me_body.cc.

References _composite_bounding_shape, _display_graphics, _frame_vector, _joint, _mass_properties, _number_of_frames, claraty::Frame::set_body(), claraty::ME_Joint::set_body(), and set_this_iterator().

00381   :     _number_of_frames(0),
00382         _name(me_body._name),
00383         _mech_model_tree(me_body._mech_model_tree), 
00384         _mass_properties(0),
00385         _composite_bounding_shape(0),
00386         _display_graphics(0)
00387 {
00388   _joint = me_body._joint;
00389   _joint.set_body(this);
00390   
00391   std::vector<Frame *>::iterator frame_itr;
00392   Frame * frame;
00393 
00394   for (frame_itr = me_body._frame_vector.begin();
00395        frame_itr < me_body._frame_vector.end(); ++frame_itr)
00396     {
00397       frame = new Frame(**frame_itr);
00398       frame->set_body(this);
00399       ++_number_of_frames;
00400       _frame_vector.push_back(frame);
00401     }
00402   
00403   if (me_body._composite_bounding_shape)
00404     {
00405       _composite_bounding_shape =
00406         new Composite_Bounding_Shape(*me_body._composite_bounding_shape);
00407     }
00408   
00409   if (me_body._mass_properties!=0)
00410     {
00411     _mass_properties = new Mass_Properties(*(me_body._mass_properties));
00412     }
00413   
00414   if (me_body._display_graphics!=0)
00415     _display_graphics = new Display_Graphics(*(me_body._display_graphics));
00416   
00417   set_this_iterator();
00418 
00419 }

Here is the call graph for this function:

claraty::ME_Body::~ME_Body (  )  [virtual]

Destructor for a ME_Body object.

Definition at line 427 of file me_body.cc.

References _composite_bounding_shape, _display_graphics, _frame_vector, _mass_properties, claraty::Composite_Bounding_Shape::clear_tree(), and claraty::Composite_Bounding_Shape::empty().

00428 {
00429   if (_display_graphics)
00430     delete _display_graphics;
00431   
00432   if (!_composite_bounding_shape->empty())
00433     _composite_bounding_shape->clear_tree();
00434   
00435   if (_mass_properties)
00436     delete _mass_properties;
00437   
00438   // Now delete the vector of frames
00439   if (!_frame_vector.empty())
00440     _frame_vector.clear();      
00441   
00442 }

Here is the call graph for this function:


Member Function Documentation

void claraty::ME_Body::rename ( std::string  new_name  ) 

Set body name and the attribute name.

Parameters:
[in] new_name 

Definition at line 454 of file me_body.cc.

References _name.

Referenced by claraty::ME_Body_IO::extract_from_parse_tree().

00455 {
00456   _name = new_name;
00457 }

bool claraty::ME_Body::set_this_iterator (  ) 

Set this iterator to point to its node on the tree

Returns:
TRUE if successful, FALSE if not

Definition at line 539 of file me_body.cc.

References _mech_model_tree, and _this_iterator.

Referenced by claraty::Mechanism_Model::add_body(), ME_Body(), and claraty::Mechanism_Model::rebuild_lists().

00540 {
00541   bool retval = false;
00542   Tree<ME_Body>::Pre_Order_Iterator me_body_iterate
00543     = _mech_model_tree.begin_pre_order();
00544 
00545   for (; me_body_iterate < _mech_model_tree.end_pre_order(); ++me_body_iterate)
00546     {
00547       if (&(*me_body_iterate) == this)
00548         {
00549         retval =  true;
00550         break;
00551         }
00552     }
00553   _this_iterator = me_body_iterate;
00554   return retval;
00555 
00556 }

void claraty::ME_Body::set_this_iterator ( Tree< ME_Body >::Pre_Order_Iterator  me_body_iterate  ) 

Set this iterator to point to its node on the tree

Returns:
TRUE if successful, FALSE if not

Definition at line 565 of file me_body.cc.

References _this_iterator.

00567 {
00568   _this_iterator = me_body_iterate;
00569 
00570 }

void claraty::ME_Body::set_mech_model_tree ( Tree< ME_Body > &  mech_model_tree  ) 

Set the mech_model_tree

Returns:
TRUE if already had a reference frame, FALSE if not

Definition at line 481 of file me_body.cc.

References _mech_model_tree.

00482 {
00483   _mech_model_tree = mech_model_tree;
00484 }

void claraty::ME_Body::set_joint ( ME_Joint joint  ) 

Set body joint.

Parameters:
[in] joint 

Definition at line 579 of file me_body.cc.

References _joint, and claraty::ME_Joint::set_body().

00580 {
00581   _joint = joint;
00582   _joint.set_body(this);
00583 }

Here is the call graph for this function:

void claraty::ME_Body::set_reference_frame ( Frame ref_frame  ) 

Add the frame passed in as the body's reference frame

Returns:
TRUE if already had a reference frame, FALSE if not

Definition at line 467 of file me_body.cc.

References _frame_vector, claraty::Frame::REFERENCE_FRAME, and claraty::Frame::set_type().

00468 {
00469   ref_frame.set_type(Frame::REFERENCE_FRAME);
00470   _frame_vector[0] = &ref_frame;
00471 }

Here is the call graph for this function:

Frame & claraty::ME_Body::create_frame ( std::string  frame_name = ""  ) 

Create frame.

Parameters:
[in] frame_name 
Returns:
Pointer to the frame.

Definition at line 593 of file me_body.cc.

References _frame_vector, _number_of_frames, claraty::Frame::LOCAL_FRAME, claraty::Frame::REFERENCE_FRAME, claraty::Frame::set_body(), claraty::Frame::set_name(), and claraty::Frame::set_type().

Referenced by claraty::ME_Body_IO::extract_from_parse_tree(), and claraty::Mechanism_Model::Mechanism_Model().

00594 {
00595   Frame * frame = new Frame();
00596   if (_number_of_frames == 0)  // 
00597                                // 
00598                                // The first frame is always a REFERENCE_FRAME frame.
00599     {
00600         frame->set_type(Frame::REFERENCE_FRAME);
00601     }
00602   else                         // All other frames are LOCAL_FRAME frames
00603     {
00604       frame->set_type(Frame::LOCAL_FRAME);
00605     }
00606 
00607   frame->set_body(this);
00608   frame->set_name(frame_name);
00609   _frame_vector.push_back(frame);
00610   ++_number_of_frames;
00611   return *_frame_vector.back(); 
00612 }

Here is the call graph for this function:

void claraty::ME_Body::make_reference_frame ( Frame frame  ) 

Make a body reference frame.

Parameters:
[in] frame 

Definition at line 621 of file me_body.cc.

References _frame_vector, claraty::Frame::get_name(), claraty::Frame::LOCAL_FRAME, and claraty::Frame::REFERENCE_FRAME.

Referenced by claraty::Frame_IO::extract_from_parse_tree(), and claraty::Mechanism_Model::Mechanism_Model().

00622 {
00623   // This frame must already exist in the vector so find it first
00624   vector<Frame *> :: iterator itr = _frame_vector.begin();
00625   Frame *temp;
00626   for (; itr < _frame_vector.end(); ++itr)
00627     {
00628       if ((*itr)->get_name() == frame.get_name())
00629         {
00630           temp = *itr;
00631           break;
00632         }
00633     }
00634   if (itr == _frame_vector.end())// Did not find the frame so return
00635     return;
00636 
00637   // Delete the old version of it and insert it at the beginning of
00638   // the vector
00639   _frame_vector.erase(itr);
00640   _frame_vector.insert(_frame_vector.begin(), 1, temp);
00641   
00642   // Set the first frame to be a REFERENCE_FRAME frame and all other frames
00643   // in the vector to be LOCAL_FRAME frames 
00644   itr = _frame_vector.begin();
00645   (*itr)->set_type(Frame::REFERENCE_FRAME);
00646   ++itr;
00647   for (; itr < _frame_vector.end(); ++itr)
00648     {
00649       (*itr)->set_type(Frame::LOCAL_FRAME);
00650     }
00651   
00652 }

Here is the call graph for this function:

Mass_Properties & claraty::ME_Body::create_mass_properties (  ) 

Create body mass properties.

Returns:
Mass properties.

Definition at line 660 of file me_body.cc.

References _mass_properties.

Referenced by claraty::ME_Body_IO::extract_from_parse_tree().

00661 {
00662   _mass_properties = new Mass_Properties();
00663   return *_mass_properties;
00664 }

Bounding_Shape & claraty::ME_Body::create_bounding_shape (  ) 

Create shape tree object.

Definition at line 672 of file me_body.cc.

References _composite_bounding_shape, and claraty::Composite_Bounding_Shape::insert().

Referenced by claraty::ME_Body_IO::extract_from_parse_tree().

00673 {
00674   // Create the root from the tree of Bounding_Shape and
00675   // attach it to the tree at the root position
00676 
00677   if (!_composite_bounding_shape)
00678     {
00679       _composite_bounding_shape = new Composite_Bounding_Shape();
00680       Bounding_Shape * root_obj_params = new Bounding_Shape();
00681       _composite_bounding_shape->insert(root_obj_params);
00682     }
00683   
00684   Bounding_Shape * new_bounding_shape = new Bounding_Shape();
00685 
00686   return *new_bounding_shape;
00687 }

Here is the call graph for this function:

Display_Graphics & claraty::ME_Body::create_display_graphics (  ) 

Definition at line 696 of file me_body.cc.

References _display_graphics.

Referenced by claraty::ME_Body_IO::extract_from_parse_tree().

00697 {
00698   _display_graphics = new Display_Graphics();
00699   return *_display_graphics;
00700 }

void claraty::ME_Body::rotate_center_of_mass ( const Quaternion< double > &  rotation  ) 

Rotate the center of mass transform by the specified rotation.

The transform is modified within the me_body mass_properties data structure.

Parameters:
[in] rotation Quaternion specifying rotation.

Definition at line 776 of file me_body.cc.

References _mass_properties, claraty::Quaternion< T >::conjugate(), claraty::Mass_Properties::get_center_of_mass(), get_mass_properties(), claraty::Trans< T, Rotation_Type >::set_rotation(), and claraty::Trans< T, Rotation_Type >::set_translation().

Referenced by claraty::ME_Body_IO::extract_from_parse_tree(), and rotate_center_of_mass().

00777 {
00778   if (!_mass_properties)
00779     return ;
00780 
00781   Transform center_of_mass_transform =
00782     get_mass_properties().get_center_of_mass();
00783   Quaternion<double> rotation_conjugate(rotation);
00784   rotation_conjugate.conjugate();
00785 
00786   get_mass_properties().get_center_of_mass().set_translation(rotation_conjugate
00787                                   * Point<double>(center_of_mass_transform));
00788   get_mass_properties().get_center_of_mass().set_rotation(rotation_conjugate
00789                                * Quaternion<double>(center_of_mass_transform));
00790   
00791 }

Here is the call graph for this function:

void claraty::ME_Body::rotate_inertia_tensor ( const Quaternion< double > &  rotation  ) 

Rotate the inertia tensor by the specified rotation. The resulting tensor = rotation * inertia_tensor * rotation.transpose()

The tensor is modified within the me_body mass_properties data structure.

Parameters:
[in] rotation Quaternion specifying rotation.

Definition at line 744 of file me_body.cc.

00745 {
00746   RMatrix<double> rotation_matrix(rotation);
00747   rotate_inertia_tensor(rotation_matrix);
00748 }

void claraty::ME_Body::rotate_center_of_mass ( const RMatrix< double > &  rotation  ) 

Rotate the center of mass transform by the specified rotation.

The transform is modified within the me_body mass_properties data structure.

Parameters:
[in] rotation Quaternion specifying rotation

Definition at line 760 of file me_body.cc.

References rotate_center_of_mass().

00761 {
00762   Quaternion<double> q_rotation(rotation);
00763   rotate_center_of_mass(q_rotation);
00764 }

Here is the call graph for this function:

void claraty::ME_Body::rotate_inertia_tensor ( const RMatrix< double > &  rotation  ) 

Rotate the inertia tensor by the specified rotation. The resulting tensor = rotation * inertia_tensor * rotation.transpose()

The tensor is modified within the me_body mass_properties data structure.

Parameters:
[in] rotation Quaternion specifying rotation.

Definition at line 714 of file me_body.cc.

References _mass_properties, claraty::Mass_Properties::get_inertia(), get_mass_properties(), claraty::Mass_Properties::set_inertia(), and claraty::RMatrix< T >::transpose().

00715 {
00716   if (!_mass_properties)
00717     return ;
00718 
00719   RMatrix<double> rotation_matrix(rotation);
00720 
00721   Matrix<double> inertia_tensor(3,3);
00722   Matrix<double> inertia_tensor_rotated(3,3);
00723 
00724   get_mass_properties().get_inertia(inertia_tensor);
00725 
00726   inertia_tensor_rotated = rotation_matrix * inertia_tensor
00727     * rotation_matrix.transpose();
00728   
00729   get_mass_properties().set_inertia(inertia_tensor_rotated);  
00730 
00731 }

Here is the call graph for this function:

void claraty::ME_Body::set_ref_frame_absolute_rotation ( const Quaternion< double >  absolute_rotation  )  [inline]

Definition at line 174 of file me_body.h.

References _ref_frame_absolute_rotation.

Referenced by claraty::Frame_IO::convert_to_internal_format().

00174                                                                                    {
00175     _ref_frame_absolute_rotation = absolute_rotation;};

std::string claraty::ME_Body::get_name (  ) 

bool claraty::ME_Body::is_ground_body (  ) 

Determine if this body is the ground body

Returns:
True if this body is the ground body, false otherwise.

Definition at line 913 of file me_body.cc.

References has_parent().

Referenced by get_absolute_transform(), and get_relative_transform().

00914 {
00915   if (has_parent())
00916     return false;
00917   else
00918     return true;
00919 }

Here is the call graph for this function:

ME_Body & claraty::ME_Body::get_parent (  ) 

Return body that this body is attached to

Returns:
name

Definition at line 837 of file me_body.cc.

References _mech_model_tree, and _this_iterator.

Referenced by claraty::Frame_IO::convert_to_internal_format(), claraty::ME_Body_IO::extract_from_parse_tree(), get_absolute_transform(), and claraty::operator<<().

00838 {
00839   return *_mech_model_tree.get_parent(_this_iterator);
00840 }

ME_Body & claraty::ME_Body::get_parent ( Tree< ME_Body > &  check_tree  ) 

Return body that this body is attached to

Returns:
name

Definition at line 850 of file me_body.cc.

References Tree< T >::begin_pre_order(), Tree< T >::end_pre_order(), and Tree< T >::get_parent().

00851 {
00852   Tree<ME_Body>::Pre_Order_Iterator me_body_iterate
00853     = check_tree.begin_pre_order();
00854 
00855   Tree<ME_Body>::Iterator temp_iterator;
00856 
00857   for (; me_body_iterate < check_tree.end_pre_order(); ++me_body_iterate)
00858     {
00859       if (&(*me_body_iterate) == this)
00860         break;
00861     }
00862   temp_iterator = me_body_iterate;
00863 
00864   return *check_tree.get_parent(temp_iterator);
00865 }

Here is the call graph for this function:

bool claraty::ME_Body::has_parent (  ) 

Query if body has a valid parent

Returns:
true is has, false if not

Definition at line 875 of file me_body.cc.

References _mech_model_tree, and _this_iterator.

Referenced by is_ground_body().

00876 {
00877   return _mech_model_tree.has_parent(_this_iterator);
00878 }

bool claraty::ME_Body::has_parent ( Tree< ME_Body > &  check_tree  ) 

Query if body has a valid parent

Returns:
true is has, false if not

Definition at line 888 of file me_body.cc.

References Tree< T >::begin_pre_order(), Tree< T >::end_pre_order(), and Tree< T >::has_parent().

00889 {
00890   Tree<ME_Body>::Pre_Order_Iterator me_body_iterate
00891     = check_tree.begin_pre_order();
00892 
00893   Tree<ME_Body>::Iterator temp_iterator;
00894 
00895   for (; me_body_iterate < check_tree.end_pre_order(); ++me_body_iterate)
00896     {
00897       if (&(*me_body_iterate) == this)
00898         break;
00899     }
00900   temp_iterator = me_body_iterate;
00901 
00902   return check_tree.has_parent(temp_iterator);
00903 }

Here is the call graph for this function:

ME_Body& claraty::ME_Body::get_body (  ) 

ME_Body& claraty::ME_Body::get_tree_body ( std::string  body_name  ) 

Frame & claraty::ME_Body::get_reference_frame (  ) 

Get the body reference frame

Returns:
reference to the body reference frame

Definition at line 493 of file me_body.cc.

References _frame_vector.

Referenced by claraty::Frame_IO::convert_to_internal_format(), claraty::ME_Body_IO::extract_from_parse_tree(), and claraty::Wheel_Locomotor_Model::map_mechanism_model_to_wheel_locomotor_model().

00494 {
00495   return *_frame_vector[0];
00496 }

vector< Frame * > & claraty::ME_Body::get_frame_vector (  ) 

Return a pointer to the frame vector on the body

Returns:
reference to frame_vector

Definition at line 942 of file me_body.cc.

References _frame_vector.

Referenced by claraty::ME_Body_IO::extract_from_parse_tree(), and claraty::operator<<().

00943 {
00944   return _frame_vector;
00945 }

Frame & claraty::ME_Body::get_frame ( std::string  frame_name  ) 

Get the named body frame

Returns:
reference to the body reference frame

Definition at line 506 of file me_body.cc.

References _frame_vector.

Referenced by claraty::Frame_IO::extract_from_parse_tree(), and claraty::N_2DOF_Planar_Arm::initialize().

00507 {
00508   vector<Frame *>::iterator frame_iterator(_frame_vector.begin());
00509   while (frame_iterator != _frame_vector.end())
00510     {
00511       if ((*frame_iterator)->get_name() == frame_name)
00512         {
00513           break;
00514         }
00515       ++frame_iterator;
00516     }
00517   return *(*frame_iterator);
00518 }

Composite_Bounding_Shape & claraty::ME_Body::get_bounding_shape (  ) 

Get shape tree

Returns:
The composite bounding shape.

Definition at line 799 of file me_body.cc.

References _composite_bounding_shape.

Referenced by claraty::Wheel_Model::_compute_wheel_radius(), claraty::ME_Body_IO::extract_from_parse_tree(), and claraty::operator<<().

00800 {
00801   return *_composite_bounding_shape;
00802 }

Mass_Properties & claraty::ME_Body::get_mass_properties (  ) 

Get pointer to mass properties object

Returns:
Pointer to the child body, NULL is unsuccessful

Definition at line 1008 of file me_body.cc.

References _mass_properties.

Referenced by claraty::Mass_Properties_IO::extract_from_parse_tree(), claraty::operator<<(), rotate_center_of_mass(), and rotate_inertia_tensor().

01009 {
01010   return *_mass_properties;
01011 }

Display_Graphics & claraty::ME_Body::get_display_graphics (  ) 

Get pointer to display graphics object

Returns:
Pointer to the child body, NULL is unsuccessful

Definition at line 1034 of file me_body.cc.

References _display_graphics.

Referenced by claraty::operator<<().

01035 {
01036   return *_display_graphics;
01037 }

bool claraty::ME_Body::have_mass_properties (  ) 

Query if has mass properties

Returns:
Pointer to the child body, NULL is unsuccessful

Definition at line 1021 of file me_body.cc.

References _mass_properties.

Referenced by claraty::operator<<().

01022 {
01023   return (_mass_properties==0)?false:true;
01024 }

bool claraty::ME_Body::have_bounding_shape (  ) 

Query if has composite bounding shape

Returns:
True if composte has a bounding shape, false otherwise.

Definition at line 811 of file me_body.cc.

References _composite_bounding_shape.

Referenced by claraty::Wheel_Model::_compute_wheel_radius(), and claraty::operator<<().

00812 {
00813   return (_composite_bounding_shape==0)? false : true;;
00814 }

bool claraty::ME_Body::have_display_graphics (  ) 

Query if has display graphics

Returns:
Pointer to the child body, NULL is unsuccessful

Definition at line 1049 of file me_body.cc.

References _display_graphics.

Referenced by claraty::operator<<().

01050 {
01051   return (_display_graphics==0)?false:true;
01052 }

Tree< ME_Body >::Iterator & claraty::ME_Body::get_this_iterator (  ) 

Get this iterator

Returns:
the iterator

Definition at line 527 of file me_body.cc.

References _this_iterator.

Referenced by claraty::Mechanism_Model::get_body_absolute_transform(), get_relative_transform(), and claraty::Wheel_Locomotor_Model::map_mechanism_model_to_wheel_locomotor_model().

00528 {
00529   return _this_iterator;
00530 }

int claraty::ME_Body::get_number_of_frames (  )  [inline]

Definition at line 199 of file me_body.h.

References _number_of_frames.

00199 { return _number_of_frames;};

Quaternion<double>& claraty::ME_Body::get_ref_frame_absolute_rotation (  )  [inline]

Definition at line 200 of file me_body.h.

References _ref_frame_absolute_rotation.

Referenced by claraty::Frame_IO::convert_to_internal_format().

00200                                                          {
00201     return _ref_frame_absolute_rotation;};

Transform claraty::ME_Body::get_relative_transform (  ) 

Get transform of body reference frame relative to parent reference frame

Returns:
Transform

Definition at line 1062 of file me_body.cc.

References _frame_vector, _joint, claraty::ME_Joint::get_transform(), claraty::Trans< T, Rotation_Type >::identity, and is_ground_body().

Referenced by get_absolute_transform(), claraty::Wheel_Model::get_ground_contact(), and claraty::Frame::get_relative_transform().

01063 {
01064   if (!is_ground_body())
01065     return _frame_vector[0]->get_transform() * _joint.get_transform();
01066   else
01067     return Transform::identity;
01068 }

Here is the call graph for this function:

Transform claraty::ME_Body::get_relative_transform ( ME_Body body  ) 

Get transform of body reference frame relative to another body's reference frame

Returns:
Transform

Definition at line 1079 of file me_body.cc.

References get_this_iterator(), and claraty::inverse().

01080 {
01081   Transform result;
01082   if (body.get_this_iterator() == get_this_iterator())
01083     {
01084       return result; // same body so return identity;
01085     }
01086 
01087   Tree<ME_Body>::Chain_Iterator body_chain_node(body.get_this_iterator(),
01088                                            get_this_iterator());
01089   Tree<ME_Body>::Chain_Iterator body_chain_node_next(body_chain_node);
01090   ++body_chain_node_next;
01091   while (!body_chain_node_next.at_end)
01092     {
01093       if (body_chain_node_next.is_parent(body_chain_node_next))
01094         {
01095           result =
01096             result * inverse(body_chain_node_next->get_relative_transform());
01097         }
01098       else // is child
01099         {
01100           result = result * body_chain_node_next->get_relative_transform();
01101         }
01102       ++body_chain_node_next;
01103       ++body_chain_node;
01104     }
01105   return result;
01106 }

Here is the call graph for this function:

Transform claraty::ME_Body::get_absolute_transform (  ) 

Get transform of body reference frame relative to ground reference frame

Returns:
Transform

Definition at line 1140 of file me_body.cc.

References get_absolute_transform(), get_parent(), get_relative_transform(), claraty::Trans< T, Rotation_Type >::identity, and is_ground_body().

Referenced by get_absolute_transform(), claraty::Frame::get_absolute_transform(), and claraty::Wheel_Locomotor_Model::map_mechanism_model_to_wheel_locomotor_model().

01141 {
01142   if (!is_ground_body())
01143     return get_parent().get_absolute_transform() * get_relative_transform();
01144   else
01145     return Transform::identity;
01146 }

Here is the call graph for this function:


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
ME_Body me_body 
) [friend]

Output to ostream

Parameters:
[out] os ostream to put output on.
[in] me_body ME_Body_IO object to be output.
Returns:
ostream with output on it.

Definition at line 957 of file me_body.cc.

00958 {
00959   std::string spacing = "";
00960   spacing.append(XML_Out::get_indentation_space(), ' ');
00961   
00962   os << spacing;
00963   os << "<ME_Body ";
00964   os << "name = \"" << me_body.get_name() << "\" ";
00965   os << "parent = \"" << me_body.get_parent().get_name() << "\" >"  << endl;
00966 
00967   XML_Out::increment_indentation_level();
00968 
00969   os << me_body.get_joint();
00970 
00971   std::vector<Frame *>::iterator frame_itr;
00972   for (frame_itr = (me_body.get_frame_vector()).begin();
00973        frame_itr < (me_body.get_frame_vector()).end(); ++frame_itr)
00974     {
00975       os << *(*frame_itr);
00976     }
00977 
00978   if (me_body.have_mass_properties())
00979     {
00980       os << me_body.get_mass_properties();
00981     }
00982 
00983   if (me_body.have_bounding_shape())
00984     {
00985       os << me_body.get_bounding_shape();
00986     }
00987 
00988   if (me_body.have_display_graphics())
00989     {
00990       os << me_body.get_display_graphics();
00991     }
00992   XML_Out::decrement_indentation_level();
00993         
00994   os << spacing;
00995   os << "</ME_Body>" << endl;
00996 
00997   return os;
00998 }


Member Data Documentation

unsigned int claraty::ME_Body::_number_of_frames [private]

Number of frames on body.

Definition at line 219 of file me_body.h.

Referenced by create_frame(), get_number_of_frames(), and ME_Body().

std::string claraty::ME_Body::_name [private]

Name of body element.

Definition at line 220 of file me_body.h.

Referenced by get_name(), and rename().

Pointer to overall model tree to allow access to other bodies.

Definition at line 221 of file me_body.h.

Referenced by get_parent(), has_parent(), set_mech_model_tree(), and set_this_iterator().

Definition at line 224 of file me_body.h.

Referenced by get_parent(), get_this_iterator(), has_parent(), and set_this_iterator().

Pointer to body joint (attached to parent).

Definition at line 225 of file me_body.h.

Referenced by get_joint(), get_relative_transform(), ME_Body(), and set_joint().

Pointer to display graphics class

Definition at line 230 of file me_body.h.

Referenced by create_display_graphics(), get_display_graphics(), have_display_graphics(), ME_Body(), and ~ME_Body().

Absolute rotation of the reference frame. This is needed to convert zero-position frames to relative homogenous transforms

Definition at line 232 of file me_body.h.

Referenced by get_ref_frame_absolute_rotation(), and set_ref_frame_absolute_rotation().


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