Sunteți pe pagina 1din 15

E-Puck Laboratory Report

Paramtap Mewada, Reg. No.: 130109923

Contents
1 2 3 4
Introduction Mini-Project 1 Mini- Project 2

1 2 4 5 6

Drawbacks or Incomplete of current code

5 Appendix

Introduction

Given the specications of the E-Puck robot with eight infrared sensor at orientation of dierent angles
as follows: Sensor Orientations PS0 1.27 PS1 0.77 PS2 0.00 PS3 5.21 PS4 4.21 PS5 PS6 2.37 PS7 1.87 Table 1: Orientations of the E-puck's Proximity Sensors
from the calibration test the average of the maximums output of the sensor received through UART1 =(3737+3752+3757)/3=3749. Thus the output of each sensor varies between the 0 3749. from the given data maximum speed of each motor varies from 1000 to 1000. To track the direction of the v with speed of left and right wheel proportional to the closeness of

the the predator or object is given by following:


Sl Sr =

1 1 1 1

vx vy

(1.1)

This modelling works because of the fact that the force resolved into two components and concepts of the moment about the point(in this case center of E-Puck). As the speed of wheel will be set according the linear equation (0.1) as per the Varignon's Theorem the robot will experience moent that will orient the E-Puck in the direction of sensed predotor??. Should this forces be applied in the negative manner the moments will be applied in the opposite direction which will be demonstrated in the Mini-Project 1 32them E-Puck controller instead of showing 'following' obstacle will start running away from the predator or obstacle. Just like reversing the electromagnetic charge between two atoms instead of attracting, two will be repelling each other. According to the specication ,it is considered that output of each sensor detects the presence, proximity and orientation of the obstacles. 1. Presence: It is detected by the sensor output, if P Sn > 0,where n=0,...,7; then there is obstacle or predator present. 2. Proximity: It is given by the magnitude of the P Sn, where n=0,...,7. Eg: If the one reading is 10, and another reading is 100, then 100 is more closer to E-Puck than at the 10. 3. Orientation: Is given by the combination of the calibration function such that any noisy reading are removed by the calibration, then taking the linear combination of the sensor reading gives the correct orientation when divided into the vector form .
Sl Sr = 1 1 1 1 Vx Vy

e.g. P S 0 detects the predator, then P S 1 to P S 7 reading would you be zero(ideally) or will be calibrated to zero by the calling the function e_calibrate_ir( ), then all terms from the (vx1, .., vx7) = 0 ,and vx0, vy 0 = 0.
1
Universal Asynchronous Receiver-Transmitter

Thus calculating the vector of : V X0 =magnitude of proximity sensor '0'cos(0.00) , V Y0 =magnitude of proximity sensor '0' sin(0.00). Thus speed of the Speed of left and right wheel can be given by, which is done in the following code
Sl Sr = 1 1 1 1 V X0 V Y0

Mini-Project 1

However, there is physical limitations of the motors use i.e. cannot generate innite amount of speed or servo step fails if given signals larger than the its specication, in this case it 1000.
THIS IS GIVEN IN THE PROGRAM BY THE FOLLOWING:

Listing 1: Mini Project 1 prox0 = e_get_calibrated_prox ( 0 ) ; prox1 = e_get_calibrated_prox ( 1 ) ; prox2 = e_get_calibrated_prox ( 2 ) ; prox3 = e_get_calibrated_prox ( 3 ) ; prox4 = e_get_calibrated_prox ( 4 ) ; prox5 = e_get_calibrated_prox ( 5 ) ; prox6 = e_get_calibrated_prox ( 6 ) ; prox7 = e_get_calibrated_prox ( 7 ) ; vx0=prox0 cos ( 1 . 2 7 ) ; vx1=prox1 cos ( 0 . 7 7 ) ; vx2=prox2 cos ( 0 ) ; vx3=prox3 cos ( 5 . 2 1 ) ; vx4=prox4 cos ( 4 . 2 1 ) ; vx5=prox5 cos ( 3 . 1 4 ) ; vx6=prox6 cos ( 2 . 3 7 ) ; vx7=prox7 cos ( 1 . 8 7 ) ; // Linear Combination f o r VX VX=(vx0+vx1+vx2+vx3+vx4+vx5+vx6+vx7 )/max ; vy0=prox0 s i n ( 1 . 2 7 ) ; vy1=prox1 s i n ( 0 . 7 7 ) ; vy2=prox2 s i n ( 0 ) ; vy3=prox3 s i n ( 5 . 2 1 ) ; vy4=prox4 s i n ( 4 . 2 1 ) ; vy5=prox5 s i n ( 3 . 1 4 ) ; vy6=prox6 s i n ( 2 . 3 7 ) ; vy7=prox7 s i n ( 1 . 8 7 ) ; // Linear Combination f o r VY VY=(vy0+vy1+vy2+vy3+vy4+vy5+vy6+vy7 )/max ; //Making s u r e maximum magnitude never goes above 1000 // Reversing Charge Analogy S l =( i n t )( VX VY) ; i f ( Sl >1000) { S l =1000; } Sr=( i n t ) (VX VY) ; i f ( Sr >1000) { Sr =1000; }

My previous methods was write the normalization algorithm and use it set the velocites of the wheels of motor, but as values were being set in the unrounded terms E-Puck traversed more curvy paths then straight lines, the code was as follows : Listing 2: Normalisation Algorithm // Algorithm to n o r m a l i s e the data s e t f o r f i n d i n g // the v e l o c i t i e s // Accepting the c u r r e n t v a l u e s from the s e n s o r VX_temp=(vx0+vx1+vx2+vx3+vx4+vx5+vx6+vx7 ) ; VY_temp=(vy0+vy1+vy2+vy3+vy4+vy5+vy6+vy7 ) ; // Give the minimum c a l i b r a t e d value o f s e n s o r A=0; // Give the maximum c a l i b r a t e d value o f s e n s o r B=3749; // Give the minimum value o f s t e p p e r input s i g n a l a= 1000; // Give the maximum value o f s t e e p e r input s i g n a l b=1000 //The normalised value VX=a+(VX_tempA) ( ba ) / (BA) ; VY=a+(VY_tempA) ( ba ) / (BA) ;

Mini- Project 2

Task was to device the controller that makes E-Puck Robot Push an obejct. Here there is no determination condition necessary as the objective to push the object around.
CODE THAT DOES THIS TASK IS AS FOLLOWS:

Listing 3: Mini Project 1 prox0 = e_get_calibrated_prox ( 0 ) ; prox1 = e_get_calibrated_prox ( 1 ) ; prox2 = e_get_calibrated_prox ( 2 ) ; prox3 = e_get_calibrated_prox ( 3 ) ; prox4 = e_get_calibrated_prox ( 4 ) ; prox5 = e_get_calibrated_prox ( 5 ) ; prox6 = e_get_calibrated_prox ( 6 ) ; prox7 = e_get_calibrated_prox ( 7 ) ; vx0=prox0 cos ( 1 . 2 7 ) ; vx1=prox1 cos ( 0 . 7 7 ) ; vx2=prox2 cos ( 0 ) ; vx3=prox3 cos ( 5 . 2 1 ) ; vx4=prox4 cos ( 4 . 2 1 ) ; vx5=prox5 cos ( 3 . 1 4 ) ; vx6=prox6 cos ( 2 . 3 7 ) ; vx7=prox7 cos ( 1 . 8 7 ) ; // Linear Combination f o r VX VX=(vx0+vx1+vx2+vx3+vx4+vx5+vx6+vx7 )/max ; vy0=prox0 s i n ( 1 . 2 7 ) ; vy1=prox1 s i n ( 0 . 7 7 ) ; vy2=prox2 s i n ( 0 ) ; vy3=prox3 s i n ( 5 . 2 1 ) ; vy4=prox4 s i n ( 4 . 2 1 ) ; vy5=prox5 s i n ( 3 . 1 4 ) ; vy6=prox6 s i n ( 2 . 3 7 ) ; vy7=prox7 s i n ( 1 . 8 7 ) ; // Linear Combination f o r VY VY=(vy0+vy1+vy2+vy3+vy4+vy5+vy6+vy7 )/max ; //Making s u r e maximum magnitude never goes above 1000 \ l a b e l { r e v e r s e p o t e n t i a l }// Reversing Charge Analogy S l =( i n t )( VX VY) ; i f ( Sl >1000) { S l =1000; } Sr=( i n t ) (VX VY) ; i f ( Sr >1000) { Sr =1000; }

Drawbacks or Incomplete of current code

However there are certain drawbacks of not switching over to another algorithms why the robot is in contact with obstacle that robot will traversed the arcs of the movement.
So to counter this it is suggested (or extended the code ) in following manner:

Listing 4: Mini Project 1 prox0 = e_get_calibrated_prox ( 0 ) ; prox1 = e_get_calibrated_prox ( 1 ) ; prox2 = e_get_calibrated_prox ( 2 ) ; prox3 = e_get_calibrated_prox ( 3 ) ; prox4 = e_get_calibrated_prox ( 4 ) ; prox5 = e_get_calibrated_prox ( 5 ) ; prox6 = e_get_calibrated_prox ( 6 ) ; prox7 = e_get_calibrated_prox ( 7 ) ; vx0=prox0 cos ( 1 . 2 7 ) ; vx1=prox1 cos ( 0 . 7 7 ) ; vx2=prox2 cos ( 0 ) ; vx3=prox3 cos ( 5 . 2 1 ) ; vx4=prox4 cos ( 4 . 2 1 ) ; vx5=prox5 cos ( 3 . 1 4 ) ; vx6=prox6 cos ( 2 . 3 7 ) ; vx7=prox7 cos ( 1 . 8 7 ) ; // Linear Combination f o r VX VX=(vx0+vx1+vx2+vx3+vx4+vx5+vx6+vx7 )/max ; vy0=prox0 s i n ( 1 . 2 7 ) ; vy1=prox1 s i n ( 0 . 7 7 ) ; vy2=prox2 s i n ( 0 ) ; vy3=prox3 s i n ( 5 . 2 1 ) ; vy4=prox4 s i n ( 4 . 2 1 ) ; vy5=prox5 s i n ( 3 . 1 4 ) ; vy6=prox6 s i n ( 2 . 3 7 ) ; vy7=prox7 s i n ( 1 . 8 7 ) ; // Linear Combination f o r VY VY=(vy0+vy1+vy2+vy3+vy4+vy5+vy6+vy7 )/max ; //Making s u r e maximum magnitude never goes above 1000 // Reversing Charge Analogy w h i l e ( prox0 <3500 | | prox1 <3500 | | prox2 <3500 | | prox3 <3500 | | prox4 <3500 | | prox5 <3500 | | prox 6<3500 | | prox7 <3500) { S l =( i n t ) (VX+VY) ; i f ( Sl >1000) { S l =1000; } Sr=( i n t )( VX+VY) ; i f ( Sr >1000) { Sr =1000; } } // w i l l f o l l o w the s t r a i g h t path i f n e a r l y d i f f e r e n c e o f d i s t a n c e i s z e r o w h i l e ( prox0 >3500 | | prox1 >3500 | | prox2 >3500 | | prox3 >3500 | | prox4 >3500 | | prox5 >3500 | | prox 6>3500 | | prox7 >3500) { S l =1000; Sr =1000} 5

Appendix

Listing 5: Mini-project 1 Code // C o n t r o l l e r that l e t s the EPuck evade the Predator #i n c l u d e #i n c l u d e #i n c l u d e #i n c l u d e #i n c l u d e #i n c l u d e #i n c l u d e #i n c l u d e #i n c l u d e #i n c l u d e #i n c l u d e <p30F6014A . h> <motor_led / e_epuck_ports . h> <motor_led / e_init_port . h> <motor_led / advance_one_timer / e_led . h> <motor_led / advance_one_timer /e_motors . h> <motor_led / advance_one_timer /e_agenda . h> <a_d/advance_ad_scan/e_prox . h> <a_d/advance_ad_scan/e_ad_conv . h> <uart / e_uart_char . h> <s t d i o . h> <math . h>

// g l o b a l v a r i a b l e s v o l a t i l e i n t TimerA = 0 ; v o l a t i l e i n t TimerB = 0 ; // f u n c t i o n p r o t o t y p e s int get_selector ( ) ; void dumb_wait ( unsigned i n t approximate_ms ) ; void p r o c e s s _ t i m e r s ( ) ; // main i n t main ( ) { // // VARIABLE DECLARATIONS // // Used to s t o r e the proximity r e a d i n g s i n s t r i n g format , // to be s e n t to the UART. char prox_str [ 1 0 0 ] ; // Used to s t o r e the l e n g t h o f s t r . i n t prox_str_length ; // Used to s t o r e the proximity r e a d i n g s . i n t prox0 , prox1 , prox2 , prox3 , prox4 , prox5 , prox6 , prox7 ; f l o a t vx0 , vx1 , vx2 , vx3 , vx4 , vx5 , vx6 , vx7 , vy0 , vy1 , vy2 , vy3 , vy4 , vy5 , vy6 , vy7 ; f l o a t VX,VY; i n t Sl , Sr ; // Here the max f u n c t i o n ensure that the speed i s normalised with range // o f 1000 to 1000 f l o a t max=3749/1000;

// // INITIALIZATION // 6

// I n i t i a l i z i n g the motor e_init_motors ( ) ; // i n t motor_speed =500; // I n i t i a l i z e s the p o r t s . e_init_port ( ) ; // I n i t i a l i z e s the analogue to d i g i t a l c o n v e r t e r s . e_init_ad_scan (ALL_ADC) ; // I n i t i a l i z e s the UART. e_init_uart1 ( ) ; // Opens a new page on the UART t e r m i n a l . e_send_uart1_char ("\ f \a " , 2 ) ; // This f u n c t i o n must be c a l l e d b e f o r e c a l l i n g // e_get_calibrated_prox ( ) . I t r e c o r d s c o n s t a n t // r e a d i n g e r r o r o f the s e n s o r s , which are then // s u b t r a c t e d from the raw r e a d i n g s to g i v e // c a l i b r a t e d proximity r e a d i n g s . // R e f l e c t e d Light = Total Light Ambient Light Constant Error . e_calibrate_ir ( ) ; e_activate_agenda ( process_timers , 1 0 0 ) ; / / process_timer to be // executed every 10 ms e_start_agendas_processing ( ) ; // // RUNNING LOOP // while (1){ e_set_led ( 0 , 1 ) ; / / turn LED #0 ON // the f o l l o w i n g s t r u c t u r e g i v e s a time delay o f 250 ms u s i n g a // s o f t w a r e timer TimerA = 2 5 ; / / 25 means 250 ms // stuck here u n t i l TimerA i s c l e a r e d by process_timer i n agenda w h i l e ( TimerA >0); e_set_led ( 0 , 0 ) ; / / turn LED #0 OFF TimerA = 2 5 ; w h i l e ( TimerA >0); / When an epuck keeps sending s t r i n g s through UART bus , i t can not be programmed u s i n g Tiny Bootloader . We can use the s e l e c t o r to c o n t r o l whether the epuck i s allowed to send s t r i n g . / i f ( g e t _ s e l e c t o r ()==2){ // Get the r e a d i n g o f proximity s e n s o r s #0. 7

prox0 = e_get_calibrated_prox ( 0 ) ; prox1 = e_get_calibrated_prox ( 1 ) ; prox2 = e_get_calibrated_prox ( 2 ) ; prox3 = e_get_calibrated_prox ( 3 ) ; prox4 = e_get_calibrated_prox ( 4 ) ; prox5 = e_get_calibrated_prox ( 5 ) ; prox6 = e_get_calibrated_prox ( 6 ) ; prox7 = e_get_calibrated_prox ( 7 ) ; vx0=prox0 cos ( 1 . 2 7 ) ; vx1=prox1 cos ( 0 . 7 7 ) ; vx2=prox2 cos ( 0 ) ; vx3=prox3 cos ( 5 . 2 1 ) ; vx4=prox4 cos ( 4 . 2 1 ) ; vx5=prox5 cos ( 3 . 1 4 ) ; vx6=prox6 cos ( 2 . 3 7 ) ; vx7=prox7 cos ( 1 . 8 7 ) ; // Linear Combination f o r VX VX=(vx0+vx1+vx2+vx3+vx4+vx5+vx6+vx7 )/max ; vy0=prox0 s i n ( 1 . 2 7 ) ; vy1=prox1 s i n ( 0 . 7 7 ) ; vy2=prox2 s i n ( 0 ) ; vy3=prox3 s i n ( 5 . 2 1 ) ; vy4=prox4 s i n ( 4 . 2 1 ) ; vy5=prox5 s i n ( 3 . 1 4 ) ; vy6=prox6 s i n ( 2 . 3 7 ) ; vy7=prox7 s i n ( 1 . 8 7 ) ; // Linear Combnation f o r VY VY=(vy0+vy1+vy2+vy3+vy4+vy5+vy6+vy7 )/max ; //Making s u r e maximum magnitude never goes above 1000 S l =( i n t )( VX VY) ; i f ( Sl >1000) { S l =1000; } Sr=( i n t ) (VX VY) ; { } i f ( Sr >1000) Sr =1000; // Put prox i n t o a s t r i n g to send to the UART. prox_str_length = s p r i n t f ( prox_str , "Prox #0: %d,%d \ r \n " , Sr , S l ) ; e_send_uart1_char ( prox_str , prox_str_length ) ; // i n i t i a l motor_speed =500; e_set_speed_left ( S l ) ; // motor speed : from 1000 to 1000 e_set_speed_right ( Sr ) ; // motor speed : from 1000 to 1000 } 8 }

return 0; // motor speeds } / This f u n c t i o n r e t u r n s the s e l e c t o r p o s i t i o n ( ranged from 0 to 1 5 ) . The number p r i n t e d on epuck ' s s e l e c t o r are i n hexadecimal form . So p o s i t i o n 10 i s w r i t t e n as A. / int get_selector (){ r e t u r n SELECTOR0 | ( SELECTOR1< <1)|(SELECTOR2< <2)|(SELECTOR3<<3); } / This f u n c t i o n p r o v i d e s a b a s i c time delay . A f t e r a l l t h i n g s are i n i t i a l i z e d , t h i s f u n c t i o n should be u s e l e s s . / void dumb_wait ( unsigned i n t ms){ int i ; w h i l e (ms){ i = 4996; w h i l e ( i ); } } / This f u n c t i o n handles the s o f t w a r e t i m e r s . I t need to be executed by the agenda system once every 10 ms . / void p r o c e s s _ t i m e r s ( ) { i f ( TimerA>0){ TimerA ; } i f ( TimerB>0){ TimerB ; } }

Listing 6: Mini-Project 2 Code // C o n t r o l l e r that l e t s the EPuck push the o b s t a c l e #i n c l u d e #i n c l u d e #i n c l u d e #i n c l u d e #i n c l u d e #i n c l u d e #i n c l u d e #i n c l u d e #i n c l u d e #i n c l u d e #i n c l u d e <p30F6014A . h> <motor_led / e_epuck_ports . h> <motor_led / e_init_port . h> <motor_led / advance_one_timer / e_led . h> <motor_led / advance_one_timer /e_motors . h> <motor_led / advance_one_timer /e_agenda . h> <a_d/advance_ad_scan/e_prox . h> <a_d/advance_ad_scan/e_ad_conv . h> <uart / e_uart_char . h> <s t d i o . h> <math . h>

// g l o b a l v a r i a b l e s v o l a t i l e i n t TimerA = 0 ; v o l a t i l e i n t TimerB = 0 ; // f u n c t i o n p r o t o t y p e s int get_selector ( ) ; void dumb_wait ( unsigned i n t approximate_ms ) ; void p r o c e s s _ t i m e r s ( ) ; // main i n t main ( ) { // // VARIABLE DECLARATIONS // // Used to s t o r e the proximity r e a d i n g s i n s t r i n g format , // to be s e n t to the UART. char prox_str [ 1 0 0 ] ; // Used to s t o r e the l e n g t h o f s t r . i n t prox_str_length ; // Used to s t o r e the proximity r e a d i n g s . i n t prox0 , prox1 , prox2 , prox3 , prox4 , prox5 , prox6 , prox7 ; f l o a t vx0 , vx1 , vx2 , vx3 , vx4 , vx5 , vx6 , vx7 , vy0 , vy1 , vy2 , vy3 , vy4 , vy5 , vy6 , vy7 ; f l o a t VX,VY; i n t Sl , Sr ; // Here the max f u n c t i o n ensure that the speed i s normalised with range // o f 1000 to 1000 f l o a t max=3749/1000;

// // INITIALIZATION // // I n i t i a l i z i n g the motor 10

e_init_motors ( ) ; // i n t motor_speed =500; // I n i t i a l i z e s the p o r t s . e_init_port ( ) ; // I n i t i a l i z e s the analogue to d i g i t a l c o n v e r t e r s . e_init_ad_scan (ALL_ADC) ; // I n i t i a l i z e s the UART. e_init_uart1 ( ) ; // Opens a new page on the UART t e r m i n a l . e_send_uart1_char ("\ f \a " , 2 ) ; // This f u n c t i o n must be c a l l e d b e f o r e c a l l i n g // e_get_calibrated_prox ( ) . I t r e c o r d s c o n s t a n t // r e a d i n g e r r o r o f the s e n s o r s , which are then // s u b t r a c t e d from the raw r e a d i n g s to g i v e // c a l i b r a t e d proximity r e a d i n g s . // R e f l e c t e d Light = Total Light Ambient Light Constant Error . e_calibrate_ir ( ) ; e_activate_agenda ( process_timers , 1 0 0 ) ; / / process_timer to be // executed every 10 ms e_start_agendas_processing ( ) ;

// // RUNNING LOOP // while (1){ e_set_led ( 0 , 1 ) ; / / turn LED #0 ON // the f o l l o w i n g s t r u c t u r e g i v e s a time delay o f 250 ms u s i n g a // s o f t w a r e timer TimerA = 2 5 ; / / 25 means 250 ms // stuck here u n t i l TimerA i s c l e a r e d by process_timer i n agenda w h i l e ( TimerA >0); e_set_led ( 0 , 0 ) ; / / turn LED #0 OFF TimerA = 2 5 ; w h i l e ( TimerA >0); / When an epuck keeps sending s t r i n g s through UART bus , i t can not be programmed u s i n g Tiny Bootloader . We can use the s e l e c t o r to c o n t r o l whether the epuck i s allowed to send s t r i n g . / i f ( g e t _ s e l e c t o r ()==2){ // Get the r e a d i n g o f proximity s e n s o r s #0. 11

prox0 = e_get_calibrated_prox ( 0 ) ; prox1 = e_get_calibrated_prox ( 1 ) ; prox2 = e_get_calibrated_prox ( 2 ) ; prox3 = e_get_calibrated_prox ( 3 ) ; prox4 = e_get_calibrated_prox ( 4 ) ; prox5 = e_get_calibrated_prox ( 5 ) ; prox6 = e_get_calibrated_prox ( 6 ) ; prox7 = e_get_calibrated_prox ( 7 ) ; vx0=prox0 cos ( 1 . 2 7 ) ; vx1=prox1 cos ( 0 . 7 7 ) ; vx2=prox2 cos ( 0 ) ; vx3=prox3 cos ( 5 . 2 1 ) ; vx4=prox4 cos ( 4 . 2 1 ) ; vx5=prox5 cos ( 3 . 1 4 ) ; vx6=prox6 cos ( 2 . 3 7 ) ; vx7=prox7 cos ( 1 . 8 7 ) ; // Linear Combination f o r VX VX=(vx0+vx1+vx2+vx3+vx4+vx5+vx6+vx7 )/max ; vy0=prox0 s i n ( 1 . 2 7 ) ; vy1=prox1 s i n ( 0 . 7 7 ) ; vy2=prox2 s i n ( 0 ) ; vy3=prox3 s i n ( 5 . 2 1 ) ; vy4=prox4 s i n ( 4 . 2 1 ) ; vy5=prox5 s i n ( 3 . 1 4 ) ; vy6=prox6 s i n ( 2 . 3 7 ) ; vy7=prox7 s i n ( 1 . 8 7 ) ; // Linear Combnation f o r VY VY=(vy0+vy1+vy2+vy3+vy4+vy5+vy6+vy7 )/max ; //Making s u r e maximum magnitude never goes above 1000 S l =( i n t ) (VX+VY) ; i f ( Sl >1000) { S l =1000; } Sr=( i n t )( VX+VY) ; { } i f ( Sr >1000) Sr =1000; // Put prox i n t o a s t r i n g to send to the UART. prox_str_length = s p r i n t f ( prox_str , "Prox #0: %d,%d \ r \n " , Sr , S l ) ; e_send_uart1_char ( prox_str , prox_str_length ) ; // i n i t i a l motor_speed =500; e_set_speed_left ( S l ) ; // motor speed : from 1000 to 1000 e_set_speed_right ( Sr ) ; // motor speed : from 1000 to 1000 } 12 }

return 0; // motor speeds } / This f u n c t i o n r e t u r n s the s e l e c t o r p o s i t i o n ( ranged from 0 to 1 5 ) . The number p r i n t e d on epuck ' s s e l e c t o r are i n hexadecimal form . So p o s i t i o n 10 i s w r i t t e n as A. / int get_selector (){ r e t u r n SELECTOR0 | ( SELECTOR1< <1)|(SELECTOR2< <2)|(SELECTOR3<<3); } / This f u n c t i o n p r o v i d e s a b a s i c time delay . A f t e r a l l t h i n g s are i n i t i a l i z e d , t h i s f u n c t i o n should be u s e l e s s . / void dumb_wait ( unsigned i n t ms){ int i ; w h i l e (ms){ i = 4996; w h i l e ( i ); } } / This f u n c t i o n handles the s o f t w a r e t i m e r s . I t need to be executed by the agenda system once every 10 ms . / void p r o c e s s _ t i m e r s ( ) { i f ( TimerA>0){ TimerA ; } i f ( TimerB>0){ TimerB ; } }

13

S-ar putea să vă placă și