Institut de Robòtica i Informàtica Industrial
KRD Group

The CuikSuite Project

mechanism.c File Reference

Implementaton of the function operating on Tmechanism. More...

#include "mechanism.h"
#include <string.h>

Go to the source code of this file.

Functions

void InitMechanism (Tmechanism *m)
 Constructor.
unsigned int GetMechanismNLinks (Tmechanism *m)
 Gets the number of links of a mechanism.
unsigned int GetMechanismNJoints (Tmechanism *m)
 Gets the number of joints of a mechanism.
unsigned int GetMechanismNBodies (Tmechanism *m)
 Gets the number of convex sub-parts (or bodies) of a mechanism.
unsigned int GetLinkID (char *name, Tmechanism *m)
 Gets the identifier of a link given its name.
signed int GetMechanismDOF (Tmechanism *m)
 Computes the degrees of freedom of a given mechanism.
void GetMechanismDefiningPoint (unsigned int lID, unsigned int bID, unsigned int pID, double *p, Tmechanism *m)
 Gets a point from the mechanism.
unsigned int AddLink2Mechanism (Tlink *l, Tmechanism *m)
 Adds a link to a mechanism.
unsigned int AddJoint2Mechanism (Tjoint *j, Tmechanism *m)
 Adds a joint to a mechanism.
unsigned int AddBody2Mechanism (unsigned int lID, Tcpolyhedron *b, Tmechanism *m)
 Adds a convex sub-part to a mechanism.
TlinkGetMechanismLink (unsigned int i, Tmechanism *m)
 Gets a link given its identifier.
TjointGetMechanismJoint (unsigned int i, Tmechanism *m)
 Gets a joint given its identifier.
double GetMechanismMaxCoordinate (Tmechanism *m)
 Returns the sum of the maximum coordinate value for all the links and joints in the mechanism.
void PlotMechanism (Tplot3d *pt, double axesLength, Tmechanism *m)
 Adds a mechanism to a 3d scene.
void RegenerateMechanismSolution (TCuikSystem *cs, double *sol, Tmechanism *m)
 Computes the values for the non-system variables used to represent the rotation matrices for all links in the mechanism.
void MoveMechanism (Tplot3d *pt, TCuikSystem *cs, double *sol, double **r, Tmechanism *m)
 Displaces a mechanism in a 3d scene.
void DeleteMechanism (Tmechanism *m)
 Destructor.

Detailed Description

Implementaton of the function operating on Tmechanism.

See also:
Tmechanism, mechanism.h.

Definition in file mechanism.c.


Function Documentation

void InitMechanism ( Tmechanism m  ) 

Defines an empty mechanism.

Parameters:
m The mechanism to initialize.

Definition at line 16 of file mechanism.c.

References CopyVoidPtr(), DeleteVoidPtr(), INIT_NUM_JOINTS, INIT_NUM_LINKS, InitVector(), Tmechanism::joints, Tmechanism::links, Tmechanism::maxCoord, and Tmechanism::nbodies.

Referenced by InitWorld().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int GetMechanismNLinks ( Tmechanism m  ) 

Gets the number of links of a mechanism.

Parameters:
m The mechanism to query.
Returns:
The number of links of a mechanism.

Definition at line 24 of file mechanism.c.

References Tmechanism::links, and VectorSize().

Referenced by AddLink2Mechanism(), DeleteMechanism(), GetLinkID(), GetMechanismDOF(), MoveMechanism(), PlotMechanism(), and RegenerateMechanismSolution().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int GetMechanismNJoints ( Tmechanism m  ) 

Gets the number of joints of a mechanism.

Parameters:
m The mechanism to query.
Returns:
The number of joints of a mechanism.

Definition at line 29 of file mechanism.c.

References Tmechanism::joints, and VectorSize().

Referenced by AddJoint2Mechanism(), DeleteMechanism(), GenerateKinTree(), GetMechanismDOF(), MoveMechanism(), PlotMechanism(), and RegenerateMechanismSolution().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int GetMechanismNBodies ( Tmechanism m  ) 

Gets the number of convex sub-parts of a mechanism added all over the links of the mechanism.

Parameters:
m The mechanism to query.
Returns:
The number of convex bodies of a mechanism.

Definition at line 34 of file mechanism.c.

References Tmechanism::nbodies.

unsigned int GetLinkID ( char *  name,
Tmechanism m 
)

Gets the identifier of a link given its name.

Parameters:
name The name of the link.
m The mechanisms to query
Returns:
The identifier of the link with the given name or NO_UINT if the mechanisms does not include any link with that name.

Definition at line 39 of file mechanism.c.

References FALSE, GetLinkName(), GetMechanismLink(), GetMechanismNLinks(), NO_UINT, and TRUE.

Referenced by GetWorldLinkID().

Here is the call graph for this function:

Here is the caller graph for this function:

signed int GetMechanismDOF ( Tmechanism m  ) 

Computes the degrees of freedom of a mechanism.

The degrees of freedom are computed as 6 per link (but for the ground link) less the degrees of freedom reduced by the joints (6-the degrees of freedom of the joint given by GetJointDOF). Of course, this computation assumes that all link dimensions are general. For special link sizes/joint points the mechanisms can have more degrees of freedom than the returned by this function (i.e., the mechanism can be architecturally singular).

Parameters:
m The mechanism to query.
Returns:
The degrees of freedom of the mechanism.

Definition at line 62 of file mechanism.c.

References GetJointDOF(), GetMechanismJoint(), GetMechanismNJoints(), and GetMechanismNLinks().

Referenced by GetWorldDOF().

Here is the call graph for this function:

Here is the caller graph for this function:

void GetMechanismDefiningPoint ( unsigned int  lID,
unsigned int  bID,
unsigned int  pID,
double *  p,
Tmechanism m 
)

Gets a 3d point from the mechanism, i.e., from a convex body of a link of the mechanism.

Note that identifier are numbered form 0.

Parameters:
lID Identifier of the link.
bID Identifier of the convex body.
pID Identifier of the point.
p 3d vector where to store the point.
m The mechanisms to query.

Definition at line 77 of file mechanism.c.

References GetCPolyhedronDefiningPoint(), GetLinkBody(), and GetMechanismLink().

Here is the call graph for this function:

unsigned int AddLink2Mechanism ( Tlink l,
Tmechanism m 
)

Adds a link to a mechanism.

Parameters:
l The link to add.
m The mechanism to update.
Returns:
The identifier assigned to the new link (in principle this is the position of the vector of links where the new link is stored).

Definition at line 83 of file mechanism.c.

References CopyLink(), GetLinkMaxCoordinate(), GetMechanismNLinks(), Tmechanism::links, Tmechanism::maxCoord, NEW, and SetVectorElement().

Referenced by AddLink2World().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int AddJoint2Mechanism ( Tjoint j,
Tmechanism m 
)

Adds a joint to a mechanism.

Parameters:
j The joint to add.
m The mechanism to update.
Returns:
The identifier assigned to the new joint (in principle this is the position of the vector of joints where the new joint is stored).

Definition at line 98 of file mechanism.c.

References CopyJoint(), GetJointMaxCoordinate(), GetMechanismNJoints(), Tmechanism::joints, Tmechanism::maxCoord, NEW, and SetVectorElement().

Referenced by AddJoint2World(), and GenerateKinTree().

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int AddBody2Mechanism ( unsigned int  lID,
Tcpolyhedron b,
Tmechanism m 
)

Adds a convex sub-part to a mechanism.

Parameters:
lID The link where the new sub-part has to be added.
b The convex sub-part to add.
m The mechanism to update.
Returns:
The total number of convex bodies in the mechanism after adding the new body.

Definition at line 113 of file mechanism.c.

References AddBody2Link(), Error(), GetLinkMaxCoordinate(), GetMechanismLink(), Tmechanism::maxCoord, and Tmechanism::nbodies.

Here is the call graph for this function:

Tlink* GetMechanismLink ( unsigned int  i,
Tmechanism m 
)

Gets a link given its identifier.

Parameters:
i The identifier of the link to retrive.
m The mechanism to query.
Returns:
A pointer to the link with the given identifier or NULL if there is no link with the provided identifier.

Definition at line 131 of file mechanism.c.

References GetVectorElement(), and Tmechanism::links.

Referenced by AddBody2Mechanism(), DeleteMechanism(), GenerateEquationsFromBranch(), GenerateKinTree(), GetLinkID(), GetMechanismDefiningPoint(), GetWorldLink(), InitWorldKinCS(), MoveMechanism(), PlotMechanism(), and RegenerateMechanismSolution().

Here is the call graph for this function:

Here is the caller graph for this function:

Tjoint* GetMechanismJoint ( unsigned int  i,
Tmechanism m 
)

Gets a joint given its identifier.

Parameters:
i The identifier of the joint to retrive.
m The mechanism to query.
Returns:
A pointer to the joint with the given identifier or NULL if there is no joint with the provided identifier.

Definition at line 142 of file mechanism.c.

References GetVectorElement(), and Tmechanism::joints.

Referenced by Branch2Link(), DeleteMechanism(), GenerateKinTree(), GetMechanismDOF(), InitWorldKinCS(), IsRevoluteBinaryLink(), MoveMechanism(), PlotMechanism(), and RegenerateMechanismSolution().

Here is the call graph for this function:

Here is the caller graph for this function:

double GetMechanismMaxCoordinate ( Tmechanism m  ) 

Returns the sum of the maximum coordinate value for all the links and joints in the mechanism. This is used in higher levels to define an over-estimate bounding-box of the mechanism. This bounding box is used to define the ranges for some of the coordinate and separating planes variables.

Parameters:
m The mechanism to query.
Returns:
The sum of the maximum coordinate values for all links and joints.

Definition at line 153 of file mechanism.c.

References Tmechanism::maxCoord.

Referenced by GenerateWorldEquationSystems().

Here is the caller graph for this function:

void PlotMechanism ( Tplot3d pt,
double  axesLength,
Tmechanism m 
)

Adds a mechanism to a 3d scene. All convex parts of all links are added using the same frame of reference (i.e, the global one) and thus they will be displayed colliding unless they are moved.

Parameters:
pt The 3d scene where to add the mechanism.
axesLength Length for the axes for each link. 0 not to display them.
m The mechanism display.
See also:
MoveMechanism

Definition at line 158 of file mechanism.c.

References Close3dBlock(), GetMechanismJoint(), GetMechanismLink(), GetMechanismNJoints(), GetMechanismNLinks(), PlotJoint(), PlotLink(), and Start3dBlock().

Referenced by PlotWorld().

Here is the call graph for this function:

Here is the caller graph for this function:

void RegenerateMechanismSolution ( TCuikSystem cs,
double *  sol,
Tmechanism m 
)

Solution points only include values for the system variables. However, in some formulations, the frame of reference for each link is represented using not only system variables, but dummy variable too. This function computes the values for the link-related dummy variables form the system ones for all the links in the mechanism.

Parameters:
cs The cuik system on which the solutions are defiened. It is used to, given the name of the variables corresponding the reference frame of the given link, retrive its numerical identifiers, i.e., the number of range of the box to use to instantiate each variable.
sol The solution point with the values for the system variables. At the end of the function, this vector also has values for the link-related dummy variables.
m The mechanism.

Definition at line 190 of file mechanism.c.

References GetMechanismJoint(), GetMechanismLink(), GetMechanismNJoints(), GetMechanismNLinks(), IsGroundLink, RegenerateJointSolution(), and RegenerateLinkSolution().

Referenced by MoveWorld().

Here is the call graph for this function:

Here is the caller graph for this function:

void MoveMechanism ( Tplot3d pt,
TCuikSystem cs,
double *  sol,
double **  r,
Tmechanism m 
)

Displaces a mechanism previously added to a 3d scene to a given solution piont.

Parameters:
pt The 3d scene where the apply the displacement.
cs The cuik system on which the solutions are defiend. It is used to, given the name of the variables corresponding the reference frame of the given link, retrive its numerical identifiers, i.e., the number of range of the box to use to instantiate each variable.
sol The solution point. Only values for system variables are used.
r Array of 3d vectors with the translation for each one of the reference frames associated with each link.
m The mechanism to move.

Definition at line 214 of file mechanism.c.

References Close3dBlock(), GetMechanismJoint(), GetMechanismLink(), GetMechanismNJoints(), GetMechanismNLinks(), MoveJoint(), MoveLink(), and Start3dBlock().

Referenced by MoveWorld().

Here is the call graph for this function:

Here is the caller graph for this function:

void DeleteMechanism ( Tmechanism m  ) 

Deletes the information stored in a mechanism and frees the allocated memory.

Parameters:
m The mechanism to delete.

Definition at line 249 of file mechanism.c.

References DeleteJoint(), DeleteLink(), DeleteVector(), GetMechanismJoint(), GetMechanismLink(), GetMechanismNJoints(), GetMechanismNLinks(), Tmechanism::joints, and Tmechanism::links.

Referenced by DeleteWorld().

Here is the call graph for this function:

Here is the caller graph for this function: