Saturday, September 21, 2013

GSoC Experiences(4)

All is well that ends well!
This is the only statement I can express in this last article for the series of articles under GSoC experiences.

I have been able to write a stable Javascript code which is fully functional, and has the basic functionality implemented.

For testing the new code on the grounds, I have ported the script of the PyDy Example Three link pendulum according to the new code.

I still need to write some tutorials on how to use the code, and I will post the relevant links to them, and if possible a simple tutorial on using the code here only.

Anyways I am leaving here a youtube link on the working Animation:
http://www.youtube.com/watch?v=W6MIwXUw7jQ&feature=youtu.be

And here are some screenshots for those who dont like waiting for buffering :)
It feels so exciting to see this work!






GSoC Experiences(3)

This is the third article in the series of articles written on my GSoC experiences, describing some details  on project developments, which I couldn't report due to circumstances.

I will start where I left off. So, I was working on a GUI.
This is what I came up with!



Well Its just a basic GUI with some simple implementation features, i.e. play pause and controls reset.
But it was a good start, and seemed neat.

So after that I had to start working on Javascript class, Canvas class, which was going to handle all the visualization things.
I felt that I did not have enought knowledge on Javascript structure based on Prototypes, So I spent some time knowing about prototypes, and  how to work with them.

I was stuck in more than one places during Javascript source code development phases.
I was stuck with rendering the initial scene, the axes and the grid, and getting them altogether.

Another problem I encountered was with the dreaded "this" keyword in Javascripts.
The problem was that the "Play","Pause" buttons had there OnClick attrubute attached to this.startAnimation, where "this" represented the Canvas class, But the buttons seemed to take this as the default window property of the browser, and gave errors. It took me some time to figure it out and debug them all. What works is instead of using "this.startAnimation", I was supposed to use "Canvas.prototype.startAnimation", hence this is one of the places where prototypes were savior.

Except this, there were some other minor glitches with animations, But thankfully, they were all resolved, and In next and last article of this series of GSoC Experiences, I am going to write about the final outcome of the hardwork, a working example of PyDyViz.



Friday, September 20, 2013

GSoC Experiences(2)

Continuing with my GSoC experiences, this is the second article in the list.

API seemed to be in good shape, I was supposed to start writing tests for javascripts.
The main problem which occured to me was how.
I had spent a few days figuring out exactly what I am supposed to write tests for defining the behaviour of code which will be used in animations, most of which is going to work in runtime(when we are using browser for animations).

I had some discussion with my mentor. He had given me some good motivation as well as ideas on test-writing. But (yes, call me a dumb), I cant still figure out how to do that. I had written some tests myself,
during this time, but I wasn't exactly satisfied with it.

So to keep up with time, I had to switch to writing source code for javascripts.
I was thinking that once I am complete with the source code, I should be more comfortable in writing tests for the same, once it is in working condition.

So with that in mind, I had started writing source code for the Javascripts side.
First thing that crept in my mind before starting was to give a GUI to the project.





GSoC Experiences(1)


Hi All,
I have been unable to contact for a long time. This was mainly because I had ran into some troubles while working on Javascript side, and things were not going smooth. I had to work a lot for getting all in place. I totally apologise for missing all the weekly blog entries, which I should have made.

As a cover up, I am going to share my experiences during that time, for which I missed blog entries,
In the form of GSoC Experiences articles.

So, I was able to finish with the python side by 12th August( a little late then expected).
We had a basic server built in, using WebSockets for transferring content from python to browser.
It was running smooth, and all the tests were passing.

It was decided that we would be using Jasmine for testing javascripts. I had started fleshing out a clean and detailed API on Javascripts side, as well familiarizing with Jasmine and how to write tests on Jasmine.

So we had some API fleshed out, and next I was supposed to write tests for Javascript side.

Monday, August 12, 2013

GSoC report week 7, 8


This is the compiled report for the week 7 and 8.
The stuff is getting quite hectic now.

I have just been able to complete writing a Socket server, which would be used for fetching
simulation data and information to the browser, while calling the display method from
python interpreter.
The server is in very basic form, only accepting requests, and sending the data accordingly.
But it should suffice to complete the python side of things, that is creating the json files, and
creating a basic server, which would be able to serve the required files and data to the browser.


On the other side I have to work on Javascript Tests.
We would be using Jasmine framework for Javascript testing.
As far as Javascript API is concerned, it would be a simple script, containing a single class for
handling the visualizations, Canvas class.

Also I have to figure out some way to make a single javascript module to be used for both IPython
based visualizations and browser based.


GSoC report week 7, 8


This is the compiled report for the week 7 and 8.
The stuff is getting quite hectic now.

I have just been able to complete writing a Socket server, which would be used for fetching
simulation data and information to the browser, while calling the display method from
python interpreter.
The server is in very basic form, only accepting requests, and sending the data accordingly.
But it should suffice to complete the python side of things, that is creating the json files, and
creating a basic server, which would be able to serve the required files and data to the browser.


On the other side I have to work on Javascript Tests.
We would be using Jasmine framework for Javascript testing.
As far as Javascript API is concerned, it would be a simple script, containing a single class for
handling the visualizations, Canvas class.

Also I have to figure out some way to make a single javascript module to be used for both IPython
based visualizations and browser based.


Wednesday, July 31, 2013

GSoC Report : Week 5, 6

The last two weeks have been a little too hectic. I have been working on writing the source code for classes from Python side, and they are nearing the completion.

This is the week for midterm evaluations, and as per the timeline, I was supposed to completely finish the python part by now. Although most of the stuff is complete, I have one or two days work to be left to be done.
I have finished with Shape, and VisualizationFrame classes. Also yesterday I just finished writing complete code for Camera classes.
There were two instances for Camera, one is PerspectiveCamera, and other is Orthographic Camera.

The Camera class is inherited from VisualizationFrame class, which would make it inherit the generation of simulation data. This has very much utility for the fact that we can attach a camera to any moving object in our system, and hence we have  moving cameras, which is an aide for the effective visualizations.

Another approach we have been thinking upon is the possibility of applying multiple cameras to a system, which can effectively be tied upon different moving objects. and they can be switched by a keystroke in the browser.
It would be kinda cool to see an animation from one camera, and then we can switch it to a different camera, in between the animation, without any extra pain, with a keystroke.

Anyways the priority is to get the basic functionality up, and then we can add these and many other features, as time permits.

Another concept which requires a little brainstorming is the Lighting. I am thinking of letting user choose where and what type of lights they want in their system.

These lights can be added in Scene class. and most probably they can also be inherited from VisualizationFrame class, giving them also the capability of motion, rather than static lights.

Tuesday, July 16, 2013

GSoC Report Week 4

Week four is over, and it has been an exhaustive week. I had been working parallely on two instances of project, which are equally relevant.
One is to write a complete extended illustrative example, which involved simulating a three link conical pendulum.
The current work on this problem can be checked here:


The problem is a quick implementation of the whole project, and a very naive one. It has some dirty code, and some hacks, which would need addressing during the implementations in the actual project.

The example is in a stable state, and I have been able to produce static visualizations. With a small change in Javascripts. It can be readily converted to animations.
I have created some instances of classes, according API, with only basic functionality, which has helped in bringing the illustrative example(three link conical pendulum) to life.
The python part of the example is complete, as I have been able to create the JSON file containing the simulation data from the problem.
As far as javascript part is concerned, Only thing left is to animate the visualization by properly reading the simulation data from the JSON object and applying it to the static visualizations.
The simulation data is being stored in the form of a (4 by 4) transformation matrices, which are then mapped to a visualization frame.
the frame will be calling the animation matrices from the javascript side and render them.

There has been certain issues on converting the symbolic transformation matrices to the numpy, or numerical matrices. I tried using lambdify, but ran into some problems.It seems that lambdify doesnt work properly with the time dependent symbols, i.e it works fine on symbols like:
'a', but fails on 'a(t)'.

Right now for the example I am using SymPy's evalf method, with substitutions for the symbols.
But it is not considered as efficient as lambdify, so I need to figure out the way to resolve the problem.

The other part which I am working is to write the unittests for the project. It is getting a bit delayed,
and I am two or three days behind the stipulated timeline. I am hoping to cover it up in the coming two weeks, before the midterm evaluations.
The tests seems to be coming much easier, once I have done the three link pendulum example.
The example has helped me a lot in determining how different classes should be working, so I am a little more confident on the implementations.
It is also because I have already implemented the basic functionality of nearly all classes, I just need to flesh them out, provide some more functionality to them, and they would be ready to be merged into the  master.

In a nutshell, this week has been  a little exhaustive, but now I feel running towards my milestone at a much better pace.

Cheers

Monday, July 8, 2013

GSoC Report Week 3

So, week three has also came to an end.
Main considerations for this week were to write some unit tests, which would be determining the way main coding is to be done.
As per the timeline,  all tests for Python side, should be complete by the coming week, i.e. which has started from today.

As for now, I have almost completed tests for Shape class, and I have written some tests for VisualizationFrame. After that I would focus on tests for Scene class, which would act as a manager class, for holding and manipulating JSON data from the Python side, as well as be able to display output in IPython output cells, as well as fire up a server in case of Python interpreter.

Scene and VisualizationFrame are very important classes for this package. They make up the majority of the API for the visualization implementations.
Also there has been a little confusion on the extent of modularity the package would/should provide.

Hopefully in a few days things would be more clear, so that I would be able to write tests more exhaustively according to the same.

Anyways regarding general stuff, the summer period is amazing, and I am getting good responses from my mentor, and also huge support from the community people. So, it makes things easier to do, when we have so much people to help out there, which is also one of the perks of the open source environment.

Cheers

Tuesday, July 2, 2013

GSoC Report Week 2

So, week two has also ended.

I have found several ideas and new features to implement from various people in the community.
We have finished fleshing out the API, although a few things need to be fleshed out.

As recommended from my mentor, I would be doing test-driven development for the project.

We have discussed the base classes , and the coming two weeks would be dedicated to writing sole tests for the classes, related to python part of the project.
As a part of improvised timeline, we have decided to keep this month of July, for coding the python side of the project, and after midterm evaluations,. I would be working on the Javascripts.

The interaction between the Python and Javascripts would take place with the JSON objects, either written in the form of JSON Objects or as written to files.

This approach would help to provide required level of modularity to the project.
Another major approach to modularity is to make the visualization module(from python side) independent of the mechanics package, i.e. it need not know whether the visualization data comes from sympy.physics.mechanics, or from any other software which could provide the output in the form desired tby the module.
Although the focus is to make the project as mechanics friendly as possible, but still trying to maintain the modularity, and every major API decision is being taken with this point in view.

This week, I will focus on writing some tests, and commit them to the repo.

Cheers






 

Monday, June 24, 2013

GSoC Report Week 1:

 Finally, the much awaited summer coding period has started. I am already feeling very enthusiastic about it.
For the first week, I have been working on an detailed API, alongwith functions(their arguments and return values). Everything is being fleshed out.

Also we(other PyDy members) have been holding discussions on various facets of implementations, how and what would be done for effective visualizations.

An illustrative example has also been made, which utilizes different methods from the new API, to demonstrate the complete workflow.
The illustrative example can be checked here:
https://github.com/PythonDynamics/pydy_examples/pull/11

And the API is in development form and can be checked here:
http://pydy.org/visualization_temp_api

Once the API is in a more finished form it can be ported to a more relevant location(link).
In the coming week I hope to write some functions following the API, and related documentation and tests too.

Cheers,

 







Friday, June 14, 2013

First Step(Summer is Coming!!)

Coding Season is starting from 17 June, and community bonding period has been a good time, to connect with the people from the organization, and some brainstorming sessions on IRC on when and how things should be done.
 Some things have been sort out, and  some remains to be, but hopefully those will be sorted soon too.


Meanwhile I have been able to write a example, in the form of an IPython notebook, which although loosely implemented, describes the workflow we intend to accomplish in this coding season.

The example is based on the simulation of a simple mass spring system.

The workflow comprises of following steps:

1) Defining basic symbols (mass,gravity,stiffness etc.)

 2) Generate a Particle object, using built in mechanics Particle class.(sympy.physics.mechanics.Particle)

3)Define forces on particle.

4)Generate a Kane object for the particle.

5)Utilizing Kane object to generate symbolic equations of motion.

6) Using partially implemented code generation methods to generate numerical solutions to the equation of motion of the particle.

7) Passing the numerical values to the roughly implemented Javascript methods to simulate the motion in the output cell of IPython notebook.


Looks good so far. Feeling excited to start the coding session, writing some codes!! ..




Tuesday, May 28, 2013

Hello World

This is my first attempt to blogging. My blogging career(so as to say) marks with the selection in the Google Summer Of Code 2013, where I would be working in Python Software Foundation.

This blog will serve to provide an insight, and updates related to progress of my project, which would commence on 17th June.

Till then, waiting from my Google T-Shirt ...
Cheers.