Thursday, November 26, 2009

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