Wednesday, April 23, 2014

Initial Proposal

Title

GUI for Adafruid Knitting Machine


Abstract

This project deals with implementation of GUi for Brother KH-930e Knitting Machine, which runs with the help of a FDD emulator.



Content

Name: Pankaj Kumar
Email: pankajxdx@gmail.com
Blog: http://panks.me
Github/Bitbucket/Assembla etc. profile: Github: panks
IRC Nick and Network: panks, freenode
Phone: 91-8939202988
Country/Region: Chennai, India


Who are you? What makes you the best person to work on this project?
I'm currently a 4th year B.tech student at Indian Institute of Technology Madras in Computer Science and Engineering Department. I'm a FOSS enthusiastic and I contribute to opensource projects in my free time.

This projects deal with implementation of GUI, which could be done in Qt (C++ or Python) and I already worked with the Qt framework as few of opensource applications I contributed use the same for their GUI implementation.
Also I have participated in GSoC (2013) and similar programs before too, so this will not be my first time participation.

What free and/or open source projects have you participated in? Please describe your contributions.
digiKam:
Made batch processing of images parallel on a multicore system. Implemented image filter based of image ratio and few more factors. Mentored GSoC project which involved writing plugin to upload images to cloud services like Google drive and Dropbox.
Caligra:
Implemented pdf-filter so that editing of pdf documents can be done inside Caligra Words.

MOOL Project (http://dos.iitm.ac.in/projects/MOOL/):

This project deals with porting the linux kernel to C++, my part was to port the ext4 filesystem to C++.

==================================================


Project Title: GUI for Adafruit Knitting Machine
Possible Mentor:
Benefits to community networks, who would gain from your project?
Not everyone is comfortable using terminal or PCs, so this project will give a easy to use graphical interface for who so ever will be using the knitting machine.

Deliverables: A working GUI for Adafruit knitting machine, exploiting all the feature available by the script.
Project Details:
This project deals with implementation of GUI, for which I plan to use Qt. Which is a a cross-platform application and UI framework. I have experience with both Linux and Mac so I can get the GUI running for both the platforms. I'll be using signals and slots to made different modules interact with each other and to call the Floppy disk emulator and generate pattern scripts.

Implementation:

Classes used:

QMainWindow: This class provides a main application window.
QLabel: This class provides a widget for a text or image display.
QLineEdit: This class provides a widget which is a one-line text editor.
QPushButton: This class provides a widget which is a command button.
QGraphicsView: This class provides a widget for displaying the contents of a QGraphicsScene
QGraphicsScene: This class provides a surface for managing a large number of 2D graphical items.

I have already worked on the UI, the following is the implementation of it:
Main Window which opens when you launch the app.



The label have been implemented using the QLabel Class and button using QButton. On clicking the button it would open the file browser where you can select your file and it'll show the preview of that file the big box below which has been implemented using QGraphicsView.
Alternatively I'll also implement the drag and drop functionality where user can just drag and drop the image into the box to select it.
For implementing drag and drop I'll have to:
- Set acceptsDrop to true for QGraphicView widget
- Implement dragEnterEvent()
- Implement dropEvent()



Once you choose your image it'll show the preview as below:



It'll check the dimensions of the image so that it could be used as an input for number of rows and columns for the knitting machine.
You can press next here to go the next layout.




Here the windows show the size of the image, it's height and width.

To start the emulator you have to press the "Start FDD emulator" button.
I'll the connecting the signal 'buttonClicked' of 'Start FDD emulator' button to a slot 'toggleEmulatorState()' where I'll start the 'PDDemulate-1.0.py' script which will get the floopy drive up and running.
$python PDDemulate-1.0.py img /dev/tty-<>

Along with it, it'll also clear the 'img' directory to receive the new blank pattern from knitting machine, and the window will go the next state.





Here i'm not disabling the 'Start FDD emulator' button instead it changes to 'Stop FDD emulator' and now clicking on it will stop the emulator running in the background. the slot 'toggleEmulatorState()' will respond accordingly to the signal 'buttonClicked'.
'Preview' button and container number inputbox and button both will be disabled at this moment. Now the program is waiting for you to load the blank pattern in to the floppy drive from the knitting machine. As it says 'Backup the data to disk from knitting machine, waiting..'
At this point you can go to your knitting machine and make and empty pattern and make a backup of it to disk.
  • Make your container program, and note down the user generated pattern number (i.e. 901 in the example video).
  • Input the number of stitches which would the width of the image as shown in the window above.
  • Input the number of rows which would be the height of the image.
  • Exit input mode
  • Backup the pattern to disk. Command for which is '552' and then you can select your track number and hit 'step'
After this the files will the generated in the 'img' directory on the disk and the program will recognize it and will move to next state.




Now the program knows that files have been generated and it'll ask for you to input the container number you used on the knitting machine. Input your container number and hit 'OK'.
the slot called on signal 'buttonClicked' of 'OK' button will read the value from the LineEdit box beside the button and will call the next script for pattern generation.

$python insertpattern.py /img/file-01.dat <container-number> <image-file-path> <tmp-file-path>


This will generate the pattern file into a tmp file and the will move to next state.


Now the pattern has been generated in a tmp file, you can view it by clicking on 'Preview Pattern' it'll open a new window show the generator tmp file.
Now the program will call the 'splitfile2track.py' script the split the tmp file generated into two track.

$python splitfile2track.py <tmp-file-path>

it'll split the tmp file into '00.dat' and '01.dat'. and the window will go the next state.



Here it'll just copy the generated '00.dat' and '01.dat' into the 'img' directory, replacing the previously generated files, and windows will go to final and last state.






Now the files with the pattern have been the saved to the floppy drive and you can go ahead start working on the machine:
  • Load the pattern from the disk, command for which is '551'
  • Select the track you gave in the beginning while generating empty pattern.
  • Choose your pattern by container number (i.e. 901)
  • Go ahead and start knitting.

At this point you can stop the emulator and exit the program as it has been already loaded into the machine. Pressing back at this window will take you the preview windows where you can select a different image and start the process all over again.

Few possible changes in the UI:
I was thinking of incorporating the track number too in the UI, if needed. For that I need to talk to someone who have used the machine and be clear on the exact functionality of it.
Apart from that we can also dump the output of the terminal in the program window as show below, but it'll reduce it's simplicity.


I have already started working on the UI part of the project, you can check it at my github: http://github.com/panks/akm


==================================================

Project Schedule - I will be making it for both Linux and OSX so it should take a little more time, but everything including the polishing of code etc shouldn't take more than 2 months.


1 Week: Go through the script and get a better understanding of it, and see if there is anything else I can use to make it simple or is needed to be added to UI.
1 Week: Talk to the mentor and users of the machine and fix on the final design of the UI
1 Weeks: Finish the UI design for Linux.
2 Weeks: Implement all the connection and finish the backend integrating the python scripts with it.
1 Week : Take feedback from the mentor and the users and make any changes if needed.
1 Week : Make the changes to make it up and running on Mac

1 Week: Polish the code and get done with the coding part.
2 Week: Make the package file for Mac(.dmg) and for Linux (at least a .deb for Ubuntu and it's derivatives)
I'm being very conservative in the above time line the actually time taken will be mostly less than this.

Availability - I'll be available for around 30hrs/week.
What other obligations do you have this summer? -  None other, though I might have to visit another city for 4-5 days for a developer meet but nothing apart from that.

==================================================

How do you plan to continue with your project and within the freifunk community after GSoC?
I'll be happy to contribute anytime whenever I'm free even after GSoC. I am a FOSS enthusiastic and this is one thing which I really love.



Comments from Google Melange

Pankaj Kumar March 18, 2014, 12:13 a.m.
Please leave comment if you have any questions for suggestions.

Hello Pankaj, thank you for your proposal. It looks very good. Regarding hardware, do you have access to the necessary hardware to do this project? What hardware do you have, what do you need? What else is required to do this project? Thanks, Mario

Hello Mario, No, I dont have the hardware, but that isn't a very hard requirement for the project. I checked out the video given on the proposal list page and the emulator's code and how and when we are calling which script. So it can be done without me having direct access to the hardware but nevertheless it would be nice if I have contact with someone who has access to the hardware and can finally check my work on it once it's done or even in the middle of project, if needed. So it would really nice if I could get someone's email/contact who has access to the machine during the GSoC project. That's all I would need from your side. Also, I really want to contribute and become a part of FOSSASIA community. I have applied for one more organization this year in GSoC, and in case I get selected for both I would prefer working for FOSSASIA. You can use this information to resolve if there is any conflict. Thanks

Thank you for your answer. Here is a comment from Steve Conklin regarding the workflow: Enough is known now about the data format that it's not required to read an empty pattern from the knitting machine before putting a new pattern into that 'slot'. So the workflow of the proposed application should change. Do you find any info on the net to take advantage of this?

if that is the case then we can make changes in the workflow and simply skip the stage where we are waiting for a backup from the knitting machine, and directly generate all the data files given the image as input and store it in FDD emulator. That won't be a problem. Is there any relevent document which I should follow for the data format? If not that then I can do a research on it before the actually coding period starts, and then go ahead with one of two possible designs.

There is also a comment from Fabienne [http://fabienne.us] regarding this project and we should consider the following: There is the software interface for AYAB, which is admittedly retro, which I like, but they are working to allow for not only two color double bed jacquard work, but also 4 colors and 6 colors per row! http://ayab-knitting.com/ Completely open source, also uses a drop in replacement of the knitting machine's pcb with an arduino and a shield. The hardware is less buggy than knitic in the last release. Both the hardware and the software are open source. They target not only the cheaper KH910, but also the KH930. https://bitbucket.org/chris007de/ayab-apparat/src So in summary, it's a bit of a step back to target the older memory restriction based hack, and not support a hack that has an arduino+shield style of setup. The other reason besides limited memory to move to replace the hardware is that you can add on all sort of things like motor control, yarn knot or no-yarn-left sensors, and perhaps yarn auto feeds or whatever your imagination can fathom. If one stays with the built-in hardware, one is limited to the original functions of the machine, pattern placement on the bed of needles, pattern key for one repeat or more across the bed, color explosion for double bed jacquard with the krc key. This works, but limits you in the geometry of the complexity of the knit projects you can achieve. So, an option would be to target the newer hack of Ayab with the GSoC project. What do you think about this? There is some more info about the software here: https://bitbucket.org/chris007de/ayab-apparat/wiki/Software.wiki

I checked out the AYAB project and I feel it's definitely an improvement over the current method where we load a empty pattern in FDD emulator and do the job. Though there is down side to it that we need additional hardware (Ardunio and shield), but I feel it's worth it as give addition features like wider knitting pattern (upto 200), and they are soon going to support upto 4-6 colors per row. Also inbuilt image processing options with it supports more operations like invert, resize and rotate. I too feel that we should go for implementing a GUI for the scripts given by AYAB.

Hello, I have another question. Next year at the end of March (2015) we will have another FOSSASIA event in Singapore. In the past Google has sponsored GSoC students additionally with 500USD. At this time we do not know, if they have reserved funding for next year. The question is, if you get accepted as a GSoC student would join us at FOSSASIA 2015 and present your project? Would you agree to cover the difference in travel cost or the whole cost (if we do not get additional funding) from your GSoC income? Thanks, Mario


Oh yeah, I would love to. In fact yesterday only I was reading about this year's FOSSASIA meetup in Cambodia. I would be happy to present my project at next year's event, and cover the difference or the full cost(if needed) for my travel and stay. Thanks