A100222053 5小組會議記錄

Page 1

小組會議記錄 課 程 名 稱 智慧系統設計與應用

授 課 教 師 林金玲

別 第一組

題 E-puck 程式討論

14

Facebook 社團、RC 線上聊天室

101

時 0

4 月 分

13 16

蕭姿俞

日 時

30

出 席 成 員 林書瑄、蕭姿俞、黃懷恩、費宗儒、吳育碩 記

蕭姿俞 內

一、 使用 webots 模擬程式 二、 決定使用於言為 C ,java 使用有問題 三、 工作比例: 1.

蕭姿俞:100%

2.

林書瑄:80%

3.

費宗儒:0% (備註:電腦送修)

4.

黃還恩、吳育碩:0%

四、 理解範例程式,加以修改 1. Include 所需 API #include <webots/robot.h> #include <webots/distance_sensor.h> #include <stdio.h> #include <stdlib.h> #include <webots/servo.h> #include <math.h> #define TIME_STEP 32 #define

SAFE_DISTANCE

200

2. 主程式 int main(int argc, char **argv) { wb_robot_init();

//robot 初始化

wb_robot_init(); int counter_B =0; static WbDeviceTag DS_Left1, DS_Right1, DS_Left2, DS_Right2, DS;

老師


static WbDeviceTag wheel1, wheel2, wheel3, wheel4;

DS_Left1 = wb_robot_get_device("DS_Left1"); wb_distance_sensor_enable(DS_Left1,TIME_STEP);

DS_Left2 = wb_robot_get_device("DS_Left2"); wb_distance_sensor_enable(DS_Left2,TIME_STEP);

DS_Right1 = wb_robot_get_device("DS_Right1"); wb_distance_sensor_enable(DS_Right1,TIME_STEP);

DS_Right2 = wb_robot_get_device("DS_Right2"); wb_distance_sensor_enable(DS_Right2,TIME_STEP);

DS = wb_robot_get_device("DS"); wb_distance_sensor_enable(DS,TIME_STEP);

wheel1 = wb_robot_get_device("Wheel1"); wheel2 = wb_robot_get_device("Wheel2"); wheel3 = wb_robot_get_device("Wheel3"); wheel4 = wb_robot_get_device("Wheel4");

double Wheel1_R=wheel1; double Wheel2_R=wheel2; double Wheel3_R=wheel3; double Wheel4_R=wheel4;

double Max_R=0.15; double Min_R=-0.15; /* main loop */ while(1){ double valueLeft1, valueRight1, valueLeft2, valueRight2, valueDS;

int delay = wb_robot_step(TIME_STEP); if(delay==-1)break;

valueLeft1 =wb_distance_sensor_get_value(DS_Left1); valueLeft2 =wb_distance_sensor_get_value(DS_Left2); valueRight1 =wb_distance_sensor_get_value(DS_Right1); valueRight2 =wb_distance_sensor_get_value(DS_Right2); valueDS =wb_distance_sensor_get_value(DS);


if((Wheel1_R>Max_R)&&(Wheel2_R>Max_R)&&(Wheel3_R>Max_R)&&(Wheel4_R>Max_R)&& (Wheel1_R<Min_R)&&(Wheel2_R<Min_R)&&(Wheel3_R<Min_R)&&(Wheel4_R<Min_R)) { Wheel1_R=0.05; Wheel2_R=0.05; Wheel3_R=0.05; Wheel4_R=0.05; } //前方有障礙 else {

if((valueDS>20)&&(valueLeft1<SAFE_DISTANCE)&&(valueRight1<SAFE_DISTANCE)) { Wheel1_R -= 0.1; Wheel2_R -= 0.1; Wheel3_R -= 0.1; Wheel4_R -= 0.1; wb_servo_set_position(wheel1,Wheel1_R); wb_servo_set_position(wheel2,Wheel2_R); wb_servo_set_position(wheel3,Wheel3_R); wb_servo_set_position(wheel4,Wheel4_R); //右轉 Wheel1_R = 0; Wheel2_R += 0.05; Wheel3_R = 0; Wheel4_R += 0.05; } else if(((valueLeft2<SAFE_DISTANCE)&&(valueRight2<SAFE_DISTANCE))) {//後方障礙,前進 if(counter_B ==0) { Wheel1_R +=0.1; Wheel2_R +=0.1; Wheel3_R +=0.1; Wheel4_R +=0.1; } else {//左轉 Wheel1_R += 0.05; Wheel2_R = 0;


Wheel3_R += 0.05; Wheel4_R = 0; counter_B=0; } counter_B++; } else if(valueLeft1<SAFE_DISTANCE)//右方障礙 { //左轉 Wheel1_R += 0.05; Wheel2_R = 0; Wheel3_R += 0.05; Wheel4_R = 0; } else if(valueRight1<SAFE_DISTANCE)//左方障礙 {//右轉 Wheel1_R = 0; Wheel2_R += 0.05; Wheel3_R = 0; Wheel4_R += 0.05; } else { Wheel1_R += 0.05; Wheel2_R += 0.05; Wheel3_R += 0.05; Wheel4_R += 0.05; } } wb_servo_set_position(wheel1,Wheel1_R); wb_servo_set_position(wheel2,Wheel2_R); wb_servo_set_position(wheel3,Wheel3_R); wb_servo_set_position(wheel4,Wheel4_R);

} wb_robot_cleanup(); return 0; }


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.