Skip to content
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

Faster animation rendering #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ckchow
Copy link

@ckchow ckchow commented Mar 8, 2015

Switched to using matplotlib's animation module.

@arindam1993
Copy link
Owner

Thanks, that looks great!
However, there's one thing I'm not sure how you're handling i.e making the video and physics have different framerates. In my code the run() function uses a probability trick to skip the required calls to self.loop(). self.fixedLoop() is always called.

I'm not sure how you're handling this, you seem to running both fixedLoop() and loop() inside your tick() method which you pass to FuncAnimation.
This should work fine for a 30fps video, dunno how you are supporting variable framerates.

@ckchow
Copy link
Author

ckchow commented Mar 8, 2015

That's one thing I couldn't figure out how to do. The animator uses some
kind of save fig type scheme internally that I don't think you can skip.

I didn't get around to experimenting with just viewing and not saving the
animation, which might be fast enough to remove the need for multiple frame
rates. Should be a quick test, just have to switch the matplotlib backend
back to an interactive one and use ani.show() instead of ani.save().

On Sunday, March 8, 2015, arindam1993 [email protected] wrote:

Thanks, that looks great!
However, there's one thing I'm not sure how you're handling i.e making the
video and physics have different framerates. In my code the run() function
uses a probability trick to skip the required calls to self.loop(),
self.fixedLoop() is always called.

I'm not sure how you're handling this, you seem to running both
fixedLoop() and loop() inside your tick() method which you pass to
FuncAnimation.
This should work fine for a 30fps video, dunno how you are supporting
variable framerates.


Reply to this email directly or view it on GitHub
#3 (comment).

@SterlingPeet
Copy link
Contributor

@ckchow, is it possible to use the TimedAnimation method at the bottom of this documentation page? Maybe that would help get a variable frame rate (at least the examples seem to imply this).

@ckchow
Copy link
Author

ckchow commented Mar 13, 2015

If you're still interested in frameskipping, I've found a sorta-solution. I just call self.fixedloop() a bunch of times before each render. I can push that change on this branch since it is only a few lines. However, I'm not sure what to do with respect to changing the FPS the renderer wants - if you change the FPS kwarg too much then the video doesn't work.

I'm not sure about TimedAnimation. It looks like internally it expects a streaming event source that it samples from on a timer, and to provide that we would have to make the simulator itself provide frames at a uniform 30fps in realtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants