Balancing an n-link pendulum with Python

238 views
Skip to first unread message

Jason Moore

unread,
Jan 27, 2013, 8:51:57 PM1/27/13
to sy...@googlegroups.com
Thought you all might like this demo of a fun dynamics and control problem where the equations of motion are generated with the mechanics package in SymPy.

http://www.moorepants.info/blog/npendulum.html

Matthew Rocklin

unread,
Jan 27, 2013, 9:25:53 PM1/27/13
to sy...@googlegroups.com
That's awesome!  The video at the end is particularly impressive. 


On Sun, Jan 27, 2013 at 5:51 PM, Jason Moore <moore...@gmail.com> wrote:
Thought you all might like this demo of a fun dynamics and control problem where the equations of motion are generated with the mechanics package in SymPy.

http://www.moorepants.info/blog/npendulum.html

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to sympy+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Chris Smith

unread,
Jan 28, 2013, 1:49:36 AM1/28/13
to sy...@googlegroups.com
Yes, very cool! I would like to do this as a demo in a physics show
but I'm guessing I will not do as well as the LQR... :-)

Aaron Meurer

unread,
Jan 28, 2013, 2:51:00 AM1/28/13
to sy...@googlegroups.com
Great post. Aside from being open source (free and hackable), I think
we have two main advantages over Wolfram:

- As you mention, the SymPy mechanics module provides a nice
abstraction for doing mechanics. You don't have to remember how to
apply Lagrange's method or whatever. You just set up the particles and
frames of reference, and it figures out the rest.

- The example is much easier to read, especially for someone new to
the respective packages. Mathematica's language is confusing, and if
you don't know what things like @, //, or /. mean, not to mention the
various functions like Join, With, and PadRight, it's hard to
understand what's going on. With Python, the syntax is clearer, and
even someone who doesn't know Python (but does know the mathematical
notation) can guess what things mean (maybe I am biased because I know
Python and I don't know Mathematica).

Aaron Meurer

Jason Moore

unread,
Jan 28, 2013, 2:00:19 PM1/28/13
to sy...@googlegroups.com
I agree with the second statement. Mathematica promotes itself on the shortness of their code: http://blog.wolfram.com/2012/11/14/code-length-measured-in-14-languages/ , but that is a bit of a disadvantage. Having too much syntatic sugar takes away from the easy readability. Python has some advantages in that sense.

Jason
Reply all
Reply to author
Forward
0 new messages