-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Illustrative ex for viz #11
base: master
Are you sure you want to change the base?
Conversation
Added a 3 link pendulum problem, with links as RigidBodies
Changed inertia value
…ples into 3-link-pendulum
point = link.get_masscenter() | ||
forces.append((point, -mass * g * I.y) ) | ||
|
||
kinetic_differentials = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a picky comment, but differentials are different from differential equations. Also are these kinematic or kinetic? The word kinetic is sometimes used to mean "dynamic" (that is, coming from F=ma).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are kinematic equations.
On 6/23/13, Christopher Dembia [email protected] wrote:
+#Applying forces on all particles , and adding all forces in a list..
+forces = []
+for particle in particles:
+
- mass = particle.get_mass()
- point = particle.get_point()
- forces.append((point, -mass * g * I.y) )
+#Applying forces on rigidbodies ..
+for link in links:
- mass = link.get_mass()
- point = link.get_masscenter()
- forces.append((point, -mass * g * I.y) )
+kinetic_differentials = []
This is a picky comment, but differentials are different from differential
equations. Also are these kinematic or kinetic? The word kinetic is
sometimes used to mean "dynamic" (that is, coming from F=ma).
Reply to this email directly or view it on GitHub:
https://github.com/PythonDynamics/pydy_examples/pull/11/files#r4833547
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the correct term is "kinematic differential equations"
Hey Tarun, cool stuff. I made some notes. |
How about changing this example so that it imports the results of your three pendulum example and this would only have the code for the simulation and visualization. Right now you have the same code in both files and have to maintain them both. |
'l3':1.0, 'm1':2, 'm2':2, 'm3':2, \ | ||
'M1':5, 'M1':5, 'M1':5] | ||
|
||
json = frame1.generate_json(initial_conditions, q) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this take the results from odeint + some output equations numerical results and then generate a json file? It doesn't seem like the correct info will be available here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is just a visualization at (well in this case) t=0.
so we know initial-conditions and shapes/objects info at t=0. we can
visualize it.
for animation we would certainly require json generated from this
output + numerical-vals from odeint.
although if we want to implement the visualization at any specific
time other than initial(t=0), then it would certainly require
numerical-vals.
but on the other hand, in future we will allow user to fast fwd
animations to specific time, so it might be deprecated.
On 6/24/13, Jason Moore [email protected] wrote:
+numerical_vals = odeint(right_hand_side, init_conditions, t)
+
+#Now for each t, we have numerical vals of coordinates ..
+#Now we set up a visualization frame,
+
+frame1 = VisualizationFrame('frame1',I , O)
+
+frame1.add_rigidbodies(links)
+
+frame1.add_particles(particles)
+
+param_vals_for_viz = {'g':9.8, 'l1':1.0, 'l2':1.0, \
'l3':1.0, 'm1':2, 'm2':2, 'm3':2, \
'M1':5, 'M1':5, 'M1':5]
+json = frame1.generate_json(initial_conditions, q)
Shouldn't this take the results from odeint + some output equations
numerical results and then generate a json file? It doesn't seem like the
correct info will be available here.
Reply to this email directly or view it on GitHub:
https://github.com/PythonDynamics/pydy_examples/pull/11/files#r4846400
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is any reason to make different things for visualizations at t=t1 versus t=t0 versus t=[1, 2, 3, 4, 5]. You're methods should accept any numerical values of t and output equations (functions of q) to generate the visualization. If you supply values at one instant of time then you get a static visualization, but if you supply lists/arrays then you should be able to play the animation through time. These are not distinct cases (static viz at one config and animations). A static viz is just one frame of the animation.
#also it doesnot check for TypeErrors etc. | ||
|
||
class MeshShape(object): | ||
def __init__(self,name,point_list,color='grey',origin=[0,0,0]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spaces after commas
I know that the essential.py is posted so that the example can work, but I would encourage you to use a more descriptive name in the future. The name |
How come there are 2 |
frame3 = VisualizationFrame('frame3', link3, shape=shape3) | ||
|
||
scene = Scene('scene1',I,O) | ||
scene.vframes = [frame1,frame2,frame3] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better if there was not a setter like this; see other comment.
This has to do with I know I've said it before but I find it unnecessary for the user to make the visualization frames on their own. They could easily just forget to add one of the bodies in their multibody system. I imagine something like this: scene = Scene('scene1', KanesMethod) # assuming Kane's Method knows about inertial frame.
# This will initialize a VisualizationFrame for each rigid body, with names <body_name>
print scene.vframe['link1']
scene.vframe['link1'].shape = shape1
scene.vframe['link2'].shape = shape2
scene.vframe['link3'].shape = shape3 I wish the pydy interface were a little different, so that this would ideally be: sys = System('three_link_pendulum')
sys.add_rigid_body(RigidBody('link1', ...)
sys.add_rigid_body(RigidBody('link2', ...)
sys.add_rigid_body(RigidBody('link3', ...)
km = KanesMethod(sys)
# ...
scene = Scene('scene1', sys)
# as above If we need to, we could resort to: scene = Scene('scene1', body_list)
# as above just as we pass a body list to |
Tarun, Please |
self._transform = Identity(4).as_mutable() | ||
|
||
def transform(self, reference_frame, point): | ||
# TODO : make sure this actually works correctly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote this here because I was having some trouble with evaluating the matrix with lambdify and array arguments. There may be a better way to construct this matrix, but it is probably fine for now.
Remaining items before merge:
|
…ples into illustrative-ex-for-viz
… for the particles.
…y_examples into illustrative-ex-for-viz Conflicts: illustrative_example_for_viz/illustrative_example.py illustrative_example_for_viz/simulate.py
@moorepants It can be merged now .. |
|
||
$ git clone https://github.com/PythonDynamics/pydy-viz | ||
|
||
2) Add the directory to the PYTHONPATH:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to instruct them to actually install it here:
cd pydy-viz
python setup.py install # use sudo if you want system wide install
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do the python path trick addition as an option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be best if you showed how to run each file in this directory indenpendently. You have the derivation file, the simulation, and the visualization.
Ideally the user could type three commands to run things individually:
python derive.py
python simulate.py
python visualize.py
The results of the previous command could be pickled to file so that the subsequent file could load the data. If the data isn't available on disk, then it can run
try:
open('simulate-data.p')
except IOError:
import simulate # runs simulate.py if data doesn't exits
# do the simulation ...
# pickle the results
pickle.dump(simulation_results)
This adds the example problem Tarun developed and used when designing the visualization package. I've updated it to run with the current version of PyDy. The original pull request can be found here: pydy/pydy_examples#11
Added code according to PEP8 conventions