33 #define N_FRIC_CONE_DIV 8 71 PSIM_TAG_LAMBDA = 100,
126 void dump(ostream& ost);
175 void dump(ostream& ost);
201 last_pjoints[0] = _p0;
202 last_pjoints[1] = _p1;
203 last_joint = last_pjoints[0]->
joint;
204 last_index[0] = last_index[1] = -1;
206 if(last_joint->j_type ==
JROTATE)
209 else if(last_joint->axis(1) > 0.95) axis =
PSIM_AXIS_RY;
210 else if(last_joint->axis(2) > 0.95) axis =
PSIM_AXIS_RZ;
212 else if(last_joint->j_type ==
JSLIDE)
215 else if(last_joint->axis(1) > 0.95) axis =
PSIM_AXIS_Y;
216 else if(last_joint->axis(2) > 0.95) axis =
PSIM_AXIS_Z;
219 outer_joints_origin = 0;
220 outer_joints_index = 0;
227 n_dof = last_joint->n_dof;
231 if(n_dof > 0) joint_index =
new int [n_dof];
232 if(n_const > 0) const_index =
new int [n_const];
234 if(last_joint->t_given)
236 switch(last_joint->j_type)
243 if(i == (
int)axis) joint_index[0] = i;
246 const_index[count] =
i;
260 for(i=0; i<6; i++) joint_index[i] = i;
263 for(i=0; i<6; i++) const_index[i] = i;
271 for(i=0; i<6; i++) const_index[i] = i;
285 last_index[0] = last_index[1] = -1;
288 outer_joints_origin = 0;
289 outer_joints_index = 0;
291 links =
new pLink* [1];
310 for(i=0; i<n_outer_joints; i++)
315 delete[] outer_joints;
316 delete[] outer_joints_origin;
317 delete[] outer_joints_index;
319 if(joint_index)
delete[] joint_index;
320 if(const_index)
delete[] const_index;
321 if(links)
delete[] links;
322 if(children[0])
delete children[0];
323 if(children[1] && children[1] != children[0])
delete children[1];
329 for(i=0; i<n_outer_joints; i++)
330 if(pj == outer_joints[i])
return i;
338 int schedule_depth();
361 void calc_inertia_leaf();
362 void calc_inertia_body();
365 void send_inertia(
int dest);
369 void calc_acc_leaf();
370 void calc_acc_body();
373 void send_acc(
int dest);
377 void disassembly_body();
378 void disassembly_leaf();
381 void send_force(
int dest);
403 void calc_dvel_leaf();
404 void calc_dvel_body();
405 void col_disassembly();
406 void col_disassembly_body();
410 void dump(ostream& ost);
414 int calc_contact_force(
double timestep);
416 void clear_f_final();
419 int assign_processes(
int start_rank,
int end_rank);
420 int create_types(
int* n_proc_joints,
int** lengths, MPI_Aint** disps, MPI_Datatype** oldtypes);
423 MPI_Datatype parent_lambda_type;
424 MPI_Datatype parent_acc_type;
425 MPI_Datatype parent_force_type;
432 pjoints[0] = pjoints[1] = 0;
447 :
virtual public Chain 468 cone_dir[
i](0) = cos(ang);
469 cone_dir[
i](1) = sin(ang);
470 cone_dir[
i](2) = 0.0;
474 inertia_wait_time = 0.0;
476 force_wait_time = 0.0;
485 for(
int i=0;
i<n_joint;
i++)
487 delete joint_info[
i].pjoints[0];
488 delete joint_info[
i].pjoints[1];
489 if(joint_info[
i].
plink)
delete joint_info[
i].plink;
493 if(subchains)
delete subchains;
495 if(all_acc_types)
delete[] all_acc_types;
497 cerr <<
"[" << rank <<
"] inertia_wait_time = " << inertia_wait_time << endl;
498 cerr <<
"[" << rank <<
"] acc_wait_time = " << acc_wait_time << endl;
499 cerr <<
"[" << rank <<
"] force_wait_time = " << force_wait_time << endl;
504 virtual void Clear();
517 int Update(
double timestep, std::vector<class SDContactPair*>& sdContactPairs);
523 int Schedule(
Joint** joints);
529 int AssignProcesses(
int max_procs = 1);
534 void DumpSchedule(ostream& ost);
542 int ConstraintForces(
fVec& cf);
545 _pjoints[0] = joint_info[_joint->
i_joint].pjoints[0];
546 _pjoints[1] = joint_info[_joint->
i_joint].pjoints[1];
553 virtual int init(SceneGraph* sg);
557 virtual int clear_data();
558 virtual int clear_contact();
562 void default_schedule_virtual(
Joint* j);
563 void setup_pjoint(
Joint* j);
564 void setup_pjoint_virtual(
Joint* j);
567 void update_position();
568 void update_velocity();
572 void update_collision();
591 for(joint_list::iterator j=contact_vjoints.begin(); j!=contact_vjoints.end(); count++, j++)
593 if(_jnt == *j)
return count;
607 double inertia_wait_time;
608 double acc_wait_time;
609 double force_wait_time;
613 MPI_Datatype* all_acc_types;
pSim()
Default constructor.
joint_list contact_vjoints
pJoint(Joint *_joint, Joint *_link_side)
std::list< class pSubChain * > subchain_list
int resize(int i, int j)
Changes the matrix size.
int contact_vjoint_index(Joint *_jnt)
std::vector< Joint * > joint_list
void calc_acc(const fVec3 &g0)
pSubChain(pSim *_sim, pSubChain *_p, pJoint *_p0, pJoint *_p1)
pSubChain(pSim *_sim, pSubChain *_p, pLink *_pl)
std::vector< fVec3 > all_jdot_r
std::vector< fVec3 > contact_relvels
std::vector< fVec3 > all_jdot_v
void resize(int i)
Change the size.
int parent_side
link is in parent side?
3x3 matrix and 3-element vector classes.
Classes for defining open/closed kinematic chains.
std::vector< class pJoint * > p_joint_list
Class for representing "handle"; two pJoint instances are attached to both sides of each joint...
Joint * link_side
null in parent side of space joint
The class representing the whole mechanism. May contain multiple characters.
void zero()
Creates a zero vector.
std::vector< double > fric_coefs
pSubChain * subchain
the subchain which only contains the link associated with this pjoint
Main class for forward dynamics computation.
#define N_FRIC_CONE_DIV
Number of vertices of the friction cone approximation.
The class for representing a joint.
int i_joint
index of the joint
int get_outer_index(pJoint *pj)
int * outer_joints_origin
std::vector< fMat > all_Jr
void identity()
Creates an identity matrix (only for square matrices).
std::vector< fMat > all_Jv
void GetPJoint(Joint *_joint, pJoint *_pjoints[2])
Matrix of generic size. The elements are stored in a one-dimensional array in row-major order...
Node for schedule tree; represents a partial chain.
Class for representing a single link in a schedule tree.