机器人灭火实验实验实验报告
一、实验目的:
接触比较大规模的编程,激发学习和创新能力。通过灭火的程序对JC 的知识进行全面的巩固,熟练应用各种传感器。
二、实验要求:
要求使用JC 代码编程。
三、实验内容、步骤:
1、机器人巡查火场各个房间,不重复,发现火源,灭火。
2、趋光
3、沿墙走
四、实验代码:
#include "AS_UIII_LIB.h"
int ir_1=0;
void main()
{
// 直走找墙壁并转向让墙壁在左边
drive(5,0);
while(1)
{
if(ir_detector()!=0)
if(ir_detector()!=0)
{
drive(0,2);
while(1) if(ir_detector()==1) if(ir_detector()==1) break; stop();
break;
}
}
//沿墙壁走
drive(2,-2);
while(1)
{
if(ir_detector()==2||ir_detector()==4)
{
drive(0,2);
while(1) if(ir_detector()==0) if(ir_detector()==0) break;
rot_1=rotation(1);
drive(2,0);//go straight
while(rotation(1)-rot_1
if((photo(1)+photo(2))/2
rot_1=rotation(1);
drive(2,2);//turn right
while(rotation(1)-rot_1
stop();
}
drive(2,-2);
}
while(1)
{
if(photo(1)>photo(2))
{
drive(20,20);
wait(0.5);
stop();
}
else
{
drive(20,-20);
wait(0.5);
stop();
}
if((photo(1)+photo(2))/2
}
while(1){Beep();wait(0.5);}
}
五、实验结果:
按下运行按钮之后,机器人先直走一段路程找墙壁,检测到障碍(墙壁)后,机器人原地旋转,使墙壁在机器人的左边,然后开始沿墙走,发现光源后左右前进到光源处报警。
六、实验小结:
通过这次实验,我学会了联合使用光传感器和红外传感器的方法,为进一步学习打下基础。
机器人灭火实验实验实验报告
一、实验目的:
接触比较大规模的编程,激发学习和创新能力。通过灭火的程序对JC 的知识进行全面的巩固,熟练应用各种传感器。
二、实验要求:
要求使用JC 代码编程。
三、实验内容、步骤:
1、机器人巡查火场各个房间,不重复,发现火源,灭火。
2、趋光
3、沿墙走
四、实验代码:
#include "AS_UIII_LIB.h"
int ir_1=0;
void main()
{
// 直走找墙壁并转向让墙壁在左边
drive(5,0);
while(1)
{
if(ir_detector()!=0)
if(ir_detector()!=0)
{
drive(0,2);
while(1) if(ir_detector()==1) if(ir_detector()==1) break; stop();
break;
}
}
//沿墙壁走
drive(2,-2);
while(1)
{
if(ir_detector()==2||ir_detector()==4)
{
drive(0,2);
while(1) if(ir_detector()==0) if(ir_detector()==0) break;
rot_1=rotation(1);
drive(2,0);//go straight
while(rotation(1)-rot_1
if((photo(1)+photo(2))/2
rot_1=rotation(1);
drive(2,2);//turn right
while(rotation(1)-rot_1
stop();
}
drive(2,-2);
}
while(1)
{
if(photo(1)>photo(2))
{
drive(20,20);
wait(0.5);
stop();
}
else
{
drive(20,-20);
wait(0.5);
stop();
}
if((photo(1)+photo(2))/2
}
while(1){Beep();wait(0.5);}
}
五、实验结果:
按下运行按钮之后,机器人先直走一段路程找墙壁,检测到障碍(墙壁)后,机器人原地旋转,使墙壁在机器人的左边,然后开始沿墙走,发现光源后左右前进到光源处报警。
六、实验小结:
通过这次实验,我学会了联合使用光传感器和红外传感器的方法,为进一步学习打下基础。