Jump to content


Houdini + Arduino + Robotic Claw


  • Please log in to reply
21 replies to this topic

#1 GallenWolf

GallenWolf

    Illusionist

  • Members
  • PipPipPip
  • 326 posts
  • Joined: 25-November 06
  • Location:Montreal, Canada
  • Name:Alvin Yap

Posted 26 March 2011 - 09:57 AM



Hello fellow Houdniks! I have been remiss in attending this forum, but here's my latest houdini-related thingy. Controlling a 2 dof robotic arm.

Notes:
- OTL included will give a python error if there is no serial device on /dev/ttyACM0 - please note that I am running Linux, so I have no idea what this will be like on Windows.
- I'm using __main__ to store global variables. I am not sure if this is the correct way to do it, and would love the python gurus out there to comment on it.
- I have included awesome* diagrams of my state transition diagram and how the arduino is wired to the servos
- The Arduino .C code is included, just rename it to .pde for use with the UI.

Special thanks to Graham Thompson for helping out with the callback functions. I won't have known those existed!!!

Regards,
Alvin

*this is sarcasm.

Attached Files


[ GallenWolf | Alvin | http://www.alvinvfx.com | I like aircraft carriers ]

#2 altbighead

altbighead

    Illusionist

  • Members
  • PipPipPip
  • 398 posts
  • Joined: 16-April 04
  • Location:Vancouver
  • Name:Sai Oo

Posted 26 March 2011 - 02:45 PM

nicely done.love it when i see houdini used in stuff other than effects! B)
FX Artist @ DD
vimeo

#3 ben

ben

    Initiate

  • Members
  • PipPip
  • 132 posts
  • Joined: 18-January 10
  • Location:Ubisoft Paris
  • Name:Benoit Martinez

Posted 27 March 2011 - 04:34 AM

That's really cool !
I've spent my all weekend playing with my arduino board, so thx for that nice and inspiring work.

#4 edward

edward

    Grand Master

  • Members
  • PipPipPipPipPip
  • 3,709 posts
  • Joined: 10-September 02
  • Name:e.d.w.a.r.d. .

Posted 27 March 2011 - 12:32 PM

It needs viewport handles! :)
don't panic!

#5 GallenWolf

GallenWolf

    Illusionist

  • Members
  • PipPipPip
  • 326 posts
  • Joined: 25-November 06
  • Location:Montreal, Canada
  • Name:Alvin Yap

Posted 28 March 2011 - 02:09 AM

It needs viewport handles! :)


They are there! Just didn't use it in the vid :D

GW
[ GallenWolf | Alvin | http://www.alvinvfx.com | I like aircraft carriers ]

#6 chillaxn

chillaxn

    Peon

  • Members
  • Pip
  • 1 posts
  • Joined: 31-March 11
  • Location:Blacksburg
  • Name:David Hasson

Posted 31 March 2011 - 08:39 AM

Found your great video on Makezine today (congrats on that). I've never heard of Houdini, but I was amazed by the video. I just have one question, can the same setup be used to replay a series of claw positions? Rephrased: can you create a rendered animation in Houdini and have each timestep of the servo data sent to the claw in real time? Could it work if it wasn't in real time (I'm thinking maybe a script or really slowed down animation that can just send it frame by frame automagically)?

I'm pretty sure Houdini will be my next software tool to learn because of your video.

Cheers,
Cole

#7 GallenWolf

GallenWolf

    Illusionist

  • Members
  • PipPipPip
  • 326 posts
  • Joined: 25-November 06
  • Location:Montreal, Canada
  • Name:Alvin Yap

Posted 31 March 2011 - 02:07 PM

Found your great video on Makezine today (congrats on that). I've never heard of Houdini, but I was amazed by the video. I just have one question, can the same setup be used to replay a series of claw positions? Rephrased: can you create a rendered animation in Houdini and have each timestep of the servo data sent to the claw in real time? Could it work if it wasn't in real time (I'm thinking maybe a script or really slowed down animation that can just send it frame by frame automagically)?

I'm pretty sure Houdini will be my next software tool to learn because of your video.

Cheers,
Cole


Oh wow, didn't realize it was posted on make! In reply to your question, yes, it is definitely possible, simply by either keyframing the values of the parameters (if you need really detailed control) or some procedural input (noise function, or reaction to something etc), it can put the claw into pre-defined positions.
One thing you may want to consider is servo speed/torque versus the speed of the animation - if it's changing too fast the servo may not be able to keep up. Also, what is "animation" and how heavy is this? Many ways to do it - houdini's not a 3d/effect application - it's a 3d operating system :3 You can definitely create animation of all sorts from characters to collapsing bridges and use that data to drive the arduino, and from there, maybe with a little tinkering, a proton canon. But I digress.

Let me know if I can help further. My next project is using ADXL335 data, however I'm a little stuck at data acquisition - digital filtering, convolution of signals and all that jazz. Houdini is a great package to learn, and the community here is awesome :D

Regards,
Alvin
[ GallenWolf | Alvin | http://www.alvinvfx.com | I like aircraft carriers ]

#8 John Pilgrim

John Pilgrim

    Peon

  • Members
  • Pip
  • 21 posts
  • Joined: 31-January 11
  • Location:San Francisco, CA, USA
  • Name:John Pilgrim

Posted 11 April 2011 - 05:41 PM

Great work Alvin!

I've been working on an motorized remote head for use on a jib crane, that I wanted to be controllable from Houdini via Arduino.

Your OTL and Graham's callback functions are a huge help!

Here's my build journal: http://johnpilgrim.net/MoCo/

I've got the gwServoControlMk2 OTL up and running, and can view the serial stream on an LCD connected to the Arduino.

I have one issue:
Houdini sends serial data to the Arduino when I scrub the values in the parameter pane.
But if I keyframe the same rx2 ry2 rz2 parameters and then play the animation, Houdini doesn't send any serial data.

What other events besides hou.nodeEventType.ParmTupleChanged would need to be included?

Or, better yet, is there a way to simply send the data at every frame?

Thanks for your help on this and for the huge head start with the script,
John


PS: Hou 11.0.636 on Mac OS X 10.5.8

Edited by John Pilgrim, 11 April 2011 - 05:58 PM.


#9 edward

edward

    Grand Master

  • Members
  • PipPipPipPipPip
  • 3,709 posts
  • Joined: 10-September 02
  • Name:e.d.w.a.r.d. .

Posted 11 April 2011 - 08:16 PM

I have one issue:
Houdini sends serial data to the Arduino when I scrub the values in the parameter pane.
But if I keyframe the same rx2 ry2 rz2 parameters and then play the animation, Houdini doesn't send any serial data.

What other events besides hou.nodeEventType.ParmTupleChanged would need to be included?


ParmTupleChanged is only called upon interactive parameter changes. If you want also want to get called when the frame changes, then I recommend using a Python SOP (in a separate displayed Object) instead. As the Python SOP's input, use an Object Merge ("Transform" parameter set to "Into This Object") that merges a dummy Null from inside each of your objects. Now, whenever any of those objects need to cook, your Python SOP should also recook as well. I don't have Houdini in front of me but at worst, you might need to have it generate a single point as I forget whether the viewer will recook SOPs that contain no geometry.
don't panic!

#10 Jason

Jason

    King Tapir

  • Administrators
  • 3,741 posts
  • Joined: 08-November 00
  • Name:Jason Iversen

Posted 12 April 2011 - 10:17 AM

ParmTupleChanged is only called upon interactive parameter changes. If you want also want to get called when the frame changes, then I recommend using a Python SOP (in a separate displayed Object) instead. As the Python SOP's input, use an Object Merge ("Transform" parameter set to "Into This Object") that merges a dummy Null from inside each of your objects. Now, whenever any of those objects need to cook, your Python SOP should also recook as well. I don't have Houdini in front of me but at worst, you might need to have it generate a single point as I forget whether the viewer will recook SOPs that contain no geometry.


So perhaps he should dump all his parameters onto detail attributes and then the Python SOP's only duty would be to send those to the Arduino?
jason iversen

#11 GallenWolf

GallenWolf

    Illusionist

  • Members
  • PipPipPip
  • 326 posts
  • Joined: 25-November 06
  • Location:Montreal, Canada
  • Name:Alvin Yap

Posted 12 April 2011 - 01:53 PM

*doh* Just tested this, yup doesn't work with keyframes. Edward, Jason, thanks for the hints! I'll see what I can do to make it work for keyframes. I'm thinking maybe putting the serial code data into a function inside the hda, and then when either a python sop updates per frame, or the callback function works, this function can be called to update the servos. I need to test it out, will be slow - it's kinda crunch time where I'm at ;-)

@John: That setup looks amazing. One of my long term hobby goals is camera stabilization - hence my purchase of the 2 dof pan/tilt mechnism :) All the best to your project!

Regards,
Alvin
[ GallenWolf | Alvin | http://www.alvinvfx.com | I like aircraft carriers ]

#12 John Pilgrim

John Pilgrim

    Peon

  • Members
  • Pip
  • 21 posts
  • Joined: 31-January 11
  • Location:San Francisco, CA, USA
  • Name:John Pilgrim

Posted 12 April 2011 - 02:42 PM

Thanks for the input everyone!

I followed Edward's suggestion re Python SOP and Object Merge nodes and then used hou.ch to access the parameter data I wanted to send to the Arduino.

(Jason, could you detail a bit more about how you'd set up the detail attributes.)

The following transmits the data to the Arduino LCD, in an easier to read but bandwidth wasting string format.

# from the Code tab of the Python SOP

import __main__

geo = hou.pwd().geometry()

__main__.ser.write(chr(2)+"frm"+str(int(hou.frame()))+" ry2="+str(round(hou.ch("../../ry2"),3)))

# Note: "../../ry2" resolves to "/obj/gwServoControlMk2/ry2"

Posted Image

I also had to add an On Loaded script to the OTL (with the same content as the On Created) in order to open the serial connection when opening a saved hip file that already contained the OTL.

Note that the Python SOP cooks and sends the data both when playing the animation as well as when dragging the sliders in the param pane, so the ParmTupleChanged callback becomes redundant.

John




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users