Wednesday, March 4, 2009

Production Line






Written 1 March, 2009

Production Line

I just completed a tricky build, and I'm wanting to pat myself on the back-- and what better place to do it than this blog?

I took it upon myelf, you see, to build a production line in the robot sanitorium. That meant, of course, conveyor belts, pulley systems, observation rooms, and copterbots. Copterbots!

Building a conveyor wasn't easy, but it was straightforward. I made the belts and rollers and an appratus to support them. Then I added an on/off button and indicator light and put scripts in the rollers and belts to animate their textures when the switch was turned on. Then I duplicated the first conveyor (minus the switch) and set it so it descended to one end of the first belt.

I then made a prim cube (the production line, I decided, would carry prototype robots [cubes]) and, using non-physical movement, set it to riding down the conveyor belt. With some adjusting, I got the speed right so it would stay stationary with respect to the moving belt.

When the cube reached the end of the first belt I scripted it to drop to the first and then ride in the other direction along the bottom conveyor. At the end, I scripted it to drop into a tray.

It took a lot of tweaking to get the drops just right, but at the end of it all I had a cube that would drop onto the top conveyor from a pipe and travel all the way to a cube at the end of a conveyor system, then, after 30 seconds, return to its start position.

Next, I made a little copter and scripted it to travel to the spot where the cube had come to rest, pick it up, carry it to a chute, and drop it (with a great clunking sound) into a chute.

I don't think it's possible (or at least it's not easy) to script an object to attach a prim to itself, so in actually I put a cube on the copter and scripted it to become visible with the conveyor-cube was picked up and to disappear when the cube was dropped into the chute.

All of this was intricate and complex, but reasonably straightforward. But then came the tricky part. I had to make a row of cubes travel down the conveyor and cooperate with the copter.

I took a copy of the conveyor cube into memory and added a die script to the original so at the end of its journey it would call the copter bot, wait a few seconds, then kill itself. I took it into memory and placed it in a prim with a script that would rez the cube upon voice command.

Then came the tricky part-- making the rezzed cube face in exactly the right direction so it wouldn't march off into space.

Second Life uses a complex system of rotation based, for some reason I can't comprehend, on quaternions, of which I had never heard. Apparently they're based on radians, a unit of measure I learned about in geometry but always considered archaic. Just to make things difficult, LSL adds a fourth vector.which I absolutely can't figure out.

I finally figured out that a quaterion is (I think) 90 degrees-- but putting PI/4 didn't change the orientation by 90 degrees. PI/3 did-- but not exactly. The cube would move in pretty much the proper direction down the conveyor, but would eventually drift off the belt.

For no particular reason I changed PI/3 to PI/2.9. The cube moved off track a little faster. PI/3.1, however, kept the cube on belt, at least close enough to center for government work.

I've no idea why that worked.

I timed the transit of the copter bot-- about seventeen seconds-- and set the rezzer to rez (but only when the conveyor was on) a cube every twenty-two seconds.

Then I pressed the on button and hoped for the best.

And it worked!

When the system is turned on, it takes a few minutes for the first cube to travel to the copterbot, but after that the copter is kept busy moving cubes to the chute. The progress of the cubes is inexorable.

I keep expecting the copterbot to get behind, like Lucy on the pie assembly line, but it never does. It never breaks down, just fetches and carries the cubes.

Damn, I'm good!

And lest I forget, modest!

Above all, modest!


See the conveyor system at the Whimsy Kaboom Robot Sanitorium.

4 comments:

Allen™ said...

I must confess I find rotations in LSL just as confusing but after a quick read of your post it occurred to me that PI/3.1 is mighty close to 1. Might a value of one put your cube in just the right rotation?

Just a thought. I'm too tired at the moment to try it.

Melissa Yeuxdoux said...

Radians aren't archaic; they're natural in a sense. Degrees are arbitrary, but on a unit circle (one with radius = 1), if you start at (1, 0) and move counterclockwise around the circle a distance d, then the angle formed by line segments from the center (0, 0) to (1, 0) and to the point you end at is exactly d radians.

Tycho Beresford said...

Modesty is next to Godliness. Or is it Goddessliness? Anyway good job!

Cheyenne Palisades said...

If you say so.