Monday, November 30, 2009

Few things in Dojo

I learned few things in DOJO:
1. Dojo.addonload(funcname)
this is similar to window.onload thingy... if we are using addonload thing then we should not use window.onload

2. dojo.query() I am yet to understand the basic flexibility that this provide...
However, it seemed useful while accessing dom element and defining events on them..
something like dojo.query("#idname").connect("onclick", function(){ });

3. Dojo.require is used to load the libraries

4. dojo.byId is similar to document.getHtmlById() or may be similar to document.getNodebyId() of javascript or DHTML

5. Dojo.connet is used for binding event with libraries...

Here is found a really well documented tutorial. I like well documented tutorial because they give a good head start...

http://www.dynamicajax.com/fr/AJAX_Chat_Usability_Additions-271_290_291_297.html
Chatting application in ajax... I should try this some time...

SJ

Saturday, November 28, 2009

Css Style and my lessons

I was playing around with layout, divs and css style properties.
Now it's always difficult to summarize all the experience but i'll try my best
This is what i learned...
1. Css wrapper div should be used to center the whole web site.
Now we should specify some width units and we browser size reduce beyond that value , then horizontal scroll bar will appear.
Also margin for this wrapper should be set to auto so that it'll be centered...
This code piece is used to center the website....

html,body {
height:100%;
margin:0;
padding:0;
text-align: center;
background-color: #999999;
}

#CenterLayout {
width: 1000px; /* set to desired width in px or percent */
height: 100%; /* This made me go nuts because i did not specify this height , Absolute value required here if vertical scrollbar is required below certain value*/
text-align: left; /* optionally you could use "justified" */
border: 0px; /* Changing this value will add lines around the centered area */
padding: 0;
margin: 0 auto;
}

2. Margin auto sets are outer padding values... In case of auto, it tries to place div at equal distance from left and right side div...

3. Float: left to make things left justified... i know this is not perfect... but i'll updated it as i learn more...

4. To put an image in the div and over lap text on it... i wrote this style

#CenterLayout #TitleSection {
position: relative;
top:0%;
left:30px;
width:50%;
height:25%;
// border:5px double #999;
margin:0 auto;
}

#CenterLayout #TitleSection #Title-background {
width:100%;
height:100%;
}

#CenterLayout #TitleSection #TitleContent{
position: absolute;
//margin: 15px 15px 15px 15px; /* No Idea about significance of this */
// border:3px double #777;
padding-bottom: 5px;
bottom: 0px;
left: 0.5em;
width: 90%;
height: 50%;
font-weight: bold;
color: #777;
//font-size: X-large;
font-size: 150%;
overflow: hidden;
text-align: center;
letter-spacing: 8px;
}

Now important point here is positioning attribute.
Position: absolute, place the div at absolute position relative to parent container.. so for this, we need to make sure parent container's width and height property. Also when we specify, absolute position then top, right, left, bottom... some of these properties should be specified properly.

If position is relative then top and left values are relative to self absolute position.


One very important thing to learn about vertical image resizing is:
1. in case of horizontal, screen appear in center and margins are left on both side, this looks ok because things are symmetric and space is filled. Note: here we set height as 100%

2. Now if we re-size the browser vertically then things can go messy, for example: text overflow can occur. To avoid this, we should specify the height dimension also to some value..
suppose u have an image and u position some text on top of it...
by horizontal width property of parent div, scroll-bar will appear and things will not go wrong.
This boils down to two things:
1. If we specify height dimension to some value then on very large browser window, we might see some blank space below the website ...
2. If we do not specify height dimension to 100% value, we need to find some way so that when image is resized while browser resizing then font that is overlapped on the image should also be resized...

Will write later...
SJ

Css layout and positioning

I was again struggling with the css layout of my project page...
Finally by hook and crook , i got something running and this link helped me a lot in the process...

http://www.barelyfitz.com/screencast/html-training/css/positioning/

CSS styling thingy, importance of fixed, relative and absolute positioning..

SJ

Friday, November 27, 2009

Internationalization and charting

I was searching for some java script toolkit which support Internationalization as well as charting support. I searched on internet and found this page...

http://kauriproject.org/wiki/g1/g4/g2/69-kauri.html
This page gives a brief overview of major JavaScript tool-kits in the market.
It covered negatives well but it did not distinguish deeper into their positives.

Finally i decided to go for DOJO toolkit as it is the one which charts as well as i18n support.

SJ

Thursday, November 26, 2009

Java, C++, C and web programming

Nowdays i am coding in so many things that i just mix up things badly.
to overcome this situation, i should take test from time to time..
so here i go for Java:

http://cyber.gwc.cccd.edu/faculty/hcohen/Java5Ch11MCAnswers.txt

SJ

Common mistake while allocating pointers and good programming practice

http://www.eskimo.com/~scs/cclass/int/sx7.html

Malloc may fail so it is always good to check the return value of malloc and then proceed..
One can also write a wrapper function to malloc which return space allocated to void pointer. We just need to type case this to desired data type..

SJ

Wednesday, November 25, 2009

stack vs heap allocation

A very frequent and obvious question to mind...
what are different segments and from where storage is taken to assign space to variables...

Code segment --- compiled code, static link files etc..
Data segment -- stack and heap
stack --> function calls and variables with in function... main is also a function
heap --> static and global variables

Now big question is:
How does memory leak happens...
Suppose i define some variables in a function,
variables allocated memory in stack,
and when function call returns then all that memory is de-allocated..
By de-allocation means top pointer of stack returns to point to callee function.

Now if i do not free that variable space and set the content of memory location to null then that might be disaster because it'll result into memory leak but i dont understand why did memory leak happens... Which variable is holding that memory.. Where the pointer variable allocated memory from

Will freshen up my concept and then updated this stuff...
till then u read this...
http://ee.hawaii.edu/~tep/EE160/Book/chap14/subsection2.1.1.8.html

Recently added features in java

These are some recently added feature in java's new version

Strings in switch is the interesting one....
http://code.joejag.com/2009/new-language-features-in-java-7/

Tuesday, November 24, 2009

css sytle, three column layout and float property

http://webdesign.about.com/od/csstutorials/ss/css_layout_sbs_9.htm

This link is really useful in understanding three column layout but bad thing is that it hard code the div size instead of using %..

Some good tips for newbies...
http://webdesign.about.com/od/layout/a/aa062104.htm


Fixed vs liquid layouts..
http://webdesign.about.com/od/layout/i/aa060506_2.htm

Excellent tutorial on centering a web page layout...
http://blogs.techrepublic.com.com/howdoi/?p=186
http://www.wikihow.com/Center-Web-Page-Content-Using-CSS

One doubt still remains and that is how to get away with fixed width parameter and use percentage in whole of the page...

SJ

Sunday, November 22, 2009

Globbing a directory in perl

To glob a directory is very simple in Perl.
We just have to use these three lines of code...

#!/usr/bin/perl -w

@files =
# FILEPATH can be like *
# for all html files it can be /var/doc/*.html

foreach $filename (@files){
open FILE, "<$filename" or die $!;
# do my 50 things
close FILE
}

Wednesday, November 18, 2009

Bug algorithm on robot... Difficulties on running on actual robot..

It was way more difficult and frustrating then we (Me and Konrad) initially thought.
The major problems and issues that we faced are summarized below:

1. Specifying laser driver in .cfg file

2. Timeout problem .. Laser takes time in starting
red and green light issue

3. Serial port issues...
Identifying which port on serial device.. laser is sending the output

4. Inserting the USB in correct side.. because one USB port is for serial tty/USB0 - tty/USB3 and other is for 4 to 7

5. Robot battery low so some time output is not returned well.. Make sure above 10V

6. Software related measurement issues:
a. Rotating more than desired angle
so for this we had to decrease the turnrate as it was reaching near to desired rotation value... also after it stops rotating we were checking if we need to rotate in opposite direction to get exact rotation...

b. Laser not returning data and some time data is not that accurate...

c. On stage things are simple but pioneer was behaving in lot more erratic way due to extra rotation and movement related problem... we had an accuracy of 66% in our case. when robot follows the wall accurately.

d. Path on stage was way different from actual pioneer because actual pioneer had lot of extra rotation and extra steps kind of problem... on stage it was more smooth path than on actual pioneer... We calibrated lot of variables in movement related to exact positioning and used those error correction parameters in the code...

so for example... while checking slope or distance from a point... we had to use some error value and anything lying between expected output - error value was taken as right value or condition fulfillment


After all this.. our robot does not work correctly in all the scenarios but it executes the wall following well in most of the cases...

Problem was also that there was never enough space to carry out this experiment. even if we take obstacle or wall detection distance to 1.0 meter then robot starting sensing other things because in the path their was alwyas things falling within that space...

If we give less than that then robot some time gets too close to the wall and while rotating and moving further, it collides with the wall..

Will post more difficulties later...

Tuesday, November 17, 2009

Embedding anything into the web site

This seems to be really nice page...
Informative too... read in detail some time...

http://www.labnol.org/internet/how-to-embed-in-html-webpages/6365/

SJ

PHP based login form code and style sheet issues

1. I was trying to setup login mechanism in my PHP based mechanism.
for this, i thought of using direct code from internet.
i found this code snippet to be really straightforward.

http://www.phpeasystep.com/phptu/6.html

2. This took my lot of time. I wanted to stretch my image in such a way that it fits to the window and on resizing, it should not create any issues.

Idea was to create two div and use image tag in one of the div. set the z-index to -1
Do the regular stuff in other div and set z-index as +1. there are few other things like padding and position that we need to take care so for that i copied the code from this site....
http://www.quackit.com/html/codes/html_stretch_background_image.cfm

SJ

Monday, November 16, 2009

php select problem...

First thing...
if sql code is not working then wants to see the output then first go to php directory and from command line say some thing like this:

php.exe

this will through the error and u can fix it accordingly...
if we call from browser then there is no way to find the error message..

second is:
Use "" quotes while forming html string and '' while forming sql string.
i am not sure if this is the rule that should be followed to fix my problem but this is the way it works...

SJ

WAMP setup

For a while i was struggling with wamp setup.
The problem was that PHP-mysql connection was not working properly.

I followed instruction on this page to set things up for me.
http://www.devarticles.com/c/a/Apache/Installing-PHP-under-Windows/5/
http://httpd.apache.org/docs/1.3/windows.html#down
http://forums.mysql.com/read.php?52,69846,69846#msg-69846

The problem was that i had not un-commented php-mysql connection lines in the php.ini file located in apache2.2 folder in program files..

SJ

Sunday, November 15, 2009

CEGUI skinning

I had this problem of not able to align text properly on top of button in vanilla skin of cegui. I decided to switch to taharezlook as it provides more options for windowing as well as text alignment property.

This was seriously tricky. I was in no mood to read that tutorial so just jumped into data files to see what can be done.
CEGUI follows a layering based approach for any widget.
General CEGUI widget looknfeel looks likes this:







.
.


use the properties value


.
more layers
.
.




CEGUI also provides controlProperties which helps in hiding some of imagery section and make other accessible...

By this way, i separated the logic of default image and custom image of button in taharez look and without using imagebutton thingy, i achieved "text on top of image acting as a button" functionality.

Now i am starting with WAMP model.. my first major foray in PHP.. till now i used to work on j2ee....
--Saurabh

Wednesday, November 11, 2009

Internal working of a router

This page explains the internal working of a router...
I remember reading once but was not able to find the page... so here it is..
http://www.erg.abdn.ac.uk/users/gorry/eg3567/inet-pages/router-opn.html

Thoroughly explains the internals...

Sunday, November 8, 2009

Interfaces vs abstarct classes

This page gives a very nice and detailed discussion on interfaces and abstract classes...

http://mindprod.com/jgloss/interfacevsabstract.html

SJ

Friday, November 6, 2009

Color recognition using openCV

Nowdays, i am working on sonar sensors and color detection problem using openCV...
For sonar sensors...
-> In built support for pioneer robots..
-> Problem at corners
-> Range generally 15-20 m
-> Use sound waves

For OpenCV based image capturing and recognition ...
I am still wondering on how to proceed on this... My sub task is to mount camera on robot, take pictures of object, trigger the color detection code and take appropriate action.

Will post more on this as i learn more details...

SJ