INTRODUCTION TO HIERARCHICAL LINKS

One of the most powerful features of WTK R6 is its ability to link objects in a hierarchical manner. A movable hierarchy is a group of nodes which moves together as a whole but whose sub-parts can be moved independently. See the robot arm in figure 12.

 

figure 12

 

Each part of the robot arm, the base, lower arm, middle arm, and effector, are created as separate movable nodes. And well call the pointer to these nodes base, lower, middle, and effector. Then to assemble the robot we would make the following calls

 

WTmovnode_attach(base, lower,0);
WTmovnode_attach(lower, middle,0);
WTmovnode_attach(middle, effector, 0);

 

This results is a hierarchy in which the base is the root, the lower arm is attached to the base, the middle arm to the lower arm, and finally the effector to the middle arm. When a geometry in the hierarchy moves (such as the base) everything that is hierarchically below it moves. Geometries that are hierarchically above it are not affected. For instance if the middle arm moves then the effector moves but the base and lower arm are unaffected.

Any type of sensor can be attached to the various segments to cause the arm to move.

NOTE: If you wish to remove any section of the hierarchy or delete a section then the hierarchy must be disassembled at that point.

 

WTmovnode_attach

Attaches the child node to the parent node as the attachednumth attachment. The parent node MUST BE a movable node while the child node can be a movable or regular node. Attachments begin counting at 0. In other worlds the first attachment is attachment 0, the second attachment 1, and so forth. Just like C language arrays.

This function will not detach existing attachments. Instead it creates an additional connection.

SYNTAX:

FLAG WTmovnode_attach(WTnode *parent, WTnode *child, int attachednumth);

ARGUMENTS:

parent -- The movable node to attach to
child --
The node to attach -- doesn’t have to be a movable
attachednumth --
The place in the hierarchy of the parent to attach the child. If you are not sure haw many
attachments a particular node has then use the WTmovnode_numattachments to find out
This number must be in the range of 0 to WTmovnode_numattachments.

RETURN TYPE:

FALSE if the parent node is not a movable or the attachednumth is out of range.

WTmovnode_detach

Detaches the attachednumth node of the parent node. This may leave the detached node with no parent in which case it becomes an orphan node. The parent node MUST BE a movable node, and attachednumth MUST BE in the range of 0 to WTmovnode_numattachments -1.

SYNTAX:

FLAG WTmovnode_detach(WTnode *parent, int attachednumth);

ARGUMENTS:

parent -- The parent node in question. This MUST BE a movable node
attachednumth --
The attachment number to detach

RETURN TYPE:

FALSE if the parent node was not a movable or the attachednumth is out of range.

WTmovnode_numattachments

Returns the number of nodes attached to a parent node.

SYNTAX:

int WTmovnode_numattachments(WTnode *parent);

ARGUMENTS:

parent -- The movable node in question. This argument MUST BE a movable node.

RETURN TYPE:

The number of attachment to that node. If the node is not a movable or has no attachments then this function return 0.

 

Assignment 13

project definition: