world.h File Reference

Detailed Description

Definition of the Tworld type and the associated functions.

See Also
Tworld, world.c.

Definition in file world.h.

Data Structures

struct  TBranchStep
 A step in a kinematic branch. More...
 
struct  Tbranch
 A kinematic branch. More...
 
struct  Tworld
 All the necessary information to generate equations for mechanisms. More...
 

Macros

#define INITIAL_FRAME_DELAY   5.0
 When generating 3d animations, delay before starting the animation. More...
 
#define FRAME_RATE   (1.0/10)
 When generating 3d animations, frame rate. More...
 
#define FINAL_FRAME_DELAY   500.0
 When generating 3d animations, delay between the end of the animation and the exit of the animation browser. More...
 
#define WORLD_IN_DEFINITION   0
 One of the stages of the Tworld structure definition. More...
 
#define WORLD_DEFINED   1
 One of the stages of the Tworld structure definition. More...
 
#define COUPLE_LENGTH   0
 One of the possible variables to couple in tensegrities. More...
 
#define COUPLE_REST   1
 One of the possible variables to couple in tensegrities. More...
 
#define COUPLE_FORCE   2
 One of the possible variables to couple in tensegrities. More...
 
#define COUPLE_ORIENTATION   3
 One of the possible variables to couple in tensegrities. More...
 
#define LEG   0
 One of the possible types of legs. More...
 
#define PRISMATIC_LEG   1
 One of the possible types of legs. More...
 
#define STRUT   2
 One of the possible types of legs. More...
 
#define BAR   3
 One of the possible types of legs. More...
 
#define CABLE   4
 One of the possible types of legs. More...
 
#define SPRING   5
 One of the possible types of legs. More...
 
#define PRISMATIC_BAR   6
 One of the possible types of legs. More...
 

Functions

void InitWorld (Tworld *w)
 Constructor. More...
 
boolean InitWorldFromFile (Tparameters *p, boolean error, char *fn, Tworld *w)
 Constructor. More...
 
boolean InitTensegrityFromFile (Tparameters *p, char *fn, Tworld *w)
 Constructor. More...
 
unsigned int AddLink2World (Tlink *l, boolean object, Tworld *w)
 Adds a link to the mechanism in the world. More...
 
unsigned int AddJoint2World (Tjoint *j, Tworld *w)
 Adds a joint to the mechanism in the world. More...
 
void AddLeg2World (char *name, boolean planar, unsigned int type, unsigned int lID1, unsigned int lID2, double **points, Tinterval *length, double stiffness, Tinterval *rest, Tinterval *force, double radius, unsigned int gr, Tcolor *color, unsigned int bs, Tworld *w)
 Adds a sph-sph joint to the world. More...
 
void AddObstacle2World (char *name, Tpolyhedron *o, Tworld *w)
 Adds an obstacle to the environment in the world. More...
 
unsigned int GetWorldMobility (Tworld *w)
 Returns the number of degrees of freedom of the mechanism in the world. More...
 
boolean IsMechanismInWorldAllSpheres (Tworld *w)
 TRUE if the mechanisms in the world is based on spheres. More...
 
unsigned int GetWorldLinkID (char *linkName, Tworld *w)
 Gets the identifier of a link from its name. More...
 
unsigned int GetWorldObstacleID (char *obsName, Tworld *w)
 Gets the identifier of an obstacle from its name. More...
 
TlinkGetWorldLink (unsigned int linkID, Tworld *w)
 Gets a link from its identifier. More...
 
TjointGetWorldJoint (unsigned int jointID, Tworld *w)
 Gets a joint from its identifier. More...
 
unsigned int GetWorldNLinks (Tworld *w)
 Gets the number of links in the mechanism included in the world. More...
 
unsigned int GetWorldNJoints (Tworld *w)
 Gets the number of joints in the mechanism included in the world. More...
 
unsigned int GetWorldNObstacles (Tworld *w)
 Gets the number of obstacles in the environment included in the world. More...
 
unsigned int GetWorldNConvexBodiesInLinks (Tworld *w)
 Gets the number of convex polyhedrons that define the mechanism included in the world. More...
 
unsigned int GetWorldNConvexBodies (Tworld *w)
 Gets the number of convex polyhedrons that define the mechanism and the environment included in the world. More...
 
unsigned int GetWorldNDOF (Tworld *w)
 Gets the number of degrees of freedom in the world. More...
 
void GetWorldRangeDOF (unsigned int ndof, Tinterval *r, Tworld *w)
 Gets the range for a given degree of freedom. More...
 
void GetWorldJointLabel (unsigned int ndof, char **string, Tworld *w)
 Returns a label identifying each joint. More...
 
void GetWorldDOFLabel (unsigned int ndof, char **string, Tworld *w)
 Returns a label identifying each degree of freedom. More...
 
boolean IsWorldPolynomial (Tworld *w)
 Checks if the system of equations is polynomial. More...
 
void CheckAllCollisions (unsigned int fl, unsigned int fo, Tworld *w)
 Activates all the possible collision between links and links and obstacles. More...
 
void NoCheckAllCollisions (unsigned int fl, unsigned int fo, Tworld *w)
 Desactivates all the possible collision between links and links and obstacles. More...
 
boolean AnyCollision (Tworld *w)
 Determines if we want to avoid any collision. More...
 
void PrintCollisions (FILE *f, Tworld *w)
 Stores the collision information into a file. More...
 
void CheckSelfCollisions (unsigned int fl, Tworld *w)
 Activates all the possible collision between links. More...
 
void NoCheckSelfCollisions (unsigned int fl, Tworld *w)
 Desactivates all the possible collision between links. More...
 
void CheckLinkLinkCollision (unsigned int a, unsigned int b, Tworld *w)
 Activates the possible collision between a particular pair of links. More...
 
void NoCheckLinkLinkCollision (unsigned int a, unsigned int b, Tworld *w)
 Desactivates the possible collision between a particular pair of links. More...
 
void CheckLinkObstacleCollision (unsigned int a, unsigned int b, Tworld *w)
 Activates the possible collision between a particular link and an object in the environment. More...
 
void NoCheckLinkObstacleCollision (unsigned int a, unsigned int b, Tworld *w)
 Desactivates the possible collision between a particular link and an object in the environment. More...
 
void CheckObstacleCollision (unsigned int fl, unsigned int b, Tworld *w)
 Activates the possible collision between a particular obstacle and all the links. More...
 
void NoCheckObstacleCollision (unsigned int fl, unsigned int b, Tworld *w)
 Deactivates the possible collision between a particular obstacle and all the links. More...
 
void NoCheckConnectedCollisions (unsigned int fl, Tworld *w)
 Desactivates the collision detection between connected links. More...
 
void InitWorldCD (Tparameters *pr, unsigned int mt, Tworld *w)
 Initializes the collision detector. More...
 
boolean WorldCanCollide (Tworld *w)
 Determines if any collision is potentially possible. More...
 
void GetLinkTransformsFromSolutionPoint (Tparameters *p, boolean simp, double *sol, THTransform **tl, TLinkConf **def, Tworld *w)
 Define transforms for the links from the a solution point. More...
 
unsigned int GetSolutionPointFromLinkTransforms (Tparameters *p, THTransform *tl, TLinkConf *def, double **sol, Tworld *w)
 Determines the mechanisms configuration from the pose of all links. More...
 
void DeleteLinkTransforms (THTransform *tl, TLinkConf *def, Tworld *w)
 Deletes transforms for each link. More...
 
boolean WorldContinuousCD (Tworld *w)
 Determines the type of collision library used. More...
 
boolean MoveAndCheckCDFromTransforms (boolean all, unsigned int tID, THTransform *tl, TLinkConf *def, THTransform *tlPrev, TLinkConf *defPrev, Tworld *w)
 Checks a point for collision. More...
 
boolean MoveAndCheckCD (Tparameters *p, boolean all, unsigned int tID, double *sol, double *solPrev, Tworld *w)
 Checks a point for collision. More...
 
boolean NewtonInWorld (Tparameters *p, double *v, Tbox *b_sol, Tworld *w)
 Generates a sample from a the kinematic cuiksystem in the world using the Newton algorithm. More...
 
unsigned int GetWorldSystemVars (boolean **sv, Tworld *w)
 Gets the system vars of the kinematic cuiksystem. More...
 
unsigned int GetWorldVarTopology (unsigned int vID, Tworld *w)
 Get the topology of a given variable. More...
 
unsigned int GetWorldSimpVariableMask (Tparameters *p, boolean **sv, Tworld *w)
 Identifies pose related variable that survied in the simplified system. More...
 
void GetWorldVarNames (char **vn, Tworld *w)
 Return the variable names. More...
 
char * GetWorldSystemVarName (unsigned int nv, Tworld *w)
 Returns the name of a given system variable. More...
 
void GenerateWorldEquations (Tparameters *p, Tworld *w)
 Generates all the cuiksystems derived from the world information. More...
 
void GenerateForceEquilibriumEquations (Tparameters *p, Tworld *w)
 Adds force equilibrium equations. More...
 
unsigned int WorldForceVars (Tparameters *p, boolean **fv, Tworld *w)
 Creates a boolean array identifying force variables. More...
 
unsigned int WorldSimpKinematicVars (Tparameters *p, boolean **kv, Tworld *w)
 Creates a boolean array to identify kinematic variables. More...
 
unsigned int WorldForceVarsIndices (Tparameters *p, unsigned int **iv, Tworld *w)
 Creates an array with the indices of the force variables. More...
 
double WorldPotentialEnergy (Tparameters *p, boolean simp, double *sol, void *w)
 Evaluates the potential energy of a configuration. More...
 
void WorldForceField (Tparameters *p, boolean simp, double *sol, double **g, void *w)
 Evaluates the gradient of the potential energy of a configuration. More...
 
void WorldForceFieldProjectedGradient (Tparameters *p, boolean simp, double *proj, double *sol, double **g, void *w)
 The projected gradient of the force field. More...
 
void FixLinks (Tparameters *p, Tworld *w)
 Generate equations to fix some links. More...
 
void WorldFixTensegrityAddon (Tparameters *p, unsigned int linkID, double **point, unsigned int *n, Tworld *w)
 Fixes a tensegrity addon. More...
 
void FixZToZero (Tparameters *p, Tworld *w)
 Generate equations to fix the Z components of the links. More...
 
void WorldCoupleTensegrityVariable (Tparameters *p, unsigned int t, unsigned int lID1, unsigned int lID2, double scale, THTransform *r, Tworld *w)
 Couple variables from different elements of a tensegrity. More...
 
void GenerateWorldSingularityEquations (Tparameters *p, char *ln, TCuikSystem *cs, Tworld *w)
 Adds variables/equations to detect singularities. More...
 
void GenerateWorldTWSEquations (Tparameters *p, char *ln, TCuikSystem *cs, Tworld *w)
 Adds variables/equations to detect translational workspace boundaries. More...
 
void GetWorldJacobian (TJacobian *J, Tworld *w)
 Gets the kinematic Jacobian. More...
 
void GetWorldSimpJacobian (Tparameters *p, TJacobian *J, Tworld *w)
 Gets the simplified kinematic Jacobian. More...
 
unsigned int GetWorldSimpTopology (Tparameters *p, unsigned int **t, Tworld *w)
 Gets the topology of the variables. More...
 
unsigned int GetWorldTopology (Tparameters *p, unsigned int **t, Tworld *w)
 Gets the topology of the variables. More...
 
unsigned int WorldDOFTopology (unsigned int **t, Tworld *w)
 Gets the topology of the degrees of freedom. More...
 
void GetWorldKinJacobian (Tparameters *p, unsigned int *nr, unsigned int *nc, Tequation ***J, Tworld *w)
 Gets the simplified kinematic Jacobian. More...
 
unsigned int WorldSimpCuikNewton (Tparameters *p, double *pt, Tworld *w)
 Tries to reach the kinematic manifold. More...
 
void EvaluateWorldJacobian (double *p, double ***J, Tworld *w)
 Evaluates the kinematic Jacobian. More...
 
void WorldEvaluateEquations (double *pt, double *r, Tworld *w)
 Evaluates the kinematic equations. More...
 
boolean WorldInequalitiesHold (double *pt, Tworld *w)
 Check if the inequalities hold. More...
 
boolean WorldSimpInequalitiesHold (Tparameters *p, double *pt, Tworld *w)
 Check if the inequalities hold for the simplified system. More...
 
double WorldErrorInSimpInequalities (Tparameters *p, double *pt, Tworld *w)
 Determines the maximum error in the inequalites for the simplified system. More...
 
void WorldEvaluateSimpEquations (Tparameters *p, double *pt, double *r, Tworld *w)
 Evaluates the simplified kinematic equations. More...
 
void WorldEvaluateSubSetSimpEquations (Tparameters *p, boolean *se, double *pt, double *r, Tworld *w)
 Evaluates a subset of the simplified kinematic equations. More...
 
double WorldErrorInEquations (double *pt, Tworld *w)
 Evalates the norm of the error in the kinematic equations for a given point. More...
 
double WorldErrorInSimpEquations (Tparameters *p, double *pt, Tworld *w)
 Evalates the norm of the error in the kinematic equations for a given point. More...
 
double WorldErrorFromDOFs (Tparameters *p, double *dof, Tworld *w)
 Error in equations from DOFs. More...
 
double EvaluateWorldCost (Tparameters *p, boolean simp, double *pt, void *w)
 Evaluates the functions cost defined in a world. More...
 
unsigned int GetWorldNumVariables (Tworld *w)
 Number of variables in the kinematic subsystem. More...
 
unsigned int GetWorldNumSystemVariables (Tworld *w)
 Number of system variables in the kinematic subsystem. More...
 
unsigned int RegenerateWorldOriginalPoint (Tparameters *p, double *s, double **o, Tworld *w)
 Reconstruct a point in original kinematic system from a simplified point. More...
 
unsigned int RegenerateWorldOriginalSystemPoint (Tparameters *p, double *s, double **o, Tworld *w)
 Reconstruct a point in original kinematic system from a simplified point. More...
 
unsigned int WorldGenerateSimplifiedPoint (Tparameters *p, double *o, double **s, Tworld *w)
 Reconstruct a point in simplified kinematic system from an original point. More...
 
unsigned int WorldGenerateSimplifiedPointFromSystem (Tparameters *p, double *o, double **s, Tworld *w)
 Reconstruct a point in simplified kinematic system from an original point. More...
 
void GetWorldInitialBox (Tbox *b, Tworld *w)
 Gets the kinematic search space for a given problem. More...
 
void GetWorldSimpInitialBox (Tparameters *p, Tbox *b, Tworld *w)
 Gets the kinematic simplified search space for a given problem. More...
 
unsigned int WorldManifoldDimension (Tparameters *p, double *point, Tworld *w)
 Dimensionality of the solution manifold.+. More...
 
unsigned int MaxWorldReduction (Tparameters *p, Tbox *b, double *reduction, Tworld *w)
 Reduces the system variables as much as possible using the kinematic constraints. More...
 
void PlotWorld (Tparameters *pr, Tplot3d *pt, double axesLength, Tworld *w)
 Adds a world (environment plus mechanism) in a 3D scene. More...
 
unsigned int RegenerateWorldSolutionPoint (Tparameters *pr, double *p, double **v, Tworld *w)
 Computes the missing values in a kinematic solution. More...
 
void WorldPrintAtoms (Tparameters *pr, FILE *f, double *pt, Tworld *w)
 Generates a file with the atom centers in global coordiantes. More...
 
void WorldStoreRigidGroups (Tparameters *pr, FILE *f, double *pt, Tworld *w)
 Generates a file with the atoms grouped in rigid clusters. More...
 
void WorldAtomJacobian (Tparameters *pr, double *sol, unsigned int *nr, unsigned int *nc, double ***J, Tworld *w)
 Jacobian of the atom position w.r.t. the variables. More...
 
void MoveWorld (Tparameters *pr, Tplot3d *pt, Tbox *b, Tworld *w)
 Moves the mechanisms defined in a world information to a given configuration. More...
 
void PrintWorldAxes (Tparameters *pr, FILE *f, Tbox *b, Tworld *w)
 Prints the axes of the mechanism. More...
 
void PrintWorldCollisionInfo (FILE *f, char *fname, Tworld *w)
 Prints information collected durint last collision check. More...
 
void MoveWorldDOF (Tparameters *pr, Tplot3d *pt, double *dof, Tworld *w)
 Moves a mechanisms to a configuration given by the degrees of freedom. More...
 
unsigned int WorldDOF2Sol (Tparameters *p, double *dof, double **sol, Tbox *b, Tworld *w)
 Transforms from degrees of freedom to cuik variables. More...
 
void WorldSample2DOF (Tparameters *p, double *sample, double *dof, Tworld *w)
 Transforms a sample degrees of freedom. More...
 
void AnimateWorld (Tparameters *pr, char *pname, double axesLength, double frameDelay, Tlist *p, Tworld *w)
 Produces an animation along a path. More...
 
void PrintWorldCS (Tparameters *p, char *fname, Tworld *w)
 Prints the cuiksystems derived from a world. More...
 
void PrintWorld (char *fname, int argc, char **arg, Tworld *w)
 Prints the world. More...
 
void DeleteWorld (Tworld *w)
 Destructor. More...
 

Macro Definition Documentation

#define INITIAL_FRAME_DELAY   5.0

When generating 3d animations, delay before starting the animation (in seconds).

Definition at line 39 of file world.h.

Referenced by AnimateWorld().

#define FRAME_RATE   (1.0/10)

When generating 3d animations, frames per second.

Definition at line 45 of file world.h.

Referenced by AnimateWorld().

#define FINAL_FRAME_DELAY   500.0

When generating 3d animations, delay between the end of the animation and the exit of the animation browser (in seconds).

Definition at line 53 of file world.h.

Referenced by AnimateWorld().

#define COUPLE_LENGTH   0

Use when the length of some tensegrity elements must be the same. This only make sense when the length of both elements is variable.

Definition at line 77 of file world.h.

Referenced by WorldCoupleTensegrityVariable().

#define COUPLE_REST   1

Use when the rest length of some tensegrity elements must be the same. This only make sense when the rest lengh of both elements is variable.

Definition at line 85 of file world.h.

Referenced by WorldCoupleTensegrityVariable().

#define COUPLE_FORCE   2

Use when the force of some tensegrity elements must be the same. This only make sense when the force of both elements is variable.

Definition at line 93 of file world.h.

Referenced by WorldCoupleTensegrityVariable().

#define COUPLE_ORIENTATION   3

Use when the orientation of some tensegrity elements must be the same. This only make sense when the orientation of both elements is variable.

Todo:
Generalize the orientation constraint betwee tensegrity elements so that we can set a fixed rotation between them.

Definition at line 104 of file world.h.

Referenced by WorldCoupleTensegrityVariable().

#define LEG   0

One of the possible types of legs. This is the normal leg with fixed length used for parallel platforms. No force information is associated.

Definition at line 115 of file world.h.

Referenced by AddLeg2World().

#define PRISMATIC_LEG   1

One of the possible types of legs. This is the normal leg with variable length used for parallel platforms. The range of extension must be realistic: range of displacements below the minimum extension. No force information is associated.

Definition at line 126 of file world.h.

Referenced by AddLeg2World().

#define STRUT   2

One of the possible types of legs. This is a fixed length tensegrity element which can only support compression.

Definition at line 134 of file world.h.

Referenced by AddLeg2World().

#define BAR   3

One of the possible types of legs. This is a fixed length tensegrity element which can support both tension and compression.

Definition at line 142 of file world.h.

Referenced by AddLeg2World().

#define CABLE   4

One of the possible types of legs. This is a fixed/variable length tensegrity element which can only support tensions.

Definition at line 150 of file world.h.

Referenced by AddLeg2World().

#define SPRING   5

One of the possible types of legs. This is a variable length tensegrity element which can only support tension. The difference with cables is that the length is always variable and the representation.

Definition at line 159 of file world.h.

Referenced by AddLeg2World().

#define PRISMATIC_BAR   6

One of the possible types of legs.

This is a variable length tensegrity element which can support both tension and compression. It is basically a prismatic bar. The range of extension must be realistic: range of displacements below the minimum extension.

Definition at line 171 of file world.h.

Referenced by AddLeg2World().

Function Documentation

void InitWorld ( Tworld w)

Initializes an empty world.

The expected way to initialize worlds is using the InitWorldFromFile function. If you decide to do it yourself (i.e., using InitWorld and then adding links, joints, obstacles, etc) the function GenerateWorldEquations when all the information is already added to the world. Once this function is called no more information (links, joints, etc) can be possibly added to the world.

Parameters
wThe world to initialize.

Definition at line 1358 of file world.c.

References Tworld::branch2Link, Tworld::checkCollisionsLL, Tworld::checkCollisionsLO, Tworld::e, Tworld::endEffector, InitEnvironment(), InitMechanism(), Tworld::m, Tworld::nb, Tworld::nj, Tworld::nl, Tworld::no, NO_UINT, Tworld::np, Tworld::nsvars, Tworld::nvars, Tworld::stage, Tworld::systemVars, Tworld::wcd, and WORLD_IN_DEFINITION.

Referenced by InitWorldFromMolecule(), and main().

boolean InitWorldFromFile ( Tparameters p,
boolean  error,
char *  fn,
Tworld w 
)

Initializes an world from the information stored in a .world file.

This is the intended way to initialize worlds. See the comments in InitWorld.

We don't have documentation yet about how to define world files. Please, have a look to the examples directory.

Parameters
pA set of parameters. Used, for instance, when defining the equations (dummification level, etc).
errorTRUE if the execution must be aborted if the file does not exist.
fnThe name of the file from where to read the information.
wThe world to initialize.
Returns
TRUE if the world file could actually be read. If the file exists but there is an error reading the file, this function throws an exception an aborts the execution.

Referenced by InitCSWDFromFile(), and main().

boolean InitTensegrityFromFile ( Tparameters p,
char *  fn,
Tworld w 
)

Initializes an world from the information stored in a .tens file (a file describing a tensegrity structure).

The utilities to deal with tensegrities are implemented in the src/CuikTensegrity folder and they are only used if the cuik-tensegrity library is available.

We don't have documentation yet about how to define tensegrity files. Please, have a look to the examples directory.

Todo:
Right now we use a link-based representation for tensegrities since it is clear and close to the representations used for parallel platforms. In this way, the integration of the tensegrities in the CuikSuite is relatively simpel. However this representation uses too many variables. We could think on implementing a particular type of representation for tensegrities based on representing only the coordinates of the tensegrity nodes. This will be more compact. However it introduces complexity in the translation from/to degrees of freedom and other related procedues. In this yet to implement representatoin we need coordinates (x,y,z) for the tensegrity nodes, the norm of the tensegrity elements l=||n_1-n_2|| (which can be fixed or variable) and auxiliary variable 'd' such that l*d=l-r, with r the rest length. with this variable the force of an element is f=k*d*n_1-k*d*n_2, with n1, n2 the coordiantes of the connected nodes. The main issue with this representation is the absence of loops which is a core-assumption in the CuikSuite.
Parameters
pA set of parameters. Used, for instance, when defining the equations (dummification level, etc).
fnThe name of the file from where to read the information.
wThe world to initialize.
Returns
TRUE if the tensegrity file could be actually read.

Referenced by main().

unsigned int AddLink2World ( Tlink l,
boolean  object,
Tworld w 
)

Adds a link to the mechanism in the world.

Parameters
lThe link to add.
objectTRUE if the link has to be used as the object being manipulated by the rest of the mechanisms. This can be also seen as the end effector. Each mechanism only manipulates one object, the last link declared as such.
wThe world to update.
Returns
The identifier assigned to the new link.

Definition at line 1383 of file world.c.

References AddLink2Mechanism(), Tworld::checkCollisionsLL, Tworld::checkCollisionsLO, Tworld::endEffector, Error(), FALSE, GetLinkName(), GetWorldLinkID(), LinkNBodies(), Tworld::m, MEM_EXPAND, Tworld::nb, NEW, Tworld::nl, Tworld::no, NO_UINT, Tworld::np, Tworld::stage, and WORLD_IN_DEFINITION.

Referenced by AddLeg2World(), InitWorldFromMolecule(), and main().

unsigned int AddJoint2World ( Tjoint j,
Tworld w 
)

Adds a joint to the mechanism in the world.

Parameters
jThe joint to add.
wThe world to update.
Returns
The identifier assigned to the new joint.

Definition at line 1436 of file world.c.

References AddJoint2Mechanism(), Error(), Tworld::m, Tworld::nj, Tworld::stage, and WORLD_IN_DEFINITION.

Referenced by AddLeg2World(), InitWorldFromMolecule(), and main().

void AddLeg2World ( char *  name,
boolean  planar,
unsigned int  type,
unsigned int  lID1,
unsigned int  lID2,
double **  points,
Tinterval length,
double  stiffness,
Tinterval rest,
Tinterval force,
double  radius,
unsigned int  gr,
Tcolor color,
unsigned int  bs,
Tworld w 
)

Adds the links and joints defining a composite spherical-sphercial joint to the world. Such joint is composed by two spherical joints connected by a cylindrical strut. This rotation of the cylinder about its axis is not relevant. Thus, this composite joint is useful to avoid representing irrelevant degrees of freedom (i.e., to obtain simpler equation systems).

Parameters
nameName for the link to generate. If NULL an default link name is used.
planarTRUE if the leg must be constrained to the XY plane.
typeType of leg: LEG, PRISMATIC_LEG, STRUT, BAR, CABLE, SPRING, PRISMATIC_BAR
lID1Identifier of the first link to connect.
lID2Identifier of the second link to connect.
pointsA point in the first link and a point in the second link given the position of the spherical joints.
lengthLength of the cylinder connecting the two spherical joints. Can be a range for cables (springs actually). Then this gives the deformation range. Must be positive. If not it is modified.
stiffnessStiffnes of the central element of the composite joint. Must be <0 for struts, >0 for cables, different from 0 for bars and 0 for non-tensegrity elements. If it is not in the correct range, it is modified.
restRest length for the central element. Must be positive. If not it is modified.
forceRange of forces that the central element can support. Must be <0 for struts, >0 for cables, different from 0 for bars and 0 for non-tensegrity elements. If it is not in the correct range, it is modified.
radiusRadius of the cylinder connecting the two sperical joints.
grGranularity to represent spheres and cylinders. For springs, it is used to give the number of loops of the spring.
colorColor of the cylinder connecting the two spherical joints.
bsBody status: normal, hidden, decoration, etc.
wThe world where to add the leg.

Definition at line 1446 of file world.c.

References Add2Color(), AddBody2Link(), AddJoint2World(), AddLink2World(), BAR, CABLE, CopyColor(), DECOR_SHAPE, DeleteColor(), DeleteJoint(), DeleteLink(), DeletePolyhedron(), Error(), FALSE, GetWorldLink(), GetWorldNJoints(), HIDDEN_SHAPE, INF, InitAxisXLink(), InitDeformXLink(), InitPrismaticXLink(), Intersection(), IntervalCenter(), IntervalSize(), LEG, LINEAR_FORCE, LowerLimit(), NEW, NewCylinder(), NewInterval(), NewRevLowJoint(), NewRevUpJoint(), NewSphere(), NewSphSphLowJoint(), NewSphSphUpJoint(), NewSpring(), NO_FORCE, PRISMATIC_BAR, PRISMATIC_LEG, SPRING, STRUT, UpperLimit(), VAR_FORCE, ZERO, and ZeroInterval().

void AddObstacle2World ( char *  name,
Tpolyhedron o,
Tworld w 
)

Adds an obstacle to the environment in the world.

Parameters
nameThe name of the obstacle.
oThe convex object representing the obstacle.
wThe world to update.

Definition at line 1788 of file world.c.

References AddShape2Environment(), Tworld::checkCollisionsLO, Tworld::e, Error(), FALSE, MEM_EXPAND, NEW, Tworld::nl, Tworld::no, Tworld::np, Tworld::stage, and WORLD_IN_DEFINITION.

unsigned int GetWorldMobility ( Tworld w)

Returns the number of degrees of freedom of the mechanism in the world. This consideres the presenceo of loops constraining the mobility.

Parameters
wThe world to query.
Returns
The number of degrees of freedom of the mechanism in the world.
See Also
GetMechanismMobility.

Definition at line 1822 of file world.c.

References GetMechanismMobility(), and Tworld::m.

boolean IsMechanismInWorldAllSpheres ( Tworld w)

Returns TRUE if the mechanisms in the world is composed by spheres only.

Parameters
wThe world to query.
Returns
TRUE if the mechanism in the world is sphere-based.

Definition at line 1827 of file world.c.

References IsMechanismAllSpheres(), and Tworld::m.

Referenced by main().

unsigned int GetWorldLinkID ( char *  linkName,
Tworld w 
)

Gets the identifier of a link from its name (NO_UINT if there is no link with the given name).

Parameters
linkNameThe name of the link.
wThe world to query.
Returns
The identifier assigned to the new link.

Definition at line 1832 of file world.c.

References GetLinkID(), and Tworld::m.

Referenced by AddLink2World(), and main().

unsigned int GetWorldObstacleID ( char *  obsName,
Tworld w 
)

Gets the identifier of an obstacle from its name (NO_UINT if there is no obstacle with the given name).

Parameters
obsNameThe name of the obstacle.
wThe world to query.
Returns
The identifier assigned to the new link.

Definition at line 1837 of file world.c.

References Tworld::e, and GetObstacleID().

Tlink* GetWorldLink ( unsigned int  linkID,
Tworld w 
)

Gets a pointer to a link in the mechanism included in the world from its identifier (NULL if there is no link with the given identifier).

Parameters
linkIDThe identifier of the link to retrive.
wThe world to query.
Returns
The pointer to the requested link, if any.

Definition at line 1842 of file world.c.

References GetMechanismLink(), and Tworld::m.

Referenced by AddLeg2World(), InitWorldFromMolecule(), main(), and WorldCoupleTensegrityVariable().

Tjoint* GetWorldJoint ( unsigned int  jointID,
Tworld w 
)

Gets a pointer to a joint in the mechanism included in the world from its identifier (NULL if there is no joint with the given identifier).

Parameters
jointIDThe identifier of the joint to retrive.
wThe world to query.
Returns
The pointer to the requested joint, if any.

Definition at line 1847 of file world.c.

References GetMechanismJoint(), and Tworld::m.

unsigned int GetWorldNLinks ( Tworld w)

Gets the number of links in the mechanism included in the world.

Parameters
wThe world to query.
Returns
The number of links in the mechanism included in the world.

Definition at line 1852 of file world.c.

References Tworld::nl.

unsigned int GetWorldNJoints ( Tworld w)

Gets the number of joints in the mechanism included in the world.

Parameters
wThe world to query.
Returns
The number of joints in the mechanism included in the world.

Definition at line 1857 of file world.c.

References Tworld::nj.

Referenced by AddLeg2World(), and main().

unsigned int GetWorldNObstacles ( Tworld w)

Gets the number of obstacles in the environment included in the world. Note that each obstacle is a convex polyhedron (see Tpolyhedron).

Parameters
wThe world to query.
Returns
The number of obstacles in the environment included in the world.

Definition at line 1862 of file world.c.

References Tworld::no.

unsigned int GetWorldNConvexBodiesInLinks ( Tworld w)

Each link can include more than one convex polyhedron. This function returns the sum of the number of convex polyhedrons defined over all links

Parameters
wThe world to query.
Returns
The number of convex bodies in the mechanism included in the world.

Definition at line 1867 of file world.c.

References Tworld::nb.

unsigned int GetWorldNConvexBodies ( Tworld w)

Each link can include more than one convex polyhedron. Moreover, the environment is also defined as a set of convex polyhedrons. This function returns the sum of the number of convex polyhedrons defined over all links and the environment.

Parameters
wThe world to query.
Returns
The number of convex parts in the mechanism and in the environment included in the world.

Definition at line 1872 of file world.c.

References Tworld::np.

unsigned int GetWorldNDOF ( Tworld w)

Gets the number of degrees of freedom in the world. Each joint introduces one or more degrees of freedom.

Note that this is different from GetWorldMobility. Here we return the sum of degrees of freedom of the joints.

Parameters
wThe world to query.
Returns
The number of degrees of freedom in the world.

Definition at line 1997 of file world.c.

References Tworld::ndof.

Referenced by main().

void GetWorldRangeDOF ( unsigned int  ndof,
Tinterval r,
Tworld w 
)

Returns the valid range for a given degree of freedom.

Parameters
ndofThe identifier for the degree of freedom.
rThe output range.
wThe world to query.

Definition at line 2002 of file world.c.

References CopyInterval(), Tworld::dof2joint, Tworld::dof2link, Tworld::dof2param, Tworld::dof2range, Error(), GetJointRangeN(), GetLinkDOFRange(), GetMechanismJoint(), GetMechanismLink(), Tworld::m, Tworld::maxCoord, Tworld::ndof, and NO_UINT.

Referenced by main().

void GetWorldJointLabel ( unsigned int  ndof,
char **  string,
Tworld w 
)

Returns a label identifying eachjoint. This is used to generate interfaces. Right now we only return a valid label for the first degree of freedom of each joint and the label identifies the joint and not the particular degree of freedom. In all other cases the output is NULL.

Note that, if different from NULL, the string is initialized inside this call but must be deallocated by the caller.

Parameters
ndofThe identifier for the degree of freedom.
stringThe output label. Possibly NULL.
wThe world to query.

Definition at line 2024 of file world.c.

References Tworld::dof2joint, Tworld::dof2range, Error(), GetJointName(), GetMechanismJoint(), and Tworld::m.

void GetWorldDOFLabel ( unsigned int  ndof,
char **  string,
Tworld w 
)

Returns a label identifying each degree of freedom. This is used to generate interfaces. This is a variant of GetWorldJointLabel but where all dof get an identifier.

Note that, if different from NULL, the string is initialized inside this call but must be deallocated by the caller.

Parameters
ndofThe identifier for the degree of freedom.
stringThe output label. Possibly NULL.
wThe world to query.

Definition at line 2036 of file world.c.

References Tworld::dof2joint, Tworld::dof2link, Tworld::dof2param, Tworld::dof2range, Error(), GetJointDOF(), GetJointDOFName(), GetJointName(), GetLinkDOFLabel(), GetLinkName(), GetMechanismJoint(), GetMechanismLink(), Tworld::m, NEW, and NO_UINT.

boolean IsWorldPolynomial ( Tworld w)
inline

Checks if the system of equations derived from the world is polynomial.

Parameters
wThe world to query.
Returns
TRUE if the system is polynomial.

Definition at line 2089 of file world.c.

References Error(), IsCSPolynomial(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

void CheckAllCollisions ( unsigned int  fl,
unsigned int  fo,
Tworld w 
)

Activates all the possible collision betwen links and links and obstacles.

Parameters
flFirst link. Use 0 if not sure what to use. This is used when including files where this function must affect only the links/objects defined in the current file and in files included here, but not to links/objects defined in the files that include the current file.
foFirst object. Use 0 if not sure what to use.
wThe world to update.

Definition at line 2097 of file world.c.

References Tworld::checkCollisionsLO, CheckSelfCollisions(), DECOR_SHAPE, Tworld::e, Error(), GetObstacleShapeStatus(), IsGroundLink, Tworld::nl, Tworld::no, Tworld::stage, and WORLD_IN_DEFINITION.

Referenced by InitWorldFromMolecule().

void NoCheckAllCollisions ( unsigned int  fl,
unsigned int  fo,
Tworld w 
)

Desactivates all the possible collision betwen links and links and obstacles.

Parameters
flFirst link. Use 0 if not sure what to use. This is used when including files where this function must affect only the links/objects defined in the current file and in files included here, but not to links/objects defined in the files that include the current file.
foFirst object. Use 0 if not sure what to use.
wThe world to update.

Definition at line 2119 of file world.c.

References Tworld::checkCollisionsLO, Error(), FALSE, Tworld::nl, Tworld::no, NoCheckSelfCollisions(), Tworld::stage, and WORLD_IN_DEFINITION.

Referenced by main().

boolean AnyCollision ( Tworld w)

Determines if any collision is activated and must be avoided.

Parameters
wThe world to query.
Returns
TRUE if there is at least one collision to avoid.

Definition at line 2294 of file world.c.

References Tworld::checkCollisionsLL, Tworld::checkCollisionsLO, FALSE, LinkCanCollide(), Tworld::nl, and Tworld::no.

Referenced by InitWorldCD(), on_cuikmove_save(), and PrintCollisions().

void PrintCollisions ( FILE *  f,
Tworld w 
)

Stores the collision information into a file in the format valid to be read by InitWorldFromFile.

Parameters
fThe file where to store the information.
wThe world with the collision information to print.

Definition at line 2306 of file world.c.

References AnyCollision(), Tworld::checkCollisionsLL, Tworld::checkCollisionsLO, Tworld::e, GetLinkName(), GetMechanismLink(), GetObstacleName(), Tworld::m, Tworld::nl, and Tworld::no.

Referenced by PrintWorld().

void CheckSelfCollisions ( unsigned int  fl,
Tworld w 
)

Activates all the possible collision betwen links.

Parameters
flFirst link. Use 0 if not sure what to use. This is used when including files where this function must affect only the links/objects defined in the current file and in files included here, but not to links/objects defined in the files that include the current file.
wThe world to update.

Definition at line 2138 of file world.c.

References Tworld::checkCollisionsLL, Error(), Tworld::nl, Tworld::stage, and WORLD_IN_DEFINITION.

Referenced by CheckAllCollisions().

void NoCheckSelfCollisions ( unsigned int  fl,
Tworld w 
)

Desactivates all the possible collision betwen links.

Parameters
flFirst link. Use 0 if not sure what to use. This is used when including files where this function must affect only the links/objects defined in the current file and in files included here, but not to links/objects defined in the files that include the current file.
wThe world to update.

Definition at line 2153 of file world.c.

References Tworld::checkCollisionsLL, Error(), FALSE, Tworld::nl, Tworld::stage, and WORLD_IN_DEFINITION.

Referenced by NoCheckAllCollisions().

void CheckLinkLinkCollision ( unsigned int  a,
unsigned int  b,
Tworld w 
)

Activates all the possible collision betwen a particular pair of links.

Note that we don't have an interface to activate/desactivate the collision checking between links sub-parts. To this end you have to use the DECOR keyword in the sub-part definition (DECOR sub-parts are not used in collision checking).

Parameters
aThe identifier of the first link of the pair whose collision has to be checked.
bThe identifier of the second link of the pair whose collision has to be checked.
wThe world to update.

Definition at line 2167 of file world.c.

References Tworld::checkCollisionsLL, Error(), Tworld::stage, TRUE, and WORLD_IN_DEFINITION.

void NoCheckLinkLinkCollision ( unsigned int  a,
unsigned int  b,
Tworld w 
)

Desactivates all the possible collision betwen a particular pair of links.

Parameters
aThe identifier of the first link of the pair whose collision has not to be checked.
bThe identifier of the second link of the pair whose collision has not to be checked.
wThe world to update.

Definition at line 2179 of file world.c.

References Tworld::checkCollisionsLL, Error(), FALSE, Tworld::stage, and WORLD_IN_DEFINITION.

Referenced by NoCheckConnectedCollisions().

void CheckLinkObstacleCollision ( unsigned int  a,
unsigned int  b,
Tworld w 
)

Activates the possible collision between a particular link and an object in the environment.

Note that we don't have an interface to activate/desactivate the collision checking for a given link sub-part. To this end you have to use the DECOR keyword in the sub-part definition (DECOR sub-parts are not used in collision checking).

Parameters
aThe identifier of the link of the whose collision has to be checked.
bThe identifier of the obstacle whose collision has to be checked.
wThe world to update.

Definition at line 2191 of file world.c.

References Tworld::checkCollisionsLO, Error(), IsGroundLink, Tworld::stage, TRUE, and WORLD_IN_DEFINITION.

Referenced by CheckObstacleCollision().

void NoCheckLinkObstacleCollision ( unsigned int  a,
unsigned int  b,
Tworld w 
)

Desactivates the possible collision between a particular link and an object in the environment.

Parameters
aThe identifier of the link of the whose collision has not to be checked.
bThe identifier of the obstacle whose collision has not to be checked.
wThe world to update.

Definition at line 2200 of file world.c.

References Tworld::checkCollisionsLO, Error(), FALSE, Tworld::stage, and WORLD_IN_DEFINITION.

Referenced by NoCheckObstacleCollision().

void CheckObstacleCollision ( unsigned int  fl,
unsigned int  b,
Tworld w 
)

Activates the possible collision with a given object.

Parameters
flFirst link. Use 0 if not sure what to use. This is used when including files where this function must affect only the links/objects defined in the current file and in files included here, but not to links/objects defined in the files that include the current file.
bThe identifier of the obstacle whose collision has to be checked.
wThe world to update.

Definition at line 2209 of file world.c.

References CheckLinkObstacleCollision(), and Tworld::nl.

void NoCheckObstacleCollision ( unsigned int  fl,
unsigned int  b,
Tworld w 
)

Deactivates the possible collision with a given object.

Parameters
flFirst link. Use 0 if not sure what to use. This is used when including files where this function must affect only the links/objects defined in the current file and in files included here, but not to links/objects defined in the files that include the current file.
bThe identifier of the obstacle whose collision has not to be checked.
wThe world to update.

Definition at line 2217 of file world.c.

References Tworld::nl, and NoCheckLinkObstacleCollision().

void NoCheckConnectedCollisions ( unsigned int  fl,
Tworld w 
)

Desactivates the collision between links connected by a joint. Additionally, for NoRot links, deactivates the collision between links connected to the NoRot links.

Parameters
flFirst link. Use 0 if not sure what to use. This is used when including files where this function must affect only the links/objects defined in the current file and in files included here, but not to links/objects defined in the files that include the current file.
wThe world to update.

Definition at line 2225 of file world.c.

References GetLinkType(), GetMechanismJoint(), GetMechanismLink(), JointFromID(), JointToID(), LINK_NoRot, Tworld::m, Tworld::nj, Tworld::nl, and NoCheckLinkLinkCollision().

void InitWorldCD ( Tparameters pr,
unsigned int  mt,
Tworld w 
)

Initializes the collision detector.

This is decoupled from the world initialization so that we can init it only when required.

In some cases (for instance when parallelizing the atlas construction using OpenMP) we need to perform collision detection in parallel for different threads. To avoid problems, in this case we initialize separate collision detection structures.

Parameters
prThe set of parameters.
mtMaximum number of threads in parallal that might use the collision detection.
wThe world from where to read the link/obstacle information.

Definition at line 1030 of file world.c.

References AnyCollision(), Tworld::checkCollisionsLL, Tworld::checkCollisionsLO, CT_CD_ENGINE, DeleteCD(), Tworld::e, Error(), GetParameter(), InitCD(), Tworld::m, NEW, Tworld::nwcd, Tworld::stage, Tworld::wcd, and WORLD_DEFINED.

Referenced by main(), and PlotWorld().

boolean WorldCanCollide ( Tworld w)

Determides if, after initializing the world collision info, any collision is possible.

This function can only be used after calling InitWorldCD.

Parameters
wThe world to query.

TRUE if any collision is possible.

Definition at line 1063 of file world.c.

References Tworld::wcd.

void GetLinkTransformsFromSolutionPoint ( Tparameters p,
boolean  simp,
double *  sol,
THTransform **  tl,
TLinkConf **  def,
Tworld w 
)

Computes a transform giving the pose for each link from values for a solution point.

The difference with respect to GetLinkTransformsFromSolution is that here only the system variables are given.

Parameters
pThe parameters.
simpTRUE if the solution is given in the simplified form.
solThe solution point.
tlThe output transforms. The space is allocated inside this function.
defConfiguration parameters for each link.
wThe world structure with the mechanical information.

Definition at line 1215 of file world.c.

References CT_REPRESENTATION, Error(), GetLinkTransformsFromDOF(), GetLinkTransformsFromSolution(), GetParameter(), Tworld::kinCS, Tworld::m, RegenerateMechanismSolution(), RegenerateOriginalPoint(), RegenerateWorldSolutionPoint(), REP_JOINTS, Tworld::stage, and WORLD_DEFINED.

Referenced by BioWordGetAtomPositionsFromConformation(), WorldPrintAtoms(), and WorldStoreRigidGroups().

unsigned int GetSolutionPointFromLinkTransforms ( Tparameters p,
THTransform tl,
TLinkConf def,
double **  sol,
Tworld w 
)

Determines the mechanisms configuration from the transforms giving the global position of all links.

This is basically the inverse function of GetLinkTransformsFromSolutionPoint.

Parameters
pThe set of parameters.
tlThe transform giving the global pose of each link.
defThe configuration information for each link. Use NULL if no link can deform.
solThe output configuration. The space for this array is allocated internally and its size depends on the CT_REPRESENTATION value. In any case only values for the system variables is allocated.
wThe world structure with the mechanical information.
Returns
The size of the solution point.

Definition at line 1261 of file world.c.

References CT_REPRESENTATION, GetCSNumSystemVariables(), GetMechanismDOFsFromTransforms(), GetParameter(), Tworld::kinCS, Tworld::m, Tworld::ndof, NEW, REP_JOINTS, Tworld::systemVars, and WorldDOF2Sol().

Referenced by BioWordConformationFromAtomPositions(), and InitWorldFromMolecule().

void DeleteLinkTransforms ( THTransform tl,
TLinkConf def,
Tworld w 
)

Deletes the transforms computed by GetLinkTransformsFromDOF or by GetLinkTransformsFromSolution.

Parameters
tlThe array of transforms to delete.
defConfiguration parameters. One per link.
wThe world structure.

Definition at line 1336 of file world.c.

References DeleteLinkConf(), HTransformDelete(), and Tworld::nl.

Referenced by BioWordGetAtomPositionsFromConformation(), MoveAndCheckCD(), MoveWorld(), MoveWorldDOF(), WorldDOF2Sol(), WorldPrintAtoms(), WorldSample2DOF(), and WorldStoreRigidGroups().

boolean WorldContinuousCD ( Tworld w)

Determines if the collision detection engine is discrete or continuous. Note that the return is only valid if the collision detection system has been previously initialized.

Parameters
wThe world structure to query.
Returns
TRUE if we use a continuous collision detection engine.

Definition at line 1068 of file world.c.

References C_FCL, FALSE, GetCDEngine(), and Tworld::wcd.

boolean MoveAndCheckCDFromTransforms ( boolean  all,
unsigned int  tID,
THTransform tl,
TLinkConf def,
THTransform tlPrev,
TLinkConf defPrev,
Tworld w 
)

Moves the links to the position given by the corresponding transforms and determines if there is any collision.

No check is done on whether the given point is actually a solution or not.

Parameters
allTRUE if we want to detect all the collision. FALSE just to detect the first one.
tIDIdentifier of the thread executing this collision check. See InitWorldCD. This parameter is only relevant if parameter 'mt' in InitWorldCD is larger than 0.
tlOne homogeneous transform for each link.
defConfiguration parameter for each link.
tlPrevOne homogeneous transform for each link in the previous configuration. Only used for continuous collision check (C_FCL collision engine).
defPrevConfiguration parameter for each link in the previous configuration.
wThe world structure to check.
Returns
TRUE if there is a collision.

Definition at line 1077 of file world.c.

References CheckCollision(), Tworld::e, FALSE, Tworld::m, Tworld::nwcd, PrintCollisionInfo(), and Tworld::wcd.

Referenced by MoveAndCheckCD(), MoveWorld(), and MoveWorldDOF().

boolean MoveAndCheckCD ( Tparameters p,
boolean  all,
unsigned int  tID,
double *  sol,
double *  solPrev,
Tworld w 
)

Computes the link transforms from the solution point and calls MoveAndCheckCDFromTransforms.

The solution point is assumed to have values for all variables (including the dummy ones). Recall that a solution point with values only for the system variables can be compleated using RegenerateWorldSolutionPoint and that a solution point in the simplified system can be converted to a solution point in the full original system using RegenerateWorldOriginalPoint.

Parameters
pThe set of parameters.
allTRUE if we want to detect all the collision. FALSE just to detect the first one.
tIDIdentifier of the thread executing this collision check. See InitWorldCD. This parameter is only relevant if parameter 'mt' in InitWorldCD is larger than 0.
solThe solution point (in the original system including values for all variables. The transform for each link is computed from the values here.
solPrevPrevious configuration. Only used for continuous collision detection (C_FCL collision engine).
wThe world structure to check.
Returns
TRUE if there is a collision.

Definition at line 1102 of file world.c.

References C_FCL, DeleteLinkTransforms(), FALSE, GetCDEngine(), GetLinkTransformsFromSolution(), MoveAndCheckCDFromTransforms(), and Tworld::wcd.

Referenced by main().

boolean NewtonInWorld ( Tparameters p,
double *  v,
Tbox b_sol,
Tworld w 
)

Generates a sample from a the kinematic cuiksystem in the world using the Newton algorithm. However,

  • In many cases we do not obtain a valid sample (the Newton process diverged).
  • The generated samples are not necessarily collision free.

Note that samples include values ONLY for the system variables (the kinematic subsystem has the same system variables than the global system). Thus, the boxe returned in the b_sol (and in the vector v) only include ranges (or values) for the system variables.

Parameters
pA set of parameters.
vSpace where to store the solution as a point. This must be allocated by the caller.
b_solThe solution as a punctual box. If the Newton diverged this will be a copy of the input box. This box is allocated inside the function.
wThe world from where to get the kinematic equation system.
Returns
TRUE if the Newton-Raphson process converged to a solution.
See Also
CuikNewton.

Definition at line 2335 of file world.c.

References CuikNewton(), DeleteBox(), Error(), GetBoxInterval(), GetCSSystemVars(), InitBox(), Tworld::kinCS, NEW, PrintBox(), SetBoxInterval(), Tworld::stage, and WORLD_DEFINED.

unsigned int GetWorldSystemVars ( boolean **  sv,
Tworld w 
)
inline

Gets the system vars of the cuiksystem in the form of an array of booleans, one for each variable where only entries corresponding to system variables are set to TRUE.

Parameters
svSpace where to store the output array of booleans.
wThe world to query.

Definition at line 2383 of file world.c.

References Error(), GetCSSystemVars(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

Referenced by main(), on_cuikmove_save(), and PlotForceField().

unsigned int GetWorldVarTopology ( unsigned int  vID,
Tworld w 
)
inline

Determines the topology of a given variable.

Parameters
vIDThe variable identifier.
wThe world to query.
Returns
The topology of the variable.

Definition at line 2391 of file world.c.

References GetCSVarTopology(), and Tworld::kinCS.

unsigned int GetWorldSimpVariableMask ( Tparameters p,
boolean **  sv,
Tworld w 
)

Identifies pose related variable that survied in the simplified system.

Pose related variables are those giving the pose of a link (typically the system variables).

Here we are interested in identifying those variables that survive in the simplified system. This is a hack to be able to generate eigengrasp. Note that since is eigengrasp oriented, we do not consider the last link in the system (i.e., the manipulated object) but only the hand links.

Parameters
pThe set of parameters.
svA boolean array identifying the surviving variables.
wThe world to analyze.

Definition at line 2396 of file world.c.

References Error(), FALSE, GetCSNumVariables(), GetLinkPoseSimpVars(), GetMechanismLink(), Tworld::kinCS, Tworld::m, NEW, Tworld::nl, Tworld::stage, and WORLD_DEFINED.

Referenced by main().

void GetWorldVarNames ( char **  vn,
Tworld w 
)
inline

Returns an array with pointers to the variables names for the kinematic cuik system. This is used to print the variable names in the solution boxes.

Parameters
vnArray where to store the pointers to the variable names. The space for this array must be allocated/deallocated by the caller. The pointers themselves not.
wThe world to query.

Definition at line 2415 of file world.c.

References Error(), GetCSVariableNames(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

Referenced by main(), and on_cuikmove_save().

char* GetWorldSystemVarName ( unsigned int  nv,
Tworld w 
)
inline

Returns the name of a given system variable in the kinematic cuiksystem.

Parameters
nvThe index of the system variable.
wThe world structure to query.
Returns
A pointer to the name of the variable or NULL if the index is out of range.

Definition at line 2423 of file world.c.

References Error(), GetCSSystemVariableName(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

Referenced by main().

void GenerateWorldEquations ( Tparameters p,
Tworld w 
)

From the information stored in a .world file, we generate the environment and mechanisms structures. From this information we have to generate systems of equations necessary to solve the problem. This is the purpose of this function. Therefore, this function should be used after reading the .world file and before start to solve the problem.

Parameters
pA set of parameters.
wThe world structure with the information from where to generate the equations.

Definition at line 2431 of file world.c.

References AddEquationNoSimp(), AddMatrixEquation(), Tworld::branch2Link, COORD_EQ, CT_REPRESENTATION, DeleteEquation(), DeleteMEquation(), DeleteVariables(), Tworld::e, Error(), GenerateMEquationFromBranch(), GenerateTransEquationsFromBranch(), GetCSSystemVars(), GetCSVariables(), GetEnvironmentMaxCoordinate(), GetMechanismMaxCoordinate(), GetParameter(), InitEquations(), InitJacobian(), InitWorldCS(), InitWorldKinCS(), Tworld::kinCS, Tworld::m, Tworld::maxCoord, Tworld::nl, Tworld::nsvars, Tworld::nvars, Tworld::refEqs, Tworld::refEqsJ, REP_JOINTS, Tworld::stage, Tworld::systemVars, WORLD_DEFINED, WORLD_IN_DEFINITION, and WorldInitDOFInfo().

Referenced by GenerateWorldSingularityEquations(), and InitWorldFromMolecule().

void GenerateForceEquilibriumEquations ( Tparameters p,
Tworld w 
)

Adds the force equilibirum equations to the system generated by GenerateWorldEquations.

This only makes sense in tensegrity structures.

Parameters
pA set of parameters.
wThe world structure with the information from where to add the equations.

Definition at line 2510 of file world.c.

References AddEquation2CS(), AddMonomial(), AddVariable2Monomial(), CT_PRETENSION, CT_REPRESENTATION, DeleteEquation(), DeleteMonomial(), EQU, Error(), GetForceOnLink(), GetLinkForceModel(), GetLinkForceVars(), GetMechanismJoint(), GetMechanismLink(), GetParameter(), InitEquation(), InitMonomial(), IsForceEquilibriumLink(), JointForceEquation(), Tworld::kinCS, Tworld::m, NFUN, Tworld::nj, Tworld::nl, NO_FORCE, REP_JOINTS, ResetMonomial(), SetEquationCmp(), SetEquationType(), SetEquationValue(), Tworld::stage, SYSTEM_EQ, WORLD_DEFINED, and ZERO.

unsigned int WorldForceVars ( Tparameters p,
boolean **  fv,
Tworld w 
)

Creates an array to identify the force variables in the problem. Only force variables, not all force related variables (i.e., rest length) are set.

Parameters
pThe set of paramters.
fvThe array of booleans. It is allocated internally but be deallocated externally.
wThe world query.
Returns
Number of force variables in the problem.

Definition at line 2585 of file world.c.

References CT_REPRESENTATION, Error(), FALSE, GetMechanismLink(), GetParameter(), Tworld::kinCS, Tworld::m, NEW, Tworld::nl, Tworld::nvars, SetForceVars(), Tworld::stage, Tworld::systemVars, and WORLD_DEFINED.

Referenced by WorldForceVarsIndices().

unsigned int WorldSimpKinematicVars ( Tparameters p,
boolean **  kv,
Tworld w 
)

Creates an array to identify kinematic variables (i.e., no force variables) in the simplified cuiksystem.

This is useful, for instance, to compute path lenghts in the kinematic sub-space.

If all variables are kinematic, the output array (kv) will be NULL.

Parameters
pThe set of parameters.
kvThe array of booleans to create.
wThe world to query.
Returns
The number of entries in the output array, i.e., the number of variables in the simplified system.

Definition at line 2616 of file world.c.

References CT_REPRESENTATION, Error(), FALSE, GetMechanismLink(), GetParameter(), Tworld::kinCS, Tworld::m, NEW, Tworld::nl, Tworld::nvars, SetForceRelatedVars(), SimplifyBooleanArray(), Tworld::stage, and WORLD_DEFINED.

Referenced by main(), PathEffort(), and SmoothSamples().

unsigned int WorldForceVarsIndices ( Tparameters p,
unsigned int **  iv,
Tworld w 
)

Creates an array with the indices of the force variables. This can be seen as a variant of WorldForceVars where the output is in the form of a array of indices rather than of as an array of booleans.

Parameters
pThe set of paramters.
ivThe array of indices. It is allocated internally but be deallocated externally.
wThe world query.
Returns
Number of force variables in the problem.

Definition at line 2649 of file world.c.

References Error(), GetWorldNumSystemVariables(), NEW, and WorldForceVars().

Referenced by main().

double WorldPotentialEnergy ( Tparameters p,
boolean  simp,
double *  sol,
void *  w 
)

Computes the potential energy of a configuration. It only returns different from 0 for tensegrities.

The potential energy is computed modeling the links as springs.

Parameters
pThe set of parameters.
simpTRUE if the solution point is in the simplified form.
solThe solution point. If simp==FALSE, it includes only system variables (i.e., as it is stored in solution files).
wThe world structure including the tensegrity definition. (as a void* for compatibility with the MinimizeOnAtlas function).
Returns
The value of the potential energy. 0 for non-tensegrity structures.

Definition at line 2680 of file world.c.

References CT_REPRESENTATION, Error(), GetMechanismLink(), GetParameter(), Tworld::kinCS, LinkPotentialEnergy(), Tworld::m, Tworld::nl, RegenerateMechanismSolution(), RegenerateOriginalPoint(), RegenerateWorldSolutionPoint(), REP_JOINTS, Tworld::stage, and WORLD_DEFINED.

Referenced by main().

void WorldForceField ( Tparameters p,
boolean  simp,
double *  sol,
double **  g,
void *  w 
)

Computes the gradient of the potential energy of a configuration. It only returns different from a null vector for tensegrities (it can also be null for some tensegrities, though).

The potential energy is computed modeling the links as springs.

Parameters
pThe set of parameters.
simpTRUE if the input point is in the simplified form. If so, the output is also in simplified form.
solThe solution point. If simp==FALSE, it includes only system variables (i.e., as it is stored in solution files).
gThe output gradient. Its form/size depends on parameter simp.
wThe world structure including the tensegrity definition.
Returns
The number of entries of the output array.
See Also
WorldPotentialEnergy.

Definition at line 2722 of file world.c.

References CT_REPRESENTATION, Error(), GenerateSimplifiedPoint(), GetMechanismLink(), GetParameter(), Tworld::kinCS, LinkForceField(), Tworld::m, NEWZ, Tworld::nl, Tworld::nvars, RegenerateMechanismSolution(), RegenerateOriginalPoint(), RegenerateWorldSolutionPoint(), REP_JOINTS, Tworld::stage, and WORLD_DEFINED.

Referenced by main(), PlotForceField(), StepEffort(), StepEffortGradient(), and WorldForceFieldProjectedGradient().

void WorldForceFieldProjectedGradient ( Tparameters p,
boolean  simp,
double *  proj,
double *  sol,
double **  g,
void *  w 
)

Computes the a projection of the gradient of the force field. Actually we copute

  • proj^T * H

with H the Hessian matrix of the potential energy. This seems a rather particular function but we implement it since this is the only way in which we use the Hessian. Moreover, this form, we avoid forming the Hessian matrix (a large matrix).

Each of the columns of the Hessian is the derivative of the force field w.r.t. one of the variables of the problem. It can be easily check that these derivatives are:

  • [0...0] for variables other other than l/r
  • [0... 0 +K -K 0 ... 0] if the variable is l
  • [0... 0 -K +K 0 ... 0] if the variable is r

(This applies for all the l/r in the problem). When computing proj^T * H we obtain:

  • +K * proj_l - K * proj_r = +K * (proj_l-proj_r)
  • -K * proj_l + K * proj_r = -K * (proj_l-proj_r)

Which is exactly what is obtained from WorldForceField using proj as a parameter. This greatly simplifies the implementation of this projected gradient function.

Parameters
pThe set of parameters.
simpTRUE if the input point is in the simplified form. If so, the output is also in simplified form.
projThe projection vector.
solThe solution point. If simp==FALSE, it includes only system variables (i.e., as it is stored in solution files).
gThe diagonal of the Hessian matrix. Its form/size depends on parameter simp.
wThe world structure including the tensegrity definition.
Returns
The number of entries of the output array.
See Also
WorldPotentialEnergy, WorldForceField.

Definition at line 2776 of file world.c.

References WorldForceField().

Referenced by StepEffortGradient().

void FixLinks ( Tparameters p,
Tworld w 
)

Generate equations to fix (some dimensions) of the translation of a some links.

This is only used in tensegrity structures (in particular to avoid the tensegrity to be free-flying).

Parameters
pA set of parameters.
wThe world structure with the information from where to add the equations.

Definition at line 2783 of file world.c.

References AddEquation2CS(), Tworld::branch2Link, CopyEquation(), CT_REPRESENTATION, DeleteEquation(), Error(), GenerateTransEquationsFromBranch(), GetEquationValue(), GetLinkTrans(), GetMechanismLink(), GetParameter(), INF, Tworld::kinCS, Tworld::m, Tworld::nl, REP_JOINTS, SetEquationValue(), Tworld::stage, SYSTEM_EQ, and WORLD_DEFINED.

void WorldFixTensegrityAddon ( Tparameters p,
unsigned int  linkID,
double **  point,
unsigned int *  n,
Tworld w 
)

Tensegrity addons are geometric objects that are attached to tensgrity nodes. This is a form of adding rich geometry to tensegrities, which otherwise are only composed by struts, cables, and springs.

Each addons has to be fixed to three tensegrity nodes to fully determine its pose. In this way the 9 dof of the addon (3 translations and 3 rotations) are cancelled and the addon is effectively fixed to the tensegrity structure.

Note that by attaching an addon to a tensegrity, the relative distances between the three points used to fix the addon are fixed

Parameters
pThe set of parameters.
linkIDThe identifier of the addon.
pointThe coordinates of three on the addon.
nThe identifier of three nodes in the tensegrity.
wThe world structure holding the tensegrity description.

Definition at line 2819 of file world.c.

References AddCt2Monomial(), AddEquation2CS(), AddMonomial(), AddVariable2Monomial(), ApplyLinkRot(), Tworld::branch2Link, DeleteEquation(), DeleteMonomial(), Error(), FALSE, GenerateTransEquationsFromBranch(), GetCSVariableID(), GetLinkName(), GetMechanismLink(), InitMonomial(), Tworld::kinCS, LINK_TRANS, Tworld::m, NEW, NFUN, NO_UINT, ResetMonomial(), and SYSTEM_EQ.

void FixZToZero ( Tparameters p,
Tworld w 
)

Generate equations to define a planar tensegrity, fixing the Z component of the director vectors of the links.

This is only used in tensegrity structures.

Parameters
pA set of parameters.
wThe world structure with the information from where to add the equations.

Definition at line 2867 of file world.c.

References CT_REPRESENTATION, Error(), FixLinkZToZero(), GetMechanismLink(), GetParameter(), Tworld::kinCS, Tworld::m, Tworld::nl, REP_JOINTS, Tworld::stage, and WORLD_DEFINED.

void WorldCoupleTensegrityVariable ( Tparameters p,
unsigned int  t,
unsigned int  lID1,
unsigned int  lID2,
double  scale,
THTransform r,
Tworld w 
)

In tensegrities many times elements share a variable: they have the same length, stiffness, rest length, force or even orientation. This function fixes the variables and must be used AFTER defining such variables, i.e., after using GenerateWorldEquations.

Parameters
pThe set of parameters.
tThe type of couple: length, stiffness, rest length, force, orientation.
lID1The identifier of the first link to couple.
lID2The identifier of the second link to couple.
scaleScale factor between the variables. Only used for non-orientation couplings.
rRotation between orientations. Only used in orientation coupling.
wThe world where to add the couple equations.

Definition at line 2889 of file world.c.

References AddCt2Monomial(), AddEquation2CS(), AddMonomial(), AddVariable2Monomial(), COUPLE_FORCE, COUPLE_LENGTH, COUPLE_ORIENTATION, COUPLE_REST, CT_REPRESENTATION, DeleteEquation(), DeleteMonomial(), EQU, Error(), GetLinkForceModel(), GetLinkForceVars(), GetParameter(), GetWorldLink(), HTransformGetElement(), InitEquation(), InitMonomial(), IsVariableLengthLink(), Tworld::kinCS, LINEAR_FORCE, NFUN, NO_FORCE, REP_JOINTS, ResetMonomial(), SetEquationCmp(), SetEquationType(), SetEquationValue(), Tworld::stage, SYSTEM_EQ, and WORLD_DEFINED.

void GenerateWorldSingularityEquations ( Tparameters p,
char *  ln,
TCuikSystem cs,
Tworld w 
)

Extends the kinematic subsystem with variables/equations to deal with singularities.

We re-defined the variables giving bounds for the joints so that introducing a singularity in the extreme of its range. Moreover, if requiered, we add equations giving the position of a link in the global frame.

Note that this only part of the process to generate a system of equations to detect singularities. The equations to detect the loss of rank of the Jacobian are to be added later. They are not added here to allow the user to select the variables for which the singularities are to be detected. This is to be done with a separate utility.

Parameters
pA set of parameters.
lnIf we want to find position singularities, the name of the link link we want to focus on. If different from NULL, the equations giving the origin of the link in the global frame are added to the system.
csThe resulting cuiksystem. The kinematic one from w plus the added information.
wThe world structure with the mechism to analyze.

Definition at line 3039 of file world.c.

References AddCt2Monomial(), AddEquation2CS(), AddMonomial(), AddVariable2CS(), AddVariable2Monomial(), CARTESIAN_VAR, COORD_EQ, CopyCuikSystem(), CopyEquation(), CT_REPRESENTATION, DeleteEquation(), DeleteMonomial(), DeleteVariable(), Error(), GenerateJointRangeSingularityEquations(), GenerateWorldEquations(), GetEquation(), GetLinkName(), GetMechanismJoint(), GetMechanismLink(), GetMechanismLinkID(), GetParameter(), InitMonomial(), Tworld::kinCS, LINK_TRANS, Tworld::m, Tworld::maxCoord, NEW, NewInterval(), NewVariable(), NFUN, Tworld::nj, NO_UINT, Tworld::refEqs, REP_JOINTS, ResetMonomial(), SetEquationType(), SetVariableInterval(), Tworld::stage, and WORLD_DEFINED.

Referenced by GenerateWorldTWSEquations(), and main().

void GenerateWorldTWSEquations ( Tparameters p,
char *  ln,
TCuikSystem cs,
Tworld w 
)

Extends the kinematic subsystem with variables/equations to detect translational workspace boundaries.

This is a composition of GenerateWorldSingularityEquations and AddJacobianEquations to detect a particular set of singularities.

Parameters
pA set of parameters.
lnThe link whose translation we want to bound.
csThe resulting cuiksystem. The kinematic one from w plus the added information.
wThe world structure with the mechism to analyze.

Definition at line 3104 of file world.c.

References AddSimplifiedJacobianEquations(), Error(), FALSE, GenerateWorldSingularityEquations(), GetCSNumVariables(), GetCSVariableID(), LINK_TRANS, NEW, NO_UINT, and TRUE.

Referenced by main().

void GetWorldJacobian ( TJacobian J,
Tworld w 
)
inline

Returns the symbolic Jacobian for the kinematic equations on a given point

The size of the Jacobian matrix is the number of equations of the kinematic system times the number of variables.

Parameters
JThe returned Jacobian.
wThe world to query.
See Also
GetCSJacobian.

Definition at line 3137 of file world.c.

References Error(), GetCSJacobian(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

void GetWorldSimpJacobian ( Tparameters p,
TJacobian J,
Tworld w 
)
inline

Returns the symbolic Jacobian for the simplified kinematic equations on a given point

The size of the Jacobian matrix is the number of equations of the simplified kinematic system times the number of variables.

Parameters
pThe set of parameters.
JThe returned Jacobian matrix.
wThe world to query.
See Also
GetSimpCSJacobian.

Definition at line 3145 of file world.c.

References Error(), GetSimpCSJacobian(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

Referenced by main(), and PathEffort().

unsigned int GetWorldSimpTopology ( Tparameters p,
unsigned int **  t,
Tworld w 
)
inline

Gets the topology of the variables in simplified kinematic equations.

Parameters
pThe set of parameters.
tSpace for the output array (one entry per variable, allocated inside this function).
wThe world to query.
Returns
The number of variables in the simplified kinematic system (i.e., the number of entries in the output array).
See Also
GetSimpCSTopology

Definition at line 3153 of file world.c.

References Error(), GetSimpCSTopology(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

Referenced by main(), and PathEffort().

unsigned int GetWorldTopology ( Tparameters p,
unsigned int **  t,
Tworld w 
)
inline

Gets the topology of the variables in kinematic equations.

Parameters
pThe set of parameters.
tSpace for the output array (one entry per variable, allocated inside this function).
wThe world to query.
Returns
The number of variables in the kinematic system (i.e., the number of entries in the output array).
See Also
GetCSTopology

Definition at line 3162 of file world.c.

References Error(), GetCSTopology(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

unsigned int WorldDOFTopology ( unsigned int **  t,
Tworld w 
)

Gets the topology of the degrees of freedom of the mechanism.

Parameters
tSpace for the output array (one entry per variable, allocated inside this function).
wThe world to query.
Returns
The number of dof of the mechanism.

Definition at line 3171 of file world.c.

References Tworld::dof2joint, Tworld::dof2range, GetJointRangeTopology(), GetMechanismJoint(), Tworld::m, Tworld::ndof, NEW, NO_UINT, and TOPOLOGY_R.

void GetWorldKinJacobian ( Tparameters p,
unsigned int *  nr,
unsigned int *  nc,
Tequation ***  J,
Tworld w 
)

Returns the symbolic Jacobian for the simplified kinematic equations on a given point

The size of the Jacobian matrix is the number of equations of the kinematic system times the number of variables of the simplified system.

Parameters
pThe set of parameters.
nrThe number of rows of the returned Jacobian matix (i.e., the number of equations of the simplified system).
ncThe number of columns of the returned Jacobian matix (i.e., the number of variables of the simplified system).
JThe returned Jacobian matrix. This is an array of equations.
wThe world to query.
See Also
GetSimpCSJacobian.
unsigned int WorldSimpCuikNewton ( Tparameters p,
double *  pt,
Tworld w 
)
inline

Tries to reach the kinematic manifold from a given point. This point in given in the simplified space (without un-used variables nor dummies).

Parameters
pThe set of parameters.
ptThe initial/output point (in the simplified space).
wThe world with the kinematic equations.
Returns
DIVERGED if we could not reach a solution point or CONVERGED_IN_GLOBAL if a solution point is found.
See Also
CuikNewtonSimp.

Definition at line 3193 of file world.c.

References CuikNewtonSimp(), and Tworld::kinCS.

void EvaluateWorldJacobian ( double *  p,
double ***  J,
Tworld w 
)
inline

Returns the matrix resulting from evaluating the Jacobian for the kinematic equations on a given point

The size of the Jacobian matrix is the number of equations of the kinematic system times the number of variables.

Parameters
pThe point on which to evalutate the Jacobian.
JThe returned Jacobian matrix. This is allocated internally and must be deallocated externally.
wThe world to query.
See Also
EvaluateCSJacobian.

Definition at line 3198 of file world.c.

References Error(), EvaluateCSJacobian(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

void WorldEvaluateEquations ( double *  pt,
double *  r,
Tworld w 
)
inline

Evaluates the set of kinematic equations on a given point.

Parameters
ptThe evaluation point.
rThe array where to store the evaluation for each equation (must be allocated externally).
wThe world with the kinematic equations.
See Also
EvaluateCSEquations.

Definition at line 3206 of file world.c.

References Error(), EvaluateCSEquations(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

boolean WorldInequalitiesHold ( double *  pt,
Tworld w 
)
inline

Checks if all the intequalities in the system hold for a given point.

Parameters
ptThe point.
wThe world to query.
Returns
TRUE if all inequalities hold.

Definition at line 3214 of file world.c.

References Error(), InequalitiesHoldOnPoint(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

boolean WorldSimpInequalitiesHold ( Tparameters p,
double *  pt,
Tworld w 
)
inline

Checks if all the intequalities in the system hold for a given point for the simplified system.

Parameters
pThe set of parameters.
ptThe point in the simplified system.
wThe world to query.
Returns
TRUE if all inequalities hold for the simplified system.

Definition at line 3222 of file world.c.

References Error(), Tworld::kinCS, SimpInequalitiesHoldOnPoint(), Tworld::stage, and WORLD_DEFINED.

double WorldErrorInSimpInequalities ( Tparameters p,
double *  pt,
Tworld w 
)
inline

Determines the maximum error in the inequalites for the simplified system.

Parameters
pThe set of parameters.
ptThe point in the simplified system.
wThe world to query.
Returns
The maximum error in the inequalities in the simplified system.

Definition at line 3230 of file world.c.

References Error(), ErrorInSimpInequalitiesOnPoint(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

void WorldEvaluateSimpEquations ( Tparameters p,
double *  pt,
double *  r,
Tworld w 
)
inline

Evaluates the simplified kinematic equations on a given point.

Parameters
pThe set of parameters.
ptThe evaluation point (in the simplified space).
rThe array where to store the evaluation for each equation (must be allocated externally).
wThe world with the kinematic equations.
See Also
EvaluateSimpCSEquations.

Definition at line 3238 of file world.c.

References Error(), EvaluateSimpCSEquations(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

void WorldEvaluateSubSetSimpEquations ( Tparameters p,
boolean se,
double *  pt,
double *  r,
Tworld w 
)
inline

Evaluates a subset of the simplified kinematic equations on a given point.

Parameters
pThe set of parameters.
seThe array of booleans selecting the equations to evaluate.
ptThe evaluation point (in the simplified space).
rThe array where to store the evaluation for each equation (must be allocated externally).
wThe world with the kinematic equations.
See Also
EvaluateSimpCSEquations.

Definition at line 3246 of file world.c.

References Error(), EvaluateSubSetSimpCSEquations(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

double WorldErrorInEquations ( double *  pt,
Tworld w 
)

Evaluates the kinematic equations on a point and returns the norm of the error.

Parameters
ptThe point on which to evaluate the kinematic equations.
wThe world with the equations to evaluate.
Returns
The norm of the error for the given point.
See Also
ErrorInCSEquations.

Definition at line 3254 of file world.c.

References Error(), ErrorInCSEquations(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

Referenced by MoveWorld(), MoveWorldDOF(), and WorldErrorFromDOFs().

double WorldErrorInSimpEquations ( Tparameters p,
double *  pt,
Tworld w 
)
inline

The same as WorldErrorInEquations but working on the simplified set of kinematic equations.

Parameters
pThe set of parameters.
ptThe point on which to evaluate the kinematic equations.
wThe world with the equations to evaluate.
Returns
The norm of the error for the given point.
See Also
ErrorInSimpCSEquations.

Definition at line 3262 of file world.c.

References Error(), ErrorInSimpCSEquations(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

double WorldErrorFromDOFs ( Tparameters p,
double *  dof,
Tworld w 
)

Error in equation from the configuration given as degrees of freedom. If the internal representation is not DOF, the configuration is converted before computing the error.

Parameters
pThe set of parameters.
dofThe degrees of freedom given the configuration.
wThe world with the equations to evaluate.
Returns
The norm of the error for the given configuration.

Definition at line 3270 of file world.c.

References WorldDOF2Sol(), and WorldErrorInEquations().

Referenced by on_cuikmove_save().

double EvaluateWorldCost ( Tparameters p,
boolean  simp,
double *  pt,
void *  w 
)
inline

Evaluates the functions cost defined in a world in a given point. This is basically used by T-RRT (see also EvaluateCSCost).

Parameters
pThe set of parameters.
simpTRUE if the solution point is given in the simplified sytem.
ptThe solution point
wThe cuiksystem with the equation to evaluate.

Definition at line 3281 of file world.c.

References Error(), EvaluateCSCost(), and WORLD_DEFINED.

unsigned int GetWorldNumVariables ( Tworld w)

Return the number of variables in the kinematic subsystem (as defined and without any simplification).

Parameters
wThe world to query.
Returns
The number of variables in the kinematic subsystem.

Definition at line 3289 of file world.c.

References Error(), GetCSNumVariables(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

unsigned int GetWorldNumSystemVariables ( Tworld w)
inline

Return the number of system variables in the kinematic subsystem (as defined and without any simplification).

Parameters
wThe world to query.
Returns
The number of variables in the kinematic subsystem.

Definition at line 3297 of file world.c.

References Error(), GetCSNumSystemVariables(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

Referenced by BioWorldConformationSize(), main(), and WorldForceVarsIndices().

unsigned int RegenerateWorldOriginalPoint ( Tparameters p,
double *  s,
double **  o,
Tworld w 
)
inline

Reconstruct a point in original kinematic system from a point in the simplified system.

Parameters
pThe set of parameters.
sThe point in the simplified system.
oThe output on in the original system. Space allocated internally. Includes all the variables (system and non-system).
wThe world to query.
Returns
The size of the output array (number of variables in the original system).
See Also
RegenerateOriginalPoint RegenerateWorldOriginalSystemPoint.

Definition at line 3305 of file world.c.

References CT_REPRESENTATION, Error(), GetParameter(), Tworld::kinCS, Tworld::m, RegenerateMechanismSolution(), RegenerateOriginalPoint(), REP_JOINTS, Tworld::stage, and WORLD_DEFINED.

Referenced by RegenerateWorldOriginalSystemPoint().

unsigned int RegenerateWorldOriginalSystemPoint ( Tparameters p,
double *  s,
double **  o,
Tworld w 
)

Reconstruct a point in original kinematic system from a point in the simplified system. The difference with RegenerateWorldOriginalPoint is that here the output pointo only includes the system variables.

Parameters
pThe set of parameters.
sThe point in the simplified system.
oThe output on in the original system. Space allocated internally. Only includes the system variables.
wThe world to query.
Returns
The size of the output array (number of variables in the original system).
See Also
RegenerateOriginalPoint.

Definition at line 3334 of file world.c.

References GetCSNumSystemVariables(), Tworld::kinCS, NEW, RegenerateWorldOriginalPoint(), and Tworld::systemVars.

Referenced by main().

unsigned int WorldGenerateSimplifiedPoint ( Tparameters p,
double *  o,
double **  s,
Tworld w 
)
inline

Reconstruct a point in the simplified kinematic system from a point in the original system.

Parameters
pThe set of parameters.
oThe point in the original system. System and non-system variables!
sThe output in the simplified system. Space allocated internally.
wThe world to query.
Returns
The size of the output array (number of variables in the simplified system).
See Also
GenerateSimplifiedPoint WorldGenerateSimplifiedPointFromSystem

Definition at line 3362 of file world.c.

References Error(), GenerateSimplifiedPoint(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

Referenced by main(), and PathEffort().

unsigned int WorldGenerateSimplifiedPointFromSystem ( Tparameters p,
double *  o,
double **  s,
Tworld w 
)

Reconstruct a point in the simplified kinematic system from a point in the original system. The difference with respec to WorldGenerateSimplifiedPoint is that here 'o' only includes the system variables.

Parameters
pThe set of parameters.
oThe point in the original system. System variables only.
sThe output in the simplified system. Space allocated internally.
wThe world to query.
Returns
The size of the output array (number of variables in the simplified system).
See Also
GenerateSimplifiedPoint WorldGenerateSimplifiedPoint

Definition at line 3370 of file world.c.

References Error(), GenerateSimplifiedPoint(), Tworld::kinCS, RegenerateWorldSolutionPoint(), Tworld::stage, and WORLD_DEFINED.

void GetWorldInitialBox ( Tbox b,
Tworld w 
)
inline

Gets the kinematic search space for a given problem. The search space is deduced from the ranges of the kinematic variables involved in the problem.

This can be seen as a box from world constructor.

Parameters
bThe output box with the search space.
wThe world to query.

Definition at line 3388 of file world.c.

References Error(), GenerateInitialBox(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

void GetWorldSimpInitialBox ( Tparameters p,
Tbox b,
Tworld w 
)
inline

The same GetWorldInitialBox

Parameters
pThe set of parameters.
bThe output box with the search space.
wThe world to query.

Definition at line 3396 of file world.c.

References Error(), GenerateSimpInitialBox(), Tworld::kinCS, Tworld::stage, and WORLD_DEFINED.

Referenced by main(), and PathEffort().

unsigned int WorldManifoldDimension ( Tparameters p,
double *  point,
Tworld w 
)

Computes the dimensionality of the solution manifold assuming that the given point is regular.

Parameters
pThe set of parameters.
pointThe point on the manifold. In the original (not simplified form).
wThe world to query.
Returns
The dimension of the solution manifold.

Definition at line 3404 of file world.c.

References Error(), Tworld::kinCS, ManifoldDimension(), Tworld::stage, and WORLD_DEFINED.

Referenced by main(), and PathEffort().

unsigned int MaxWorldReduction ( Tparameters p,
Tbox b,
double *  reduction,
Tworld w 
)

Reduces the system variables as much as possible taking into account only the system equations (i.e., using only the Tworld::kinCS).

Parameters
pThe set of parameters to use when solving the cuiksystems (RHO, SIGMA,...).
bThe box with the ranges to reduce.
reductionThe reduction ratio (size of the output box / size of the input box).
wThe world to use in the reduction.
Returns
The box status after the reduction: EMPTY_BOX, REDUCED_BOX, REDUCED_BOX_WITH_SOLUTION, ERROR_IN_PROCESS.

Definition at line 3412 of file world.c.

References EMPTY_BOX, Error(), GetBoxLevel(), GetBoxSize(), Tworld::kinCS, MaxReduction(), Tworld::stage, SYSTEM_VAR, Tworld::systemVars, and WORLD_DEFINED.

void PlotWorld ( Tparameters pr,
Tplot3d pt,
double  axesLength,
Tworld w 
)

Adds a world (environment plus mechanism) in a 3D scene. Note that the the mechanism is not set in any valid configuration but all links are plotted with its local frame overlapped with the global one. To actually display the mechanism in a correct configuration you should use MoveWorld.

Parameters
prThe set of parameters.
ptThe 3d scene where we add the geometry.
axesLengthLength for the axes for each link. 0 not to display them.
wThe wold to plot.

Definition at line 3452 of file world.c.

References Close3dBlock(), Tworld::e, Error(), InitWorldCD(), Tworld::m, PlotEnvironment(), PlotMechanism(), Tworld::stage, Start3dBlock(), Tworld::wcd, and WORLD_DEFINED.

Referenced by AnimateWorld(), and main().

unsigned int RegenerateWorldSolutionPoint ( Tparameters pr,
double *  p,
double **  v,
Tworld w 
)

Computes the non-system variable in a kinematic solution.

Parameters
prThe set of parameters.
pThe input kinematic solution point with values for the system variables only.
vThe output kinematic solution point with values for all variables. The space for this point is allocated internally.
wThe world.
Returns
Then dimensionality of the output point.

Definition at line 3468 of file world.c.

References Error(), GetCSNumVariables(), Tworld::kinCS, Tworld::m, NEW, RegenerateMechanismSolution(), Tworld::stage, Tworld::systemVars, and WORLD_DEFINED.

Referenced by GetLinkTransformsFromSolutionPoint(), main(), MoveWorld(), PathEffort(), PlotForceField(), PrintWorldAxes(), WorldForceField(), WorldGenerateSimplifiedPointFromSystem(), WorldPotentialEnergy(), and WorldSample2DOF().

void WorldPrintAtoms ( Tparameters pr,
FILE *  f,
double *  pt,
Tworld w 
)

Generates a file with the atom centers in global coordiantes. The global coordinates are those given by a solution point (parameter pt).

This is used only when the world represents a molecule and we want to store the atom (i.e., the sphere) positions into a file. (world where the mechanisms is formed by spheres only are considered molecules).

The atoms centers are latter used by cuikpdb2world that coordinates biological inforamation (pdb file) and a world. It is very important that the atoms in the world are given exactly in the same order as those in the pdb.

This function assumes that the enviroment is empty (i.e., the world is fully defined by the links).

NOTE: the file with the atom positions generated by this functions is only used to generate world from pdb files. This is somehow weird since to generate the atom files we already need a world file. We proceed in way since the generated world is "sync" with the pdb and then, the results fo cuikatlas, cuikatlascenters, ... can be incorporated to the pdb (to generate new pdb's that can be analyzed with any standard molecular analysis software).

Parameters
prThe set of parameters.
fThe file where to store the atom centers.
ptThe solution point.
wThe world with the atoms.

Definition at line 3496 of file world.c.

References DeleteLinkTransforms(), Tworld::e, FALSE, GetEnvironmentNObstacles(), GetLinkTransformsFromSolutionPoint(), Tworld::m, MechanismPrintAtoms(), and Warning().

Referenced by main().

void WorldStoreRigidGroups ( Tparameters pr,
FILE *  f,
double *  pt,
Tworld w 
)

Generates files where the atoms (centers and radius) are stored grouped in rigid clusters. These files are not used within the CuikSuite, but only when testing the RigidCLL. We basically use the CuikSuite machinery to easily generate testing files for the RigidCLL package.

This function assumes that the enviroment is empty (i.e., the world is fully defined by the links). Moreover, for proper operation, all links must be composed by spheres (atoms).

Parameters
prThe set of parameters.
fThe file where to store the atom centers.
ptThe solution point.
wThe world with the atoms.

Definition at line 3511 of file world.c.

References DeleteLinkTransforms(), Tworld::e, FALSE, GetEnvironmentNObstacles(), GetLinkTransformsFromSolutionPoint(), Tworld::m, MechanismStoreRigidAtoms(), and Warning().

Referenced by main().

void WorldAtomJacobian ( Tparameters pr,
double *  sol,
unsigned int *  nr,
unsigned int *  nc,
double ***  J,
Tworld w 
)

Jacobian of the atom position w.r.t. the variables. In this context we assume that all balls in the mechanism represent an atom.

This is mainly used when manipulating worlds derived form biological information.

This Jacobian is used to transform the gradient of the energy in atom coordinates to a gradient in internal coordinates.

If the world is not only formed by spheres an error is triggered.

Parameters
prThe set of parameters.
solThe configuration.
nrNumber of rows of the output Jacobian.
ncNumber of columns of the output Jacobian.
JThe output matrix with the Jacobian.
wThe world.

Definition at line 3526 of file world.c.

References CT_REPRESENTATION, Error(), EvaluateJacobianXVectors(), GetLinkBody(), GetMechanismLink(), GetParameter(), GetPolyhedronCenter(), GetPolyhedronType(), IsMechanismAllSpheres(), LinkNBodies(), Tworld::m, NEW, Tworld::nl, Tworld::refEqsJ, REP_JOINTS, and SPHERE.

void MoveWorld ( Tparameters pr,
Tplot3d pt,
Tbox b,
Tworld w 
)

Moves the mechanisms defined in a world information to a given configuration.

Note that the box should only include ranges for the system variables. Therefore, the box given as a parameter is a sub-box of the box associated with Tworld::kinCS.

Parameters
prThe set of parameters.
ptThe 3d scene where the world has been previously added (see PlotWorld).
bThe box from where to get the configuration. The configuration used to plot the mechanism is defined from the center of the interval for the system variables. Note that by taking the center it is not warranteed the configuration to be valid but if boxes are small enough the committed error will be small too.
wThe world with the mechanism to move.

Definition at line 3581 of file world.c.

References CT_REPRESENTATION, DeleteLinkTransforms(), Error(), GetBoxCenter(), GetBoxNIntervals(), GetCSNumSystemVariables(), GetCSNumVariables(), GetLinkTransformsFromSolution(), GetParameter(), Tworld::kinCS, Tworld::m, MoveAndCheckCDFromTransforms(), MoveMechanismFromTransforms(), MoveWorldDOF(), NEW, RegenerateWorldSolutionPoint(), REP_JOINTS, Tworld::stage, TRUE, Warning(), WORLD_DEFINED, and WorldErrorInEquations().

Referenced by AnimateWorld(), and main().

void PrintWorldAxes ( Tparameters pr,
FILE *  f,
Tbox b,
Tworld w 
)

Prints a point and the axis for each of the different joints in the mechanisms. This is latter used to generate the mechanism Jacobian.

The values are all in global coordinates.

Parameters
prThe set of parameters.
fThe file where to store the information.
bThe box with the solution to use.
wThe world to query.

Definition at line 3637 of file world.c.

References CT_REPRESENTATION, Error(), EvaluateEqualityEquations(), FALSE, GetBoxCenter(), GetBoxNIntervals(), GetMechanismJoint(), GetParameter(), Tworld::kinCS, Tworld::m, NEW, Tworld::nj, Tworld::nl, PrintJointAxes(), Tworld::refEqs, RegenerateWorldSolutionPoint(), REP_JOINTS, Tworld::stage, and WORLD_DEFINED.

Referenced by main().

void PrintWorldCollisionInfo ( FILE *  f,
char *  fname,
Tworld w 
)

Prints information collected durint last collision check.

See StoreCollisionInfo for more details.

This function implicitly assumes that the last link is an abject being manipulated by the rest of links.

Parameters
fFile where to write the collision script.
fnameFile from where we obtained the world information. The last part of the filename (from the last '_' to the end) is assumed to be the name of the object. This name is the one used to call the sub-matlab scripts giving contact points and normals on the object.
wThe world.

Definition at line 3674 of file world.c.

References Tworld::endEffector, Tworld::m, StoreCollisionInfo(), and Tworld::wcd.

Referenced by on_cuikmove_save().

void MoveWorldDOF ( Tparameters pr,
Tplot3d pt,
double *  dof,
Tworld w 
)

Moves a mechanisms to a configuration given by values for the different degrees of freedom of the joints forming the mechanisms. This might be a configuration not fulfilling the whole set of equations (loop closures might be violated).

This basically generates a configuration in our formulation from the degrees of freedom values and calls MoveWorld.

Parameters
prThe set of parameters.
ptThe 3d scene where the world has been previously added (see PlotWorld).
dofThe array of doubles given the values for all the degrees of freedom in the mechanism.
wThe world with the mechanism to move.

Definition at line 3680 of file world.c.

References DeleteLinkTransforms(), Error(), GetLinkTransformsFromDOF(), Tworld::m, MoveAndCheckCDFromTransforms(), MoveMechanismFromTransforms(), Tworld::stage, TRUE, WORLD_DEFINED, WorldDOF2Sol(), and WorldErrorInEquations().

Referenced by main(), and MoveWorld().

unsigned int WorldDOF2Sol ( Tparameters p,
double *  dof,
double **  sol,
Tbox b,
Tworld w 
)

Defines a configuration in cuik variables from a configuration given by degrees of freedom.

There is no guarantee that the ouput box fulfill all equations (it is generated from a dof probably adjusted in open loop).

Parameters
pThe set of parameters.
dofThe values for each of the degrees of freedom of the mechanism.
solThe re-constructed solution point (including system and non-system variables an in the origional, non-simplified, system !!).
bThe solution point in form of a box. Only initialized if 'b' is not NULL.
wThe world with the mechanism description.
Returns
The number of elements in the solution.

Definition at line 3708 of file world.c.

References AXIS_H, CT_REPRESENTATION, DeleteLinkTransforms(), Tworld::dof2joint, Tworld::dof2range, Error(), GenerateJointSolution(), GenerateLinkSolution(), GetCSNumVariables(), GetCSVariableID(), GetJointRangeTopology(), GetLinkName(), GetLinkTransformsFromDOF(), GetMechanismJoint(), GetMechanismLink(), GetParameter(), HTransformGetElement(), INF, InitBoxFromPoint(), IsGroundLink, Tworld::joint2dof, JointFromID(), JointToID(), Tworld::kinCS, LINK_TRANS, Tworld::m, Tworld::ndof, NEW, Tworld::nj, Tworld::nl, NO_UINT, Tworld::openLink, PI2PI, REP_JOINTS, Tworld::stage, TOPOLOGY_S, and WORLD_DEFINED.

Referenced by GetSolutionPointFromLinkTransforms(), main(), MoveWorldDOF(), on_cuikmove_save(), and WorldErrorFromDOFs().

void WorldSample2DOF ( Tparameters p,
double *  sample,
double *  dof,
Tworld w 
)

Transform a configuration given in cuik variables to configuratoin given in degrees of freedom.

In some sense this is the inverse of WorldDOF2Sol. Note the difference in what here the sample must include only system variables.

Parameters
pThe set of parameters.
sampleThe array with the sample to convert. This MUST include only system variables.
dofSpace where to store the ouput. It must have as many entries as dof of the mechanisms (see GetWorldNDOF).
wthe world with the mechanism description.

Definition at line 3800 of file world.c.

References CT_REPRESENTATION, DeleteLinkTransforms(), Error(), GetLinkTransformsFromSolution(), GetMechanismDOFsFromTransforms(), GetParameter(), Tworld::m, Tworld::ndof, RegenerateWorldSolutionPoint(), REP_JOINTS, Tworld::stage, and WORLD_DEFINED.

Referenced by main().

void AnimateWorld ( Tparameters pr,
char *  pname,
double  axesLength,
double  frameDelay,
Tlist p,
Tworld w 
)

Produces an animation along a path. An animation is a 3d geometry that can be browsed with geomview.

Note that the boxes in the list should only include ranges for the system variables. Therefore, the box given as a parameter is a sub-box of the box associated with Tworld::kinCS.

Parameters
prThe set of parameters.
pnameName for the file with the geometry to generate.
axesLengthLength for the axes for each link. 0 not to display them.
frameDelayExtra time (in seconds) added in between frames. In the default mode animations show 10 frames per second (i.e., the frame delay is 0.1). This parameter can be used to slow down animations. This is very useful when animating sets of isolated solutions: we can freeze each frame time enough to inspect each solution separately.
pThe list of boxes with the frames of the animation.
wThe world.

Definition at line 3837 of file world.c.

References Advance(), Close3dBlock(), ClosePlot3d(), Delay3dObject(), EndOfList(), Error(), FALSE, FINAL_FRAME_DELAY, First(), FRAME_RATE, GetBoxNIntervals(), GetCSNumNonDummyVariables(), GetCurrent(), INITIAL_FRAME_DELAY, InitIterator(), InitPlot3d(), Tworld::kinCS, MoveWorld(), PlotWorld(), Tworld::stage, Start3dBlock(), TRUE, and WORLD_DEFINED.

Referenced by main().

void PrintWorldCS ( Tparameters p,
char *  fname,
Tworld w 
)

Generate a file with the cuiksystem generated from the world information.

Parameters
pA set of parameters.
fnameThe base name for the file names to create
wThe world with the cuiksystems to print.

Definition at line 3881 of file world.c.

References CreateFileName(), CUIK_EXT, DeleteFileName(), Error(), GetFileFullName(), Tworld::kinCS, PrintCuikSystem(), Tworld::stage, and WORLD_DEFINED.

Referenced by main().

void PrintWorld ( char *  fname,
int  argc,
char **  arg,
Tworld w 
)

Prints the world in a form that can be read by InitWorldFromFile.

Parameters artc and arg can be used to add information in the world about how it was generated. Use 0 and NULL to add no information.

Parameters
fnameThe file where to store the world information.
argcNumber of strings to be added to the world file header as comments.
argStrings to be added to the world file as comments. Right now, this is used to store in the command line used to create it.
wThe world to print.

Definition at line 3902 of file world.c.

References CreateFileName(), DeleteFileName(), Tworld::e, Error(), GetFileExtension(), GetFileFullName(), GetFileName(), GetFilePath(), Tworld::m, PrintCollisions(), PrintEnvironment(), PrintMechanism(), and WORLD_EXT.

Referenced by main(), and PrintBioWorld().

void DeleteWorld ( Tworld w)

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

Parameters
wThe world to delete.

Definition at line 3952 of file world.c.

References DeleteEnvironment(), DeleteMechanism(), DeleteWorldCD(), DeleteWorldCollisionInfo(), DeleteWorldCS(), Tworld::e, Tworld::m, Tworld::stage, and WORLD_DEFINED.

Referenced by DeleteBioWorld(), and main().