I would have taken this offlist some time ago, were it not that I am
talking from a position of almost total ignorance myself, and might
make some huge error that needs correcting). The reason I am even
trying to explain this is a feeling that explanations from someone who
knows only fractionally more than you, and who remembers not knowing
anything, are often easier to follow.

On 9 June 2010 10:10, Viesturs Lācis <[email protected]> wrote:
>
> I think that I give up trying to do this by myself (see below on
> reasons, that have driven me to the desperation)  and so I would like
> to ask, if anyone can write a kinematics module for me and what would
> be the fee for that?

If you are lucky you will find someone who will do the work for
waterjet cut parts. Or if the puzzle looks interesting enough,
somebody might do it for fun. I would have been astonished if you
could figure it out yourself in only an evening, by the way. In fact I
would have been rather depressed too, as it has taken me some months
to get the limited understanding I currently have.

This was quite a complicated kinematic module, with slightly scary
things like Jacobians in it. Perhaps an evening reading the stuff
below while looking at rotatekins.c and rotatekins.h will help.

> int kinematicsForward(const double *joint,
>                      EmcPose * world,
>                      const KINEMATICS_FORWARD_FLAGS * fflags,
>                      KINEMATICS_INVERSE_FLAGS * iflags) {

EMC calls the code in the Kinematics module, and passes into the
function the machine state that it needs to do the calculations.
If you look at the program lines which I have left in above your
question, the function "kinematicsForward" is being called as a
function by some other part of the code.

Take a very simple case of a function to add two numbers, it might look like

double function sum(double A, double B) {
return A + B
}

so any other part of the code could use Z = sum(13, 11) which would
call the code in the function, where A would return a value of 13, and
B a value of 11, and the numbers in each case would be encoded in the
computer memory as "double" (ie a group of 8 bytes that encode a
decimal number in a specific way)

What we have in the kinematics module is a more complex version of the
same thing. The kinematicsForward function is being called with the
following parameters (A and B were parameters above)

a "double" called "joint"
a structure called an "emcPose" called "world"
a structure called KINEMATICS_FORWARD_FLAGS called "fflags"
and a similar set of iflags.

so, joint, world, fflags and iflags are how the machine state is
passed "into" the function. some of these are "structures" or sets of
data of various types defined in a header file somewhere. for example
a structure might be defined called a "car" with an integer number of
wheels, a character string model name and a double-precision weight.
then some simple C-code might say

car Z; // create a "car" type data object called Z
Z.wheels =3;
Z.name = 'Reliant Robin';
Z.weight = 603.345;

The function then defines a set of variables for its own internal use:
>  go_pose *pos;
>  go_rpy rpy;
>  go_real jcopy[GENSER_MAX_JOINTS]; // will hold the radian conversion of 
> joints
>  int ret = 0;
>  int i, changed=0;

"pos" is a structure of type "go_pose", "rpy" is a "go_rpy" structure
and so on. these structures are probably defined in terms of other
data types in the .h file that goes with the .c file, or in some other
linked header file.

> They contain large part of those unknown functions/variables or
> whatever they are, but I have no f***ing idea, where to find, what
> they mean.

If it makes you feel any better, I know exactly how you feel.
 I guess most EMC programmers use IDEs (Integrated development
environments) of various sorts that make finding the structure
definitions much easier. For example, I use one where you can
right-click a structure name and it finds the header-file definition
for you.

What might be causing you some confusion is that different kinematics
modules are using different variable names to contain the same data,
so rotatekins used one called "pos" and the one above uses one called
"world" to hold the exact same data, an EmcPose structure.

There is one thing that I have left out of all the discussion above: A
function can only return one value, generally just a success or
failure code. The parameters passed to a function in C are passed as
numeric values (some other programming languages pass the variable
itself, which can be good and bad) With a complicated function like a
kinematics module we need to return a lot more data to the bit of the
program that calls the kinematics function than just one number. That
is what the "*" characters are about, "double *j " is actually sent to
the kinematics function as the memory address where a set of doubles
is stored, to be used to recieve the results of the calculations.
This means that the kinematics function can both read and write the
memory where the joint positions are stored (which is how the
calculation results get back out of the function to control the
motors). so joints[1] = 10; anywhere in the code will set the value of
that memory location to decimal 10, in the double data format, where
other code can use the value, even if that other code uses a totally
different variable name for the data.
the joints[3] structure actually means "the value stored in the memory
location three  "double" data-sizes along from the address sent across
to us by *joints"
You have to be careful not to look too far up that array, I suspect
that joints[10] would point to some totally different memory,
containing totally different data, and C doesn't check that sort of
thing. That is what the GENSER_MAX_JOINTS constant is, it's defined in
a header file somewhere, and is in ALL_CAPS as a clue that it's a
constant.


</blind-leading-the-blind>

-- 
atp

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to