Swordrock's Blog

Just another WordPress.com site

Algorithms-2


Algorithms-2

Hi;


Today i am going on algorithms lessons on lots of exercises , more we do practice on algorithms , more we get the knowledge !

ARRAYS

You may need to make some works done more times in a program.We use arrays or loops to do this.The work goes till counter reaches the value we need.

Ex1).:write an algorithm that prints “KEMAL ATATURK” FOR FİVE TİMES!

1.BEGIN

2.i <–0

3.i <–i+1

4.PRINT “KEMAL ATATURK”

5.IF (i<5) GO A3

6.STOP

—-

Ex2).: print the numbers interval 1-10 with algorithms.

1.BEGIN

2.i <–0

3i <–i+1

4.PRINT i

5.IF (i<10) GO A3

6.STOP

—-

Ex3).: find an algorithm that add first 10 number and print the result.(1-10)

1.BEGIN

2.i <–0   T  <–0

3.i <–i+1      T<–i+T

4.IF  (i<10) GO A3

5.PRINT T

6.STOP

—-

Ex4).: add odd numbers from 1 to 10 and print it in algorithm.

1.BEGIN

2.i<–1   T<–1

3.i<–i+2     T<–i+T

4.IF (i<9)  GO A3

5.PRINT T

6.STOP

—–

Ex5).: add even numbers from 1 to 10 and print it in algorithm

1.BEGİN

2.i<–0  T<–0

3.i<–i+2       T<–T+i

4.IF (i<10)  GO A3

5.PRINT T

6.STOP

—–

Ex6).:  find total value and multiplication value of the numbers in 1-120  interval and print it in algorithm

1.BEGIN

2.i<–0  T<–0  M<–1

3.i<–i+1

T<–T+i     M<–i*M

4.IF (i<120) GO A3

5.PRINT T,M

6.STOP

—–

Ex7).:  find average value of odd numbers in the interval 1-10 and print it in algorithm

1.BEGIN

2.i<–1   T<–1  N<–1

3.i<i+1    T<–T+i     N<–N+1

4.IF (i<9)  GO A3

5.A<–T/N

6.PRINT A

7.STOP

—–

Ex8).: find average value of the numbers in the interval 1-13 and print it in algorithm

1.BEGIN

2.i<–0       T<–0       N<–1

3. i<–i+1    T<–i+T    N<–N+1

4.IF  (i<13) GO A3

5.A<–T/N

6.PRINT A

7.STOP

—–

Ex9).: find average value of odd and even numbers in the interval 1-10 and print it in algorithm

(we will use “mode application in math” for this question to make it easy.)

1.BEGIN

2. i<–0  CT<–0 TT<–0  CA<–0  TA<–0

3.i<–i+1

4.IF i MODE 2 =0 CT<–CT+i , CA<–CA+1

IF i MODE 2 =0 TT<–TT+i , TA<–TA+1

5.IF (i<10) GO A4

6. CORT<–CT/CA    TORT<–TT/TA

7.PRINT CORT,TORT

8.STOP

—-

Ex10).: the algorithm to  find the average of the first and the last number of which 99 is entered from the keyboard

1.BEGIN

2.SCAN “ENTER A VALUE”,A

3.i<–1

4.i<–İ+1    SCAN “ENTER A VALUE”,B

5.IF (i<99) GO A4

6.RESULT <–A/B

7.PRINT RESULT

8.STOP

—–

Ex11).:  find algorithm:find the average value of fifth number to eighth number in eight number.

1.BEGIN

2.i<–0

3.i<–i+1

4.SCAN  i “.VALUE”,VALUE

5.IF i=5   A<–VALUE

6.IF (i<8) GO A3

7.AVER<–A/VALUE

8.PRINT AVER

9.STOP

—–

Ex12).: we will enter a value bigger than zero,then we will print them all till we reach our value.find the algorithm

1.BEGİN

2.SCAN “GİVE A VALUE BİGGER THAN ZERO”,A

3.İF (A<0) PRİNT “ERROR” , GO A2

4.PRİNT A

5.A<–A-1

6.PRINT A

7.IF (A<0) GO A5

8.STOP

—–

Ex13).: find the cube of the numbers in the interval 1-50 and find the total value of them and print.

1.BEGIN

2.i<–1   T<–1

3.i<–i+2

4.T<–T+i^3

5.IF (i<49) GO A3

6.PRINT T

7.STOP

——

Ex14).: find square value of  1-n numbers and print the total value of them.

1.BEGIN

2.SCAN “ENTER A VALUE”,N

3.i<–0  T>0

4.i<i+1

5.T <–i^2+T

6.IF (i<N) GO A4

7.PRINT T

8.STOP

That’s all for today,see you !

Eylül 11, 2010 Posted by | C/C++ programming | Yorum bırakın

Robotics-2 Sensors


SENSORS

What the sensor sense ? how it sense it ? how it process it ?  how it uses it ?

# you must consider the task/tasks of robot,the best sensor type to sense it,the best mechanical design that will allow robot to use its sensory information to perform the task

Machine perception

True world –>Sensing device–>Signal processing—>Control system

#Everything that the human sense can do without the handicaps (glasses);

Vision outside the rgb spectrum,active vision (radar and optical range sensor measurement),hearing outside the  20 hz-20 khz  range,chemical analysis beyond the taste and smell,radiation neutron pozitron alfa….

——————————————-

Transduction to Electronics

Thermistor: temperature-to-resistance



Electrochemical: chemistry-to-voltage



Photocurrent: light intensity-to-current



Pyroelectric: thermal radiation-to-voltage



Humidity: humidity-to-capacitance



Length: position-to-inductance



Microphone: sound pressure-to-<anything>


——————————————–

Transduction to vision

Thermometers: temperature-to-length



Barometers:air pressure-to-length



Scales:weight-to-angle



Humidity:hair curl-to-angle



Indicator dyes:chemistry-to-color


Photo film:light/radiation-to-silver density



Speedometers:velocity-to-angle


————————————————————————-

Characterizing the Sensor Performance

i will share some basic knowledge that everyone in robotics will need to understand .


#Sensitivity : Minimum input change to result in output change

#Cross sensitivity : Variation with other changes like temperature

#Error / accuracy : difference between the real value and the generated value

Accuracy=1- (m-v)/v

#Noise : Most sensors generates measurement that are contaminated  by noise

1)systematic noise : errors that could be modelled for example through calibration

2)random noise : errors that can not be predicted .Typically modelled in a probabilistic fashion

Processing Properties


Sensors dont provide states,sensors provide signals,processing converts signals to states;

Processing ;

#Electronics   : measure voltage going through a circuit on a switch

#Signal processing : recognize a voice, separate it from the noise

#Computation : edge detection of objects in an image ,followed by object recognition

Sensor Types and Measurements

1)contact →bump, switch

2)distance →ultrasound, radar, infrared (IR)

3)light level →photo cells, cameras

4)sound—>levelmicrophones

5)strain →strain gauges

6)rotation →encoders

7)magnetism compasses

8)smell →chemical

9)temperature →thermal, infrared

10)inclination →inclinometers, gyroscopes

11)pressure →pressure gauges

12)altitude →altimeters

i finish my lesson with a funny video , have fun 🙂

Eylül 9, 2010 Posted by | Robotic | Yorum bırakın