Sunday, August 31, 2008

Maya + Python + Arduino + Servo (Part 2)



An update on the previous video. This time I have written a Python Plugin for maya. This makes it now possible for real time (viewport to servo) communication, without the need for dynamic playback. So now it is possible to literally keyframe your servo's position in time and playback it's animation!

A big thank you to John Park for blogging about these Ideas on the Make Blog. Check out what people have to say about it here

Edit: I have made some progress on this technique click here for more info

15 comments:

samiam said...

Nice work Dan

Did you want to share the source?

Im curious about how it is all done.

Wouldnt it be cool to make a simple robot that you could keyframe in Maya and then playback in real life.

Sam

Dan Thompson said...

Thanks Sam,

If you check out the part 1 video post you will find all the necessary links which have the code and techniques I've used to set this up. This should get you started.

The only code I have written is the python plug-in for maya. I haven't released this yet because I need to apply for a unique plug-in ID from Autodesk. Otherwise maya could crash for some people and I could get lots of angry bloggers on here ;)

I plan to document the whole thing thoroughly, but it may take some time. I will post the plugin code once I get the ID, then I will release it on www.highend3d.com for download.

Anonymous said...

Will this node be available on other platforms? I would be interested in this for maya on Mac OS X...

Dan Thompson said...

Hi Jeremy,

The node is written in python so it doesn't need compiling. So I imagine it would just work on a mac maya 8.5 an up.

Though I could be wrong. There are no immediate plans for a cross platform release. Got too much on my plate already! ;)

Anonymous said...

I was just looking into that - I didn't realize you could pop python into a plugin node like that. I assume that's got some speed advantages?

I just started using python and am unfamiliar w/ the serial out commands as of yet - I can assume that you're going serial out directly to the arduino?

I was using the Maya commandport with Processing to do basic mocap w/ an arduino (and started on a wii-mote but ran out of free time) but I'd love to be able to go back out of maya right thru serial..

If you've got any pointers I'd love to hear 'em... thanks!!

ColorCode AR599 said...

Hi Dan,
I've been working on similar idea for the MAKE controller, but hit a bit of a wall as I'm a bit new to python plugins for maya. I can read the values fine, but can't get my node to respond to the incoming values. Are you routing this through the device manager or just setting to a node directly. I teach a course in Architecture where students construct custom physical modelling interfaces for maya. Previously I've been relying on a bit of a hack to make this work, but if you'd be willing to share some hints/code I would really appreciate it and of course would credit you in the port to another open source controller.

Dan Thompson said...

I'm afraid my way might be a bit of a hack too. Here's a tip I learned. To force the node to update and run it's pySerial commands, you need to have an output attr on the node and connect it to any other node's (a sphere's rotate.y) float attr.

This flags your node's output plugs as "dirty", the node sees the flags, stops being lazy and computes your pySerial code, which sends the data.

I promise I'll release this soon. Just don't want to release something hacky and then get bombarded with questions if you know what I mean ;)

Good Luck, do you and your students have a website?

ColorCode AR599 said...

I'm focussing on the other direction to start with - Input from sensors to a python Node. I was advised to use MTimerMessage so that it samples the value every so many seconds and also dirties the plug....Just haven't had the free time to finish it. Are you looking at input as well or just output at the moment?

Dan Thompson said...

Hi Nick,

Just focusing on the output at the moment. This is my first attempt at python and at maya's API. So I started with something simple.

I have wondered about what approach to take when using input devices. Someone mentioned midi. But I was hoping to use serial and python. Sorry I can't be of more help. Sounds very interesting.

Is there some place I can watch your progress? I'd loved to see how it works.

Dan.

Piasa Valley FIlms said...

Hey Dan,
Im truly blown away with this technique you have been working on. Im looking at building a motion control rig for our studio doing VFX backplates for our clients documentaries. But im really curious what would our creatures we animated would look like in the real world. Has there been any progress since your last post Dan? Do you know with the setup you have online, can you use more then one servo motor with the one Arduino card speaking to Maya.

Ged

Dan Thompson said...

Hey Ged what is the name of your studio? Do you have a web site?

Funny you should mention this now. I have been working on this just this weekend!

Currently the setup works with up to four servos at once but it would be easy to modify the code to add more. Eventually I would like to get it to talk to a seperate multi servo board for better bandwidth.

I know I keep saying it, but I will have something for release real soon. I'm currently adding support for driving stepper motors as well, but it's much harder to code than a servo due to the limitless rotations a stepper can make. It's a different data structure.

Watch this space, I can assure it's my number 1 personal project at the moment (and I have many of them) :)

Piasa Valley FIlms said...

Hey Dan,
I dont know if my boss would find this usefull from what we do day to day, but i do know it would come in handy in other aspects. Have you heard of Hive Studios? We are in NSW the Blue Mountains. www.hivestudios.com

By trade I'm more of an animator by profession. I'm also working on a film project myself, but haven't had the time and location to even start principle filming yet. It will be a live action low budget film.

You mentioned about the Stepper Motors soft cover book on one of your videos and i went out to buy one for myself as well. So i myself am new to this field, but have planned to build a remote control crane. I have put a crane together but now i may revisit the drawing board to turn it into a motion control crane.

Have you heard about the Pan/Tilt/ 985 Series System from servocity? Do you know if i used that with the Arduino card and replacing the noisy servos with the Stepper Motor (ROB-08420). Have you had any success transferring movements from about 4 Stepper Motors through the arduino board into Maya, while having Maya key the key frames in real time?

Hear from you soon.
Cheers
Ged

Dan Thompson said...

I have not heard of Hive Studios till now. Sounds like a nice location to work.

I have heard of the pan tilt head you mentioned, Good for lighter weight applications. I am planning on making something similar from scratch with extruded aluminum from a Bunnings Hardware Store. Servos are usually quieter than stepper motors in my experience.

The Maya to Stepper communication is what I'm working on at the moment. But I'm not quite there yet. This is a good community for motion control and timelapse http://www.timescapes.org/ . Good luck with your rig!

Kevin Larson said...

Wow. I just stumbled onto your blog and I'm really excited about how you have Maya working with servos rc servos. I have been building a motion control rig for hte last year in my spare time I currently have a pan tilt unit working in Mach3. The base is made of Pittmann servos and gecko servo drivers. Do you think it is possible to have Maya control multiple servos like my Pittmanns thought the parallel port? I'd love to give it a try if you can point me in the right direction.

Dan Thompson said...

Hey Kevin, if it's a parallel port I'd say it would be possible. pySerial and the Maya API is what you want. The current setup in the video you saw only works with rc servos that don't go pass 180 degrees. But if you are keen to get your hands dirty, follow the links on part 1 of this series. It's should give you a good starting point.

I should mention that I'm not confident that sending moco move data over serial while filming is the way to go. I plan to have a system that caches to memory on a micro controller and sources the move data from there for better response time.