Submitted by John Pyles on Thu, 2004-10-28 00:22
Hi,
I'm fairly new to Framsticks and I think Framsticks could be a big help in
some work I'm doing.
I'm interested in the animations of Framsticks' locomotion. What I'd like to
do is find a way to export the X,Y,Z coordinates of the center of mass of
each Framstick neuron and stick for every animation frame. I've played with
some of the export options, but I don't really know how to extract what I
want from those file formats.
Any suggestions for a way to do this? For every animation frame, I'd like to
end up with a list of the coordinates of the center of mass for each part of
the creature.
Thanks very much in advance!
-John
Forums:
Re: Coordinates from Framsticks...
> I'm interested in the animations of Framsticks' locomotion. What I'd like to
> do is find a way to export the X,Y,Z coordinates of the center of mass of
> each Framstick neuron and stick for every animation frame. I've played with
> some of the export options, but I don't really know how to extract what I
> want from those file formats.
Good news! Very easy to do! Use the scripting languate, FramScript.
See the scripts/standard.expdef file.
In the onStep() function iterate through all creatures,
for each creature iterate through all its Parts, and
print (to stdout or to a File) the coordinates, or whatever
you are interested in.
You may find inspiration in other fragments in the
standard.expdef, or in other script files :-)
MacKo
Re: Coordinates from Framsticks...
Thanks so much! I'll try that! I haven't delved much into the scripting yet,
but it looks like a powerful tool. Hopefully I'll figure it out. Great
software!
-John
"Maciej Komosinski"
wrote in message news:clrggb$qdt$1@cancer.cs.put.poznan.pl...
>> I'm interested in the animations of Framsticks' locomotion. What I'd like
>> to do is find a way to export the X,Y,Z coordinates of the center of mass
>> of each Framstick neuron and stick for every animation frame. I've played
>> with some of the export options, but I don't really know how to extract
>> what I want from those file formats.
>
> Good news! Very easy to do! Use the scripting languate, FramScript.
> See the scripts/standard.expdef file.
>
> In the onStep() function iterate through all creatures,
> for each creature iterate through all its Parts, and
> print (to stdout or to a File) the coordinates, or whatever
> you are interested in.
>
> You may find inspiration in other fragments in the
> standard.expdef, or in other script files :-)
>
>
> MacKo
>
Re: Coordinates from Framsticks...
>>In the onStep() function iterate through all creatures,
>>for each creature iterate through all its Parts, and
>>print (to stdout or to a File) the coordinates, or whatever
>>you are interested in.
something like... (not tested)
//assumed group #0 only
var i,j,c,p;
for (i = 0;i < LiveLibrary.getGroup(0).creaturecount;i++)
{
c=LiveLibrary.getGroup(0).getCreature(i);
for (j = 0;j < c.numparts;j++)
{
p = c.getMechPart(j);
Simulator.print(""+p.x+"\t"+p.y+"\t"+p.z"+\n); //or to a File
}
}
this will print it to the messages window (and messages.out file),
you need to create the File object to have it saved into a file.
MacKo
Re: Coordinates from Framsticks...
Very interesting method (also for me)...
Just a complement : how can I do the same thing with the command line =
version (frams.exe) ?
Can I send the informations simply to the console ?
Alain
Le Fri, 29 Oct 2004 14:03:52 +0200, Maciej Komosinski =
a =E9crit:
>>> In the onStep() function iterate through all creatures,
>>> for each creature iterate through all its Parts, and
>>> print (to stdout or to a File) the coordinates, or whatever
>>> you are interested in.
>
> something like... (not tested)
>
>
>
> //assumed group #0 only
> var i,j,c,p;
> for (i =3D 0;i < LiveLibrary.getGroup(0).creaturecount;i++)
> {
> c=3DLiveLibrary.getGroup(0).getCreature(i);
> for (j =3D 0;j < c.numparts;j++)
> {
> p =3D c.getMechPart(j);
> Simulator.print(""+p.x+"\t"+p.y+"\t"+p.z"+\n); //or to a File
> }
> }
>
>
> this will print it to the messages window (and messages.out file),
> you need to create the File object to have it saved into a file.
>
>
>
> MacKo
>
-- =
Utilisant le client e-mail r=E9volutionnaire d'Opera : =
http://www.opera.com/m2/
Re: Coordinates from Framsticks...
> Very interesting method (also for me)...
> Just a complement : how can I do the same thing with the command line
> version (frams.exe) ?
> Can I send the informations simply to the console ?
It can be done the same way, and it will be printed on the
console window if you use Simulator.print(...).
MacKo
Re: Coordinates from Framsticks...
ok thanks...
But another problem for the solution with write in Files :
I try this :
in onExpDefLoad :
...
File.createDirect("Export.txt", "Exporting Datas");
(this works only if a create the scripts_output directory : why ?)
in onStep :
...
File.open("Export.txt");
//assumed group #0 only
var i,j,c,p,s;
for (i = 0;i < LiveLibrary.getGroup(0).creaturecount;i++)
{
c=LiveLibrary.getGroup(0).getCreature(i);
for (j = 0;j < c.numparts;j++)
{
p = c.getMechPart(j);
s = (""+p.x+"\t"+p.y+"\t"+p.z+"\n");
File.writeString(s);
File.appendDirect("Export.txt","Exportation des données"); // THIS
DOES'NT WORKS !!!
}
}
File.close("Export.txt");
But nothing is wrtiten in the file... How to ?
thanks
alain
"Maciej Komosinski" a
écrit dans le message de news: cnllqn$alh$2@cancer.cs.put.poznan.pl...
>
>> Very interesting method (also for me)...
>> Just a complement : how can I do the same thing with the command line
>> version (frams.exe) ?
>> Can I send the informations simply to the console ?
>
> It can be done the same way, and it will be printed on the
> console window if you use Simulator.print(...).
>
>
> MacKo
>
Re: Coordinates from Framsticks...
> ok thanks...
> But another problem for the solution with write in Files :
> I try this :
>
> in onExpDefLoad :
> ...
> File.createDirect("Export.txt", "Exporting Datas");
>
> (this works only if a create the scripts_output directory : why ?)
because all Files are created in that directory - it must
exist.
> in onStep :
> ...
> File.open("Export.txt");
> But nothing is wrtiten in the file... How to ?
This is not the correct usage of the File object.
See the "scripts_sample/standard-log.expdef", functions
ExpProperties_dumpgens_call()
ExpProperties_calcsim_call()
for examples on how to create a file, write to it, and
close.
Good luck,
MacKo