《机器人足球实验报告(共15页).doc》由会员分享,可在线阅读,更多相关《机器人足球实验报告(共15页).doc(15页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精选优质文档-倾情为你奉上计 算 机 与 信 息 学 院机器人足球实验报告计算机科学与技术实验一一、实验目的掌握RoboCup仿真机器人足球比赛相关知识点,具体内容如下: (1)Linux操作系统的熟悉及了解其基本操作。(2)掌握Linux下如何进行C+编程,了解gcc编译器以及一些简单编辑工具,如:vi、emacs、gedit、Anjuta、Kdevelope等。(3)启动RoboCup仿真(2D)足球队的比赛。二、实验设备硬件环境:PC机软件环境:操作系统linux三、实验内容(1)掌握 Linux 一些常用的命令a)如何找到用户主目录的绝对路径名?在自己的系统上,用户主目录的绝对路径名是
2、什么? pwd /home/student(2)将当前工作目录从/home/UVA 转到/home/Tsinghua 需要使用什么命令?如何显示当前目录?cd /home/Tsinghua(3)如何在当前目录下建立子目录 RoboCup?mkdir Robcup(4)如何删除子目录 RoboCup?rmdir Robcup(5)如何查看当前目录下的内容?ls(6)如何将文件 start.sh 的权限设定为:start.sh 属于可读、可写、可执行?chmod 777 start.sh(7)如何将当前目录包括所有子目录全部做备份文件,备份文件名为 first.tar?tar xvf dir1 f
3、irst.tar(8)如何将目录/home 下每一个文件压缩成.gz 文件?tar -zcwf store.tar (9)如何把上例中每个压缩的文件解压,并列出详细的信息?tar xvf store.tarLs -lg实验二1、 实验目的(1)了解Demeer5的工作原理(2)学会对Demeer5进行简单的修改二、实验设备硬件环境:PC软件环境:Linux三、实验内容(1)如果可踢球就用最大力踢球 else if( WM-isBallKickable() / 如果球已知,而且当前球在我脚下(可踢) VecPosition pos=( PITCH_LENGTH/2.0,(-1 + 2*(WM-g
4、etCurrentCycle()%2) * 0.4 * SS-getGoalWidth() ); soc=kickTo(pos,SS-getBallSpeedMax(); ACT-putCommandInQueue( soc ); / 放入命令队列 ACT-putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc );(2)如果球不可踢且我是队友中最快到达球的队员,则去截球 else if( WM-getFastestInSetTo( OBJECT_SET_TEAMMATES, OBJECT_BALL, &iTmp ) = WM-getAgen
5、tObjectType() & !WM-isDeadBallThem() )/ 如果球不在我的控制范围下,但是当前能最快抢到球的是我,那我就去执行抢球动作 Log.log( 100, I am fastest to ball; can get there in %d cycles, iTmp ); soc = intercept( false ); ACT-putCommandInQueue( soc ); ACT-putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc );(3)其他情况按战略点跑位else if( posAgent.get
6、DistanceTo(WM-getStrategicPosition() 1.5 + fabs(posAgent.getX()-posBall.getX()/10.0) / 到了这里就是其他距离球相对远一点的人了,如果离自己的阵形点太远,就跑回 自己的阵形点去。 if(WM-getAgentStamina().getStamina()SS-getRecoverDecThr()*SS-getStaminaMax()+800) soc = moveToPos(WM-getStrategicPosition(),PS-getPlayerWhenToTurnAngle(); ACT-putComman
7、dInQueue( soc ); ACT-putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ) ); (4)将球踢向对方球门 else if( WM-isBallKickable() / 如果球已知,而且当前球在我脚下(可踢) VecPosition pos=( PITCH_LENGTH/2.0, (-1 + 2*(WM-getCurrentCycle()%2) * 0.4 * SS-getGoalWidth() ); /得到对方球门的坐标 soc=kickTo(pos,SS-getBallSpeedMax();ACT-putComma
8、ndInQueue( soc ); ACT-putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc );(5)将球踢向距自己最近的球员 else if( WM-isBallKickable() / 如果球已知,而且当前球在我脚下(可踢)VecPosition vec=WM-globalPosition(WM-getClosestInSetTo(OBJECT_SET_TEAMMATES,posAgent); soc=kickTo(vec,2.0);ACT-putCommandInQueue(soc); ACT-putCommandInQueue
9、( turnNeckToObject( OBJECT_BALL, soc );(7)用不同的带球模式带球 dribble(vec,DRIBBLE)分别用DRIBBLE_FAST 快速带球 DRIBBLE_SLOW 慢速带球 DRIBBLE_WITHBALL 安全带球的模式带球(8)向对方球门带球 else if( WM-isBallKickable() AngDeg ang=0.0; soc=dribble(ang,DRIBBLE_FAST);ACT-putCommandInQueue(soc); ACT-putCommandInQueue( turnNeckToObject( OBJECT_
10、BALL, soc );(9)不同的带球组合else if( WM-isBallKickable() if(WM-isInTheirPenaltyArea(WM-getBallPos() VecPosition pos=( PITCH_LENGTH/2.0,(-1 + 2*(WM-getCurrentCycle()%2) * 0.4 * SS-getGoalWidth() ); soc=kickTo(pos,SS-getBallSpeedMax(); else AngDeg ang=0.0;soc=dribble(ang,DRIBBLE_FAST); AngDeg ang=0.0; soc=d
11、ribble(ang,DRIBBLE_FAST); ACT-putCommandInQueue( soc ); / 放入命令队列 ACT-putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ); 实验三一、.实验目的 熟悉demeer5并学会demeer5的基本使用方法,具体内容如下: (1)理解UVA程序的的么而内容 (2)能修改demeer5 (3)能进行底层动作的组合二、实验设备:硬件设备:pc机软件设备:操作系统linux三、实验内容(1)如果在对方禁区内就射门,否则,如果时7、8、9号队友就超前方带球,其他队友传球给9号 els
12、e if( WM-isBallKickable() if(WM-isInTheirPenaltyArea(WM-getBallPos() VecPosition pos=( PITCH_LENGTH/2.0, (-1 + 2*(WM-getCurrentCycle()%2) * 0.4 * SS-getGoalWidth() ); soc=kickTo(pos,SS-getBallSpeedMax(); else if(WM-getAgentObjectType()=OBJECT_TEAMMATE_7|WM- getAgentObjectType()=OBJECT_TEAMMATE_8|WM-
13、getAgentObjectType()=OBJECT_TEAMMATE_9) AngDeg ang=0.0; soc=dribble(ang,DRIBBLE_FAST); else soc=leadingPass(OBJECT_OPPONENT_9,1); AngDeg ang=0.0; soc=dribble(ang,DRIBBLE_FAST); ACT-putCommandInQueue( soc ); ACT-putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ); (2)如果队员的位置在自己半场就向对方球门踢球,否则就向前方带球
14、 else if( WM-isBallKickable()getBallPos().getX()getCurrentCycle()%2) * 0.4 * SS-getGoalWidth() ); soc=kickTo(pos,SS-getBallSpeedMax(); else AngDeg ang=0.0;soc=dribble(ang,DRIBBLE_FAST); AngDeg ang=0.0; soc=dribble(ang,DRIBBLE_FAST); ACT-putCommandInQueue( soc ); ACT-putCommandInQueue( turnNeckToObje
15、ct( OBJECT_BALL, soc ); (3)担忧人来抢球时,就将球传给离自己最近的队友,否则就自己带球 else if( WM-isBallKickable() Circle cir(posAgent,2.5); int num=WM-getNrInSetInCircle(OBJECT_SET_OPPONENTS,cir); if(numgetGlobalPosition(WM-getClosestInSetTo(OBJECT_SET_TEAMMATES,posAgent); soc=kickTo(vec,2.0); else soc=dribble(0.0,DRIBBLE_FAST
16、); ACT-putCommandInQueue( soc ); / 放入命令队列 ACT-putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ); 实验四一、实验目的进一步了解demeer5并能熟悉的修改demeer5的内容以达到对场上的球员的控制(1)能理解UVA程序中原来的demeer中原来的demeer中的全部控制(2)能通过修改demeer5中的具体 函数内容实现对场上球员的控制(3)能通过底层动作的简单组合控制场上队员做出一些复杂动作决策(4)对worldmodel有初步的认识,学会在woeldmodel,basicplaye
17、r里添加新函数二、实验设备硬件环境:PC软件环境:操作系统linux三、实验内容(1)判断守门员的位置,朝门空隙较大的一方射门 else if( WM-isBallKickable() VecPosition vec=WM-getGlobalPosition(WM-getOppGoalieType(); if(vec.getY()0) VecPosition pos=(52.2,-6.5); soc=kickTo(pos,SS-getBallSpeedMax(); else VecPosition pos1=(52.5,6.5);soc=kickTo(pos1,SS-getBallSpeedM
18、ax(); ACT-putCommandInQueue( soc ); ACT-putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc ); (2)在Basicplay力添加一个带球函数,要求如果无人阻挡就向球门带球,否则想办法避开对方球员带球前进 .打开WorldModel.h,在里面预定义函数,即写入bool isOpponentAtAngleEx( AngDeg angA , AngDeg angB ,double dDist );该函数用来判断当前球员角度在angAangB之间距离小于dDist的范围内是否有对方队员.找到并打开Wor
19、ldModel.c在里面填加一个新函数 bool WorldModel:isOpponentAtAngleEx( AngDeg angA , AngDeg angB ,double dDist ) VecPosition posAgent = getAgentGlobalPosition(); VecPosition posOpp; AngDeg angOpp; int iIndex; for( ObjectT o = iterateObjectStart( iIndex, OBJECT_SET_OPPONENTS ); o != OBJECT_ILLEGAL; o = iterateObje
20、ctNext ( iIndex, OBJECT_SET_OPPONENTS ) ) posOpp = getGlobalPosition( o ); angOpp = ( posOpp - posAgent ).getDirection() ; if( angA=angOpp & angOpp =angB & posAgent.getDistanceTo( posOpp ) isBallKickable() Circle cir(posAgent,2.5); int num=WM-getNrInSetInCircle(OBJECT_SET_OPPONENTS,cir); if(numisOpp
21、onentAtAngleEx(ang-45, ang, 6) ) ang+=45; else if ( WM-isOpponentAtAngleEx(ang,ang+45,6) ) ang-=45; SoccerCommand soc = dribble ( ang , DRIBBLE_SLOW); else soc=dribble(0.0,DRIBBLE_FAST); ACT-putCommandInQueue( soc ); ACT-putCommandInQueue( turnNeckToObject( OBJECT_BALL, soc );实验五视觉改变:先在Basicplayer.h
22、中输入 SoccerCommand view (SoccerCommand soc );给 view (SoccerCommand soc )做定义;再在Basicplayer.cpp中view (SoccerCommand soc )函数做定义如下:/*将视觉分成的视觉模式(“1”代表60度,“2”代表120,“3”代表180)*/SoccerCommand BasicPlayer:view(SoccerCommand soc) /7 - 共分成7份 VecPosition posAgent = WM-getAgentGlobalPosition(); AngDeg angBody = WM
23、-getAgentGlobalBodyAngle(); AngDeg angTurn=30; switch( WM-getCurrentCycle()%7 ) case 0: angTurn -= 60; case 1: ACT-putCommandInQueue(SoccerCommand(CMD_CHANGEVIEW, VA_NARROW, VQ_HIGH); ACT-putCommandInQueue(turnNeckToPoint(posAgent+VecPosition( 5, VecPosition:normalizeAngle(angBody+angTurn), POLAR),
24、soc); break; case 2: case 3: ACT-putCommandInQueue(SoccerCommand(CMD_CHANGEVIEW, VA_NORMAL, VQ_HIGH); ACT-putCommandInQueue(turnNeckToPoint(posAgent+VecPosition(5, angBody, POLAR), soc); break; case 4: case 5: case 6: Act-putcommandinqueue(soccercommand(cmd_changeview, va_wide, vq_high); break; defa
25、ult:; 再在playerTeams.cpp球可踢的条件下增加ACT-putCommandInQueue(view(soc);就可看到明显的视觉变化实验六特殊比赛模式的设计模式一:单纯的比赛模式来判断在playertreams.cpp中球可踢情况下加入如下特殊模式 else if ( WM-isBallKickable() if(WM-isKickInUs()/我方界外球 if(WM-getAgentObjectType()=OBJECT_TEAMMATE_11) soc =leadingPass(OBJECT_TEAMMATE_9,2); /传球给9号if(WM-getAgentObjec
26、tType()=OBJECT_TEAMMATE_10) soc=leadingPass(OBJECT_OPPONENT_9,2); /传球给9号if(WM-getAgentObjectType()=OBJECT_TEAMMATE_5)if(WM-getAgentObjectType()=OBJECT_TEAMMATE_4)if(WM-getAgentObjectType()=OBJECT_TEAMMATE_7) else if(WM-isKickInThem()/对方界外球 ObjectT o; ObjectT WorldModel:getSecondClosestInSetTo(Objext
27、SetT objectSet, ObjectT o, double *dDist=NULL, double dConfThr=-1.0);/返回最近对象Dash to向对象进行盯防 else if(WM-isCornerKickUs()/我方角球 ObjectT o;SoccerCommand sctemp;o = WM-getSecondClosestInSetTo(OBJECT_SET_TEAMMATES, OBJECT_BALL);if ( o = WM-getAgentObjectType() )sctemp=ACT-putCommandInQueue(moveToPos(pointT
28、oKickTo(),PS-getPlayerWhenToTurnAngle(); ACT-putCommandInQueue( turnNeckToObject( OBJECT_BALL, sctemp ); else if(WM-isCornerKickThem()/对方角球 ObjectT o; ObjectT WorldModel:getSecondClosestInSetTo(ObjextSetT objectSet, ObjectT o, double *dDist=NULL, double dConfThr=-1.0);/放回最近对象Dash to向对象进行盯防 else if(WM-isFreeKickUs()/我方任意球 else if(WM-isFreeKickThem()/对方任意球 专心-专注-专业