SCL  1.0
Standard Control Library : Control, dynamics, physics, and simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Groups Pages
SRigidBody.hpp
1 /* This file is part of scl, a control and simulation library
2 for robots and biomechanical models.
3 
4 scl is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8 
9 Alternatively, you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of
12 the License, or (at your option) any later version.
13 
14 scl is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU Lesser General Public
20 License and a copy of the GNU General Public License along with
21 scl. If not, see <http://www.gnu.org/licenses/>.
22 */
23 /* \file SRigidBody.hpp
24  *
25  * Created on: Jul 22, 2010
26  *
27  * Copyright (C) 2010
28  *
29  * Author: Samir Menon <smenon@stanford.edu>
30  */
31 
32 #ifndef SRIGIDBODY_HPP_
33 #define SRIGIDBODY_HPP_
34 
35 #include <scl/DataTypes.hpp>
36 #include <scl/data_structs/SObject.hpp>
37 
38 #include <sutil/CMappedList.hpp>
39 
40 #include <Eigen/Core>
41 #include <Eigen/Geometry>
42 
43 #include <string>
44 #include <vector>
45 
46 namespace scl
47 {
48 
51 {
52 public:
53  // Eigen requires redefining the new operator for classes that contain fixed size Eigen member-data.
54  // See http://eigen.tuxfamily.org/dox/StructHavingEigenMembers.html
55  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
56 
57  Eigen::VectorXd pos_in_parent_;
58  //NOTE TODO : Not using Eigen::Quaternion here because of weird Eigen dynamic_cast errors! Figure them out later.
59  Eigen::VectorXd ori_parent_quat_; //x y z real
60  Eigen::VectorXd scaling_; //Between 0 and 1. Default is 1.
61 
62  sInt collision_type_;//NOTE TODO : Should be an enum
63 
64  std::string file_name_;
65 
67  enum EGraphicObjectType{ GRAPHIC_TYPE_FILE_OBJ, GRAPHIC_TYPE_SPHERE, GRAPHIC_TYPE_CUBOID, GRAPHIC_TYPE_CYLINDER,
68  GRAPHIC_TYPE_NOT_INIT };
69 
72 
74  double color_[3];
75 
77  {
78  pos_in_parent_.setZero(3);
79  ori_parent_quat_.setZero(4);
80  ori_parent_quat_(3) = 1;
81  scaling_.setConstant(3,1);//x y z scaling. Default = 1
82  collision_type_ = 0;
83  file_name_ = "";
84  class_ = GRAPHIC_TYPE_NOT_INIT;
85  color_[0] = 0; color_[1] = 0; color_[2] = 0;
86  }
87 };
88 
95 {
96 public:
97  // Eigen requires redefining the new operator for classes that contain fixed size Eigen member-data.
98  // See http://eigen.tuxfamily.org/dox/StructHavingEigenMembers.html
99  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
100 
101  //Constructor@End of the class:
102 
103  //****************************************************************************************
104  //Robot Branching data:
105 
106  // Identifiers
107  std::string robot_name_;
112 
113  // Tree structure information: (Enables manual tree parsing)
114  std::string parent_name_;
115  SRigidBody* parent_addr_;
116  std::vector<SRigidBody*> child_addrs_;
117 
118  //3. Graph structure information: (Enables manual graph parsing)
119  std::vector<SRigidBody*> gr_parent_names_;
120  std::vector<SRigidBody*> gr_parent_addrs_;
121  std::vector<SRigidBody*> gr_child_addrs_;
122 
123  //****************************************************************************************
124  // Static Link Properties (wrt. parent at the zero position)
125  sBool is_root_;
126 
127  Eigen::Vector3d pos_in_parent_;
128 
130  Eigen::Quaternion<sFloat> ori_parent_quat_;
131 
133  Eigen::Vector3d com_;
135  Eigen::Matrix3d inertia_;
136 
138 
139  //****************************************************************************************
140  // Joint information
141  std::string joint_name_;
142  sFloat joint_limit_lower_, joint_limit_upper_;
143  sFloat joint_default_pos_;
144  EJointType joint_type_;
145 
146  //****************************************************************************************
147  // Spatial joint information
148  std::vector<std::string> sp_joint_name_;
149  std::vector<sBool> sp_joint_broken_in_spanning_tree_;
150  Eigen::VectorXd sp_joint_limit_lower_, sp_joint_limit_upper_, sp_joint_default_pos_;
151  Eigen::MatrixXd sp_S_joint_;
152  Eigen::MatrixXd sp_Sorth_joint_;
153 
154  //****************************************************************************************
155  // Graphics data
156  std::vector<SRigidBodyGraphics> graphics_obj_vec_;
157  sInt collision_type_;
158  ERenderType render_type_;
159 
160  //****************************************************************************************
162  SRigidBody();
163 
165  void init();
166 };
167 
168 }//end of namespace scl_parser
169 
170 #endif /*SRIGIDBODY_HPP_*/
Eigen::Vector3d com_
Center of mass position (in own frame)
Definition: SRigidBody.hpp:133
EGraphicObjectType
Definition: SRigidBody.hpp:67
double color_[3]
Definition: SRigidBody.hpp:74
Eigen::Vector3d pos_in_parent_
Position in the parent frame.
Definition: SRigidBody.hpp:127
EGraphicObjectType class_
Definition: SRigidBody.hpp:71
Definition: SRigidBody.hpp:94
SRigidBody()
Definition: SRigidBody.cpp:39
sFloat mass_
Mass.
Definition: SRigidBody.hpp:134
Eigen::MatrixXd sp_S_joint_
Column vectors correspond to spatial directions of motion.
Definition: SRigidBody.hpp:151
bool sBool
Definition: DataTypes.hpp:54
Eigen::MatrixXd sp_Sorth_joint_
Column vectors correspond to spatial directions of constraint.
Definition: SRigidBody.hpp:152
Eigen::Quaternion< sFloat > ori_parent_quat_
Definition: SRigidBody.hpp:130
void init()
Definition: SRigidBody.cpp:46
EJointType
Definition: DataTypes.hpp:110
double sFloat
Definition: DataTypes.hpp:72
sInt link_id_
Definition: SRigidBody.hpp:111
Definition: SRigidBody.hpp:50
int sInt
Definition: DataTypes.hpp:64
Eigen::Matrix3d inertia_
Inertia at the center of mass.
Definition: SRigidBody.hpp:135
Definition: SObject.hpp:43
sInt link_is_fixed_
(No joints) Fixed links are simply merged into upper links.
Definition: SRigidBody.hpp:137