机器人足球实验报告_第1页
机器人足球实验报告_第2页
机器人足球实验报告_第3页
机器人足球实验报告_第4页
机器人足球实验报告_第5页
已阅读5页,还剩43页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1.课程设计分析1.1课题要求(1)了解5Vs5机器人足球仿真比赛平台及其策略。(2)在C语言编程环境下,完成策略编写和调试。(3)利用所写程序进行足球机器人比赛,并在比赛中完善所写策略。1.2编写目标经过对机器人足球仿真这一课程设计了解,设计,编写和调试,实现足球策略在机器人上优化应用,使己方机器人仿真足球队在比赛中获胜。最终达成能熟练利用C语言程序设计知识处理实际问题,实现详细目标目标,并初步掌握工程化项目化软件开发方法及过程。1.3背景机器人足球如今已为越来越多人所关注。其国际认可比赛按机器人可分为三大类:大中型机器人足球实物组比赛,微型机器人足球实物组比赛,机器人足球仿真组比赛;按数量分可分为:3vs3,5vs5,11vs11等。机器人足球仿真5vs5组比赛是在国际认可同一平台TheRobotSoccerSimulatorDirector8.5上运行各队策略,从而实现比赛目标。而其策略是基于VisualC++编写,只要掌握了C语言课程设计知识就能够实现策略编写。2.用户手册2.1运行环境要求•PentiumIII600MHz•256megabytesofram•TNT23dGraphicsacceleratorwith32megabytesofram•24xCD-ROM•Screenresolutionof800x600•16bitSoundcard•MicrosoftWindows98•DirectX8.0•10megabytesoffreeharddrivespace•Director8.5•VisualC++6.02.2使用方法•将包含源代码工程文件用VisualC++5.0以上版本打开,编译(快捷键F7),链接生成动态链接库。•把生成动态链接库文件复制到C:\Stratege\blue目录下。并更具需要更换文件名称。•打开5Vs5平台程序,将文件名称输入到STRATEGIES目录下Blue栏中,再用鼠标单击Lingo把链接状态更改为C++,然后在点击Send选项。链接文件过程完成。•在右侧工具栏中,点击STARE,开始比赛。•如需深入了解该软件使用方法,单击右下角HELP选项。2.3注意事项•本文中所提供策略程序,只能在蓝队(右队)中使用。3.系统设计3.1程序预期功效实现进攻防守两大功效合理灵活切换;经过实现快速反应,精准定点定向移动,路线优化设计等方法实现高效进攻和防守。3.2功效模块划分4.详细设计及算法4.1进攻详细设计及算法(1)当球在对方半场时为进攻模式1主攻1:当球靠近对方禁区时,在对方球门罚球区守侯,伺机射门;不然辅助助攻球员进攻。主攻2:当球靠近对方禁区时,在对方球门大禁区一侧守侯,伺机射门;不然辅助助攻球员进攻,控球。助攻1:控球,将球带进对方禁区,辅助主攻机器人进攻。助攻2:在助攻1机器人后方适当位置定点,随时接应助攻1机器人。守门员:调整位置到初始位置(2)当球在我方半场且不由对方控球时为进攻模式2主攻1:控球,将球带进对方禁区,辅助主攻机器人进攻。主攻2:在助攻1机器人后方适当位置定点,随时接应助攻1机器人。助攻:准备进入对方半场并寻找有利攻击位置。防守:定位到球与我方球门之间适当位置,随时准备截球。(3)另外一套进攻方案:每个机器人都作为一个独立实体,分别进行判断:机器人1:当球在对方半场大禁区线外时,追球;当球在对方半场大禁区线内上方时,留守下方,准备接反弹出来球;当球在对方半场大禁区线内下方时,留守中间,伺机射门。机器人2:当球在对方半场大禁区上下方时,将球传向门前;当球在对方大禁区和中场线之间时,控球,将球带向球门。机器人3:。一直追球机器人4:当球在对方半场大禁区线外时,追球;当球在对方半场大禁区线内上方时,留守中间,伺机射门;当球在对方半场大禁区线内下方时,留守上方,准备接反弹出来球。4.2防守详细设计及算法当球在我方半场且对方控球时为防守模式主防:定位到球前方截球,使球向对方半场移动。助防:定位到球与球门之间适当位置截球,帮助主防和守门员。后卫1:定位到球门前适当位置做好截球接应准备。后卫2:定位到球门前适当位置做好截球接应准备。守门员:开始就自行运动到如图所表示位置,这么可借助球门柱预防守门员因惯性偏离球门,可大大提升其运动速度,并可降低与其余队员碰撞。不足之处于于因碰撞而姿态改变后调整空间较小。(1)当球在图中所表示阴影内时,守门员Y坐标尽可能与球保持一致,当球坐标在球门范围外时,守门员保持在离球最近位置侯球。(2)当球在图中所表示阴影内时,守门员进入主动防守状态。主动防守状态按球方向和位置不一样分四种状态:(1)球运动方向指向球门,此时守门员应位于球运动方向上,阻截球运动。(2)球运动方向背离球门。此时守门员应位于球与两门柱连线夹角角平分线方向上,为下一次截球作准备。(3)在图示情况下,守门员Y坐标尽可能与球保持一致,当球坐标在球门范围外时保持,球门内时运动。(4)当球在如图虚线内运动时,守门员与球相反运动,以把球撞出.4.3数据结构机器人球员数据(Vector3Dpos表示机器人三维坐标;rotation表示机器人方向;velocityLeft表示机器人左轮速度,velocityRight表示机器人右轮速度;)typedefstruct{Vector3Dpos;doublerotation;doublevelocityLeft,velocityRight;}Robot;对方机器人(组员意义同上)typedefstruct{Vector3Dpos;doublerotation;}OpponentRobot;总环境参量结构(home[PLAYERS_PER_SIDE]表示我方几号机器人;opponent[PLAYERS_PER_SIDE]表示对方几号机器人;currentBall表示当前球位置,lastBall表示上个周期球位置,predictedBall表示下个周期球位置,用来预测球下个周期位置;fieldBounds表示场地边界坐标,goalBounds表示球门边线坐标;gameState表示比赛状态,whosBall表示球掌控状态,*userData预留给用户数据指针)typedefstruct{Robothome[PLAYERS_PER_SIDE];OpponentRobotopponent[PLAYERS_PER_SIDE];BallcurrentBall,lastBall,predictedBall;BoundsfieldBounds,goalBounds;longgameState;longwhosBall;void*userData;}Environment;4.4程序流程4.5函数说明基本动作voidPredictBall(Environment*env);预测球位置,单步预测,利用微量调整。入口参数:环境参量。voidVelocity(Robot*robot,doublevl,doublevr);将响应产生机器人速度写入系统参量中,即引发机器人运动。入口参数:机器人指针,左轮速度,右轮速度。voidAngle1(Robot*robot,intdesired_angle);使机器人转到预定角度。入口参数:机器人指针,预定角度。voidAngleOfPosition(Robot*robot,doublex,doubley);使机器人转某一角度,指向特定点。入口参数:机器人指针,特定点横坐标,特定点纵坐标。以下函数有方向性,基于以上基本动作voidNormalGame_Right(Environment*env);右队总策略。入口参数:环境参量。voidDefender_Right(Environment*env);voidDefend1_Right(Environment*env);voidDefend2_Right(Environment*env);voidDefend_Right_py(Environment*env);右队防守策略。入口参数:球员指针,环境参量。voidDefence1_Right(Robot*robot,Environment*env);右队防守策略。入口参数:球员指针,环境参量。voidGoalKeeper_In_Right(Robot*robot,Environment*env);右队守门员策略。入口参数:球员指针,环境参量。新加入策略voidKick(Environment*env,Robot*robot,doubleaim_angle);基本动作,绕到球后方,带球运动到对方球场。入口参数:环境参量,球员指针,目标角度。voidPosition1_cz(Robot*robot,doublex,doubley);移动到预定点,这是整个程序最主要底层函数基础。入口参数:球员指针,预定点横坐标,预定点纵坐标。voidPosition_py(Robot*robot,doublex,doubley);移动到预定点,无速度衰减。入口参数:球员指针,预定点横坐标,预定点纵坐标。voidAttack_cz1(Robot*robot,Environment*env);voidAttack_hx(Robot*robot,Environment*env);机器人攻击策略。入口参数:球员指针,环境参量。voidShoot_Right_cz(Robot*robot,Environment*env,doubleaimx,doubleaimy);射门函数,这是进攻中最主要底层函数基础,引导机器人相指定点射门。入口参数:球员指针,环境参量,指定点横坐标,指定点纵坐标voidGoalkeeper_right_hx(Robot*robot,Environment*env)依照球运动轨迹,预计球将抵达球门位置,移动到该点截球。入口参数:球员指针,环境参量。voidGoalkeeper_Right_py2(Robot*robot,Environment*env)快速反应,在球运动方向上拦截。入口参数:球员指针,环境参量。5.总结5.1存在不足(1)定位函数在Shoot时,击球定位过程中精度很低,有时会丢球。(2)精准到点位置函数还有待深入改进,现阶段在实现时还有一定误差,有一定振荡现象。(3)守门员角度校正函数还有待改进,现阶段其实现角度校正时不分前后,造成守门员有时遭碰撞后复位前后相反,不能很好防守。5.2我们体会我们程序,建立在稳定、快速底层函数中,而且在强大有效上层策略分配下,结合动态分配角色技术,组织成为一支能与正式比赛队相抗衡仿真机器人足球队。另外,改进了现有定位运动函数,使我方进攻、防守整体性能大幅提升;自行编写射门函数,使机器人具备智能射门攻击能力;采取了动态分配技术,对高效进攻进行了有益尝试;新增了机器人“独立思索-综合攻防”新思绪,为今后高级智能化足球机器人进行了一次超前而且大胆尝试。同时,我们也有一些策略与功效未能付诸实现,如利用一阶微分量来精准控制下车运动没有实现;在动态分配角色时,还只是逐次刷新分配,没有确保角色连续性算法;守门员程序还没有做好精准有效纵向运动专用底层程序。小组在熟悉C++界面、学习现有代码、尝试编写、正式编写、组合调试各个过程中,相互交流、帮助,各自充分发挥自己优点,最终让我们小组在并不很长时间内很好完成了课题任务。我们最大收获还在于,在实际编写中领悟模块化思想,在实际合作中体会编程规范性主要性,由此建立起工程学意识将使我们受益终生。大家在一起这段时间中,团体有机合作让我们在看似繁琐、枯燥过程中不但收获了知识,更收获了愉快。我相信这次课程设计完成并不是终点,而是一个新起点,在这个起点上,我们会愈加努力学习与实践,让自己愈加优异。6.程序代码(只给出部分)//Strategy.cpp:DefinestheentrypointfortheDLLapplication.//#include"stdafx.h"#include"Strategy.h"#include<math.h>#include<windows.h>#definesquare(a)((a)*(a))//求平方#defineleng(a,b,c,d)sqrt(square((a)-(c))+square((b)-(d)))//自定义函数,求两点间距离BOOLAPIENTRYDllMain(HANDLEhModule,DWORDul_reason_for_call,LPVOIDlpReserved ){switch(ul_reason_for_call) { caseDLL_PROCESS_ATTACH: caseDLL_THREAD_ATTACH: caseDLL_THREAD_DETACH: caseDLL_PROCESS_DETACH: break;}returnTRUE;}constdoublePI=3.1415923;charmyMessage[200];//voidPredictBall(Environment*env);voidGoalie1(Robot*robot,Environment*env);voidNearBound2(Robot*robot,doublevl,doublevr,Environment*env);voidAttack2(Robot*robot,Environment*env);voidDefend(Robot*robot,Environment*env,doublelow,doublehigh);//bymoonat9/2/voidMoonAttack(Robot*robot,Environment*env);//justfortestingtocheckwhetherthe&env->opponentworksornotvoidMoonFollowOpponent(Robot*robot,OpponentRobot*opponent);voidVelocity(Robot*robot,intvl,intvr);voidAngle(Robot*robot,intdesired_angle);voidPosition(Robot*robot,doublex,doubley);voidAngle1(Robot*robot,intdesired_angle);voidAngleOfPosition(Robot*robot,doublex,doubley);voidPosition1(Robot*robot,doublex,doubley);boolPosition2(Robot*robot,doublex,doubley);boolGoaliePosition(Robot*robot,doublex,doubley);voidDefence1_Right(Robot*robot,Environment*env);voidDefender_Right(Environment*env);voidDefend1_Right(Environment*env);voidDefend2_Right(Environment*env);voidDefend_Right_py(Environment*env);voidPosition1_cz(Robot*robot,doublex,doubley);voidDefend(Robot*robot,Environment*env,doublelow,doublehigh);voidDefence1_Right(Robot*robot,Environment*env);voidPosition1_cz(Robot*robot,doublex,doubley);voidPosition0_cz(Robot*robot,doublex,doubley);voidGoalKeeper_In_Right(Robot*robot,Environment*env);voidKick(Environment*env,Robot*robot,doubleaim_angle);voidAttack_cz1(Robot*robot,Environment*env,doublex,doubley);voidShoot_Right_cz(Robot*robot,Environment*env);voidAttack1(Robot*robot,Environment*env);voidAttack3(Robot*robot,Environment*env);voidAttack4(Robot*robot,Environment*env);voidshoot(Robot*robot,Environment*env);voidpass(Robot*robot,Environment*env);voidNormalGame_Right_wl(Environment*env);voidGoalkeeper_right_hx(Robot*robot,Environment*env);voidGoalkeeper_Right_py2(Robot*robot,Environment*env);voidKick(Environment*env,Robot*robot,doubleaim_angle);voidDefend1_Right(Environment*env);voidshoot_1(Robot*robot,Environment*env);voidcloseto(Robot*robot,Environment*env);voidKick(Environment*env,Robot*robot,Vector3DToPos);void__cdeclodprintf(constchar*format,...);voidDefence1_Right1(Robot*robot,Environment*env);extern"C"STRATEGY_APIvoidCreate(Environment*env){ //allocateuserdataandassigntoenv->userData //eg.env->userData=(void*)newMyVariables();}extern"C"STRATEGY_APIvoidDestroy(Environment*env){ //freeanyuserdatacreatedinCreate(Environment*) //eg.if(env->userData!=NULL)delete(MyVariables*)env->userData;}extern"C"STRATEGY_APIvoidStrategy(Environment*env){ //thebelowcodesarejustfordemonstrationpurpose....don'ttakethisseriouslyplease. inttestInt=100; intk; switch(env->gameState) { case0: //default MoonFollowOpponent(&env->home[1],&env->opponent[2]); MoonFollowOpponent(&env->home[2],&env->opponent[3]); MoonFollowOpponent(&env->home[3],&env->opponent[4]); Position(&env->home[3],env->currentBall.pos.x,env->currentBall.pos.y); MoonAttack(&env->home[3],env); NormalGame_Right_wl(env); if(env->currentBall.pos.x<20) { Kick(env,&env->home[3],30); } if(env->currentBall.pos.x<21) { shoot(&env->home[1],env); } Position2(&env->home[2],env->currentBall.pos.x,env->currentBall.pos.y); if(env->currentBall.pos.x>79) { Defend1_Right(env); GoalKeeper_In_Right(&env->home[2],env); } if(env->currentBall.pos.x>78) { Defend2_Right(env); Goalkeeper_right_hx(&env->home[3],env); } if(env->home[1].pos.x>env->currentBall.pos.x) {PredictBall(env); Position(&env->home[1],env->predictedBall.pos.x,env->predictedBall.pos.y); }/*Shoot_Right_cz(&env->home[3],env); NormalGame_Right_wl(env); Defence1_Right(&env->home[3],env); Defender_Right(env); Shoot_Right_cz(&env->home[2],env); Attack1(&env->home[1],env); Attack3(&env->home[3],env); Attack4(&env->home[4],env); shoot(&env->home[2],env);pass(&env->home[2],env); Attack2(&env->home[2],env); Position1(&env->home[1],&env->opponent[2].pos.x,&env->opponent[2].pos.y); GoalKeeper_In_Right(&env->home[1],env); Shoot_Right_cz(&env->home[2],env);Kick(env,&env->home[3],180); Defend1_Right(Environment*env); voidDefend2_Right(Environment*env); voidDefend_Right_py(Environment*env);Position1_cz(&env->home[1],env->currentBall.pos.x,env->currentBall.pos.y); if(&env->currentBall.pos.x<20) { shoot(&env->home[2],env); }if(&env->currentBall.pos.x>78) { Position1(&env->home[1],&env->currentBall.pos.x,) } Goalie1(&env->home[0],env); break;*/ caseFREE_BALL: //Followopponentguy MoonFollowOpponent(&env->home[1],&env->opponent[2]); MoonFollowOpponent(&env->home[2],&env->opponent[3]); MoonFollowOpponent(&env->home[3],&env->opponent[4]); //attack MoonAttack(&env->home[3],env); //Goalkeeper Goalie1(&env->home[0],env); //bymoonat24/03/ //belowcodewillnotwork....nevertry.... // env->home[0].pos.x=50; // env->home[0].pos.y=0; // env->home[0].rotation=20.0; break; casePLACE_KICK: MoonAttack(&env->home[2],env); break; casePENALTY_KICK: switch(env->whosBall) { caseANYONES_BALL: MoonAttack(&env->home[1],env); break; caseBLUE_BALL: MoonAttack(&env->home[4],env); break; caseYELLOW_BALL: MoonAttack(&env->home[0],env); break; } break; caseFREE_KICK: FILE*debugfile; debugfile=fopen("debugfile.txt","a"); for(k=0;k<=4;k++) fprintf(debugfile,"robot:%dx:%fy:%fz:%f\n", k,env->opponent[k].pos.x,env->opponent[k].pos.y, env->opponent[k].pos.z); fclose(debugfile); MoonAttack(&env->home[0],env); break; caseGOAL_KICK: // MoonAttack(&env->home[4],env); // Position(&env->home[4],env->currentBall.pos.x,env->currentBall.pos.y); // shoot(&env->home[3],env); Kick(env,&env->home[3],180); break;}}voidcloseto(Robot*robot,Environment*env){}voidavoid(Robot*robot,Environment*env){}voidMoonAttack(Robot*robot,Environment*env){ PredictBall(env); Position(robot,env->predictedBall.pos.x,env->predictedBall.pos.y); }voidMoonFollowOpponent(Robot*robot,OpponentRobot*opponent){ Position(robot,opponent->pos.x,opponent->pos.y);}voidVelocity(Robot*robot,intvl,intvr){ robot->velocityLeft=vl; robot->velocityRight=vr;}voidAngle(Robot*robot,intdesired_angle){ inttheta_e,vl,vr; theta_e=desired_angle-(int)robot->rotation; while(theta_e>180)theta_e-=360; while(theta_e<-180)theta_e+=360; if(theta_e<-90)theta_e+=180; elseif(theta_e>90)theta_e-=180; if(abs(theta_e)>50) { vl=(int)(-9./90.0*(double)theta_e); vr=(int)(9./90.0*(double)theta_e); } elseif(abs(theta_e)>20) { vl=(int)(-11.0/90.0*(double)theta_e); vr=(int)(11.0/90.0*(double)theta_e); } Velocity(robot,vl,vr);}voidAngle1(Robot*robot,intdesired_angle)//让机器人原地旋转到某一角度{ inttheta_e,vl,vr; doubleKp=1.2; theta_e=desired_angle-(int)robot->rotation; while(theta_e>180)theta_e-=360; while(theta_e<-180)theta_e+=360; if(theta_e<-90)theta_e+=180; elseif(theta_e>90)theta_e-=180; vl=(int)(0-Kp*theta_e); vr=(int)(0+Kp*theta_e); Velocity(robot,vl,vr);}voidAngleOfPosition(Robot*robot,doublex,doubley)//让机器人原地旋转一直对着某一点,不分前后{ intvl,vr; doubledx,dy,d_e,desired_angle,theta_e; doubleKp=0.8; dx=x-robot->pos.x; dy=y-robot->pos.y; d_e=sqrt(dx*dx+dy*dy); if(dx==0&&dy==0) { vl=0; vr=0; Velocity(robot,vl,vr); } else desired_angle=(int)(180.0/PI*atan2((double)(dy),(double)(dx))); theta_e=desired_angle-(int)robot->rotation; while(theta_e>180)theta_e-=360; while(theta_e<-180)theta_e+=360; if(theta_e<-90)theta_e+=180; elseif(theta_e>90)theta_e-=180; vl=(int)(0-Kp*theta_e); vr=(int)(0+Kp*theta_e); Velocity(robot,vl,vr);}voidPosition1(Robot*robot,doublex,doubley)//改造原始Position函数,提升直线和转弯速度,提速至125,两方向前进{doublevl,vr,vc=120;doubledesired_angle=0,theta_e=0,d_angle=0;doubledx,dy,d_e,Ka=10.0/90.0;dx=x-robot->pos.x;dy=y-robot->pos.y;d_e=sqrt(dx*dx+dy*dy);if(dx==0&&dy==0)desired_angle=90;elsedesired_angle=(int)(180./PI*atan2((double)(dy),(double)(dx)));theta_e=desired_angle-(int)robot->rotation;while(theta_e>180)theta_e-=360;while(theta_e<-180)theta_e+=360;if(d_e>100.)Ka=1.2;//17./90.;elseif(d_e>50)Ka=0.9;//19./90.;elseif(d_e>30)Ka=0.8;//21./90.;elseif(d_e>20)Ka=0.7;//23./90.;elseKa=0.6;//25./90.;if(theta_e>95||theta_e<-95){theta_e+=180;if(theta_e>180)theta_e-=360;if(theta_e>80)theta_e=80;if(theta_e<-80)theta_e=-80;if(d_e<5.0&&fabs(theta_e)<40)Ka=0.5;//0.1;vr=(int)(-vc*(1.0/(1.0+exp(-3.0*d_e))-0.2)+Ka*theta_e);//距离为零时,速度不为零vl=(int)(-vc*(1.0/(1.0+exp(-3.0*d_e))-0.2)-Ka*theta_e);}elseif(theta_e<85&&theta_e>-85){if(d_e<5.0&&fabs(theta_e)<40)Ka=0.5;//0.1;vr=(int)(vc*(1.0/(1.0+exp(-3.0*d_e))-0.2)+Ka*theta_e);vl=(int)(vc*(1.0/(1.0+exp(-3.0*d_e))-0.2)-Ka*theta_e);}else{vr=(int)(+.8*theta_e);vl=(int)(-.8*theta_e);}if(fabs(vl)>=fabs(vr)){if(vl>0){vl=125;vr=125*vr/vl;}if(vl<0){vl=-125;vr=-125.0*vr/vl;}}if(fabs(vl)<fabs(vr)){if(vr>0){vr=125;vl=125.0*vl/vr;}if(vr<0){vr=-125;vl=-125.0*vl/vr;}}Velocity(robot,vl,vr);}boolPosition2(Robot*robot,doublex,doubley)//将GoaliePosition提速至125,两方向前进{intdesired_angle=0,theta_e=0;doubledx,dy,d_e,Kd,Ka,vl,vr;dx=x-robot->pos.x;dy=y-robot->pos.y;d_e=sqrt(dx*dx+dy*dy);if(dx==0&&dy==0)desired_angle=90;elsedesired_angle=(int)(180./PI*atan2((double)(dy),(double)(dx)));theta_e=desired_angle-(int)robot->rotation;while(theta_e>180)theta_e-=360;while(theta_e<-180)theta_e+=360;Kd=8;//0.85;//ThisistheRobot'soverallspeed.Ka=10./90.;if(d_e<0.1){vl=0;vr=0;Velocity(robot,vl,vr);returnTRUE;}if(d_e>=0.1&&theta_e>-90&&theta_e<90){d_e=sqrt(dx*dx+dy*dy);vr=vl=(int)(d_e*Kd);if(vl>120)vl=120;if(vr>120)vr=120;if(vl<1)vl=1;if(vr<1)vr=1;if(d_e<2||(theta_e>=-20&&theta_e<=20)){if(d_e<1||(theta_e>=-35&&theta_e<=35)){Ka=0.22;}else{Ka=0.32;}}else{Ka=0.35;}vl=(int)(vl-(Ka*theta_e));vr=(int)(vr+(Ka*theta_e));}if(d_e>=0.1&&(theta_e<=-90||theta_e>=90)){d_e=sqrt(dx*dx+dy*dy);vr=vl=(int)(d_e*-Kd);if(vr<-120)vr=-120;if(vl<-120)vl=-120;if(vr>-1)vr=-1;if(vl>-1)vl=-1;if(d_e<2||(theta_e>=-20&&theta_e<=20)){if(d_e<1||(theta_e>=-35&&theta_e<=35)){Ka=0.22;//0.12;}else{Ka=0.32;//0.22;}}else{Ka=0.35;//0.25;}vl=(int)(vl-(Ka*theta_e));vr=(int)(vr+(Ka*theta_e));}if(fabs(vl)>=fabs(vr)){if(vl>0){vl=125;vr=125.0*vr/vl;}if(vl<0){vl=-125;vr=-125.0*vr/vl;}}if(fabs(vl)<fabs(vr)){if(vr>0){vr=125;vl=125.0*vl/vr;}if(vr<0){vr=-125;vl=-125.0*vl/vr;}}Velocity(robot,vl,vr);returnFALSE;}if(env->currentBall.pos.y<=(FTOP+FBOT)/2){if(GoaliePosition(&env->home[flag[3]],FRIGHTX-10,GBOTY))AngleOfPosition(&env->home[flag[3]],env->currentBall.pos.x,env->currentBall.pos.y);if(GoaliePosition(&env->home[flag[4]],FRIGHTX-15,GTOPY+6))AngleOfPosition(&env->home[flag[4]],env->currentBall.pos.x,env->currentBall.pos.y);}else{if(GoaliePosition(&env->home[flag[3]],FRIGHTX-10,GTOPY))AngleOfPosition(&env->home[flag[3]],env->currentBall.pos.x,env->currentBall.pos.y);if(GoaliePosition(&env->home[flag[4]],FRIGHTX-15,GBOTY-6))AngleOfPosition(&env->home[flag[4]],env->currentBall.pos.x,env->currentBall.pos.y);}}voidShoot_Right_cz(Robot*robot,Environment*env)//射门动作,中位线算法{ doublek1,b1,k2,b2,L=2.9,x,y,d_angle,aim_angle,aimx=6.8,aimy=41.8; Ballball=env->predictedBall; OpponentRobotkeeper=env->opponent[0]; if(aimx==ball.pos.x)aim_angle=90; elseaim_angle=a

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论