Question over data input/output
-
Well, I suppose this is good a place as any for a first post. I will freely admit, I'm rather a novice at scripting in Sketchyphysics, and I do plan to pick up more of that on my own. But I'm wondering specifically about Sketchyphysics' ability to output data. In particular, velocity and the energy spent by a motor--not kinetic energy per se, but more in terms of total energy consumption. I am aware of a bit of script that outputs velocity, that I've used before, though for some reason it spits back 5 different values at a time. And energy I don't know, period.
Secondly, as this is for a project that I'm creating, I was wondering if the data over time could be output automatically to a text file. Preferably even an Excel file, but anything would be better than nothing.
Lastly, this may be a bit silly, but what exactly is the relationship between "framerate" under Plugins > Sketchy Physics > Physics Settings, and the actual frame rate that the program uses? I'd like to be able to take measurements relative to time, so I need to figure out how that works.
Thank you.
-
Well I guess we should dissect this:
-
motors operate on an abstract of acceleration and dampening and aren't really connectable to the real world, if you want proper energy figures you need to get physics formulas and then work out how to apply them to the model (actual size, weight, speed, accelerations,...)
-
getVelocity returns a movement vector, in what direction the object is moving and how fast
-
writing to files is doable as Sketchyphysics is based on Ruby script, and it can do a whole whole number of things.
But I'm not sure about Excell files as MS likes to keep their data standards hidden. -
framerate setting in Physics Settings actually determines howmany physics iterations will be done before the visible frames update, this does not control the visible frames.
So the default 3 setting means it will compute the physics states 3 times and then update the model. -
FPS is best determined by opening the Ruby Console, starting the simulation and then ending it after 500-1000 frames, to get fairly accurate average FPS figures.
-
-
Ah, okay, that's what I was afraid of with motors. I thought that might've been the case, but I wanted to confirm that. Easiest thing it sounds like then is to get SketchyPhysics to output velocity data into a text file, and then probably load it into Excel later and have it do some calculations. At least Excel I've been using for longer, so I know a bit better.
For the record, I'm trying to help design a project to be used with middle school students. We don't expect them to be able to script or come up with their own formulas, so a lot of that is what I'm working on now.
One more thing though, what does the output of getVelocity use for its "time" component? Is that movement v. physics iterations, or visible frames, or something else?
Edit: (Because I have one more question now.)
On an aside, is there a particular method for calling the (integer) frame number to use as part of a script? The articles about scripting here seemed to suggest calling it directly as if it was a variable, but I seem to be having problems doing that.
-
Added a small example of how to quickly get/display data.
Don't count the kids out too quickly, if you show them something interesting they will be digging in like crazy, tho these energy calculations aren't quite the right lure.
Velocity and all other data/scripts are updated on visible frames, so the calculations should be fairly accurate.
In the physics engine frame anyways, correlation to reality may be questionable.Need some more time on those files tho, CPhillips added a small security measure with the new SP versions so we can't mess up peoples files with our models, so I need to think of a workaround.
-
I second Mr. K on the sense that middle schoolers might delve into the scripting anyway...(all those video game hours won't have been wasted). As you go through the installs on the school computers I suggest compiling a list of essential ruby scripts/plugins (webconsole for one) that should be installed with it. I also found that Notepad++ is a good open source (always important when budgets are involved) editor for things beyond Ruby. Though my classroom experience has been with technical college students I also have a middle schooler who I KNOW was prepared both for more programming and 3d at 5th grade than she was exposed (aside from the video games). See Snatch at MIT and Alice at Carnegie Mellon for good places to get them tied into simple programming. Upon installing sketchup if nothing else they then have access to Ruby which is almost as much of a gem as Mr. K.
One more unsolicited suggestion (and this one may be a stretch due to curriculum). Much of ruby works on the fact that vectors in 3d space have THREE components and for the most part the curriculum does not cover that until long into high school. The ruby command for cross product (the cross product of any two vectors in a plane yields the normal) and a little creativity should have the students talking in 3d coordinates and comprehending directional vectors in no time....No slight to my students but 5th graders are more malleable.
Best of luck with the project....its great to see this incredible resource Sketchcup and sketchy physics making out to those who must save the planet.
-
Turns out it wasn't that big of a deal getting files to work, so here is one simple example.
If you got any questions just ask away.
Advertisement