资源描述:
《足球机器人实验报告.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、机器人足球实验报告专业:计算机科学与技术课程名称:足球机器人理论与实践指导老师:刘钊学号:200813137197学生姓名:顾伟-12-1.实验目的1)逐步掌握FIRA平台的使用2)掌握FIRA客户端智能体的编写3)完成指定的智能体功能与动作2.程序清单:#ifndef_AFX_NO_DAO_SUPPORT_5V5_PARAMETER#include#definePI3.14159265typedefstruct{doublex,y,z;}Vector3D;typedefstruct
2、{longleft,right,top,bottom;}Bounds;typedefstruct{Vector3Dpos;}Ball;typedefstruct{Vector3Dpos;doublerotation;}OpponentRobot;typedefstruct{Vector3Dpos;doublerotation,velocityLeft,velocityRight;}Robot;typedefstruct{Robothome[5];OpponentRobotopponent[5];Ba
3、llcurrentBall,lastBall,predictedBall;BoundsfieldBound,goalBound;longgameState;longwhosBall;void*userData;}Environment;//基本数据处理函数组doubleangle(Vector3Dp,Vector3Dp0);doubleangle(doublex,doubley,doublex0,doubley0);doubleangle(Vector3Dp0,Vector3Dp);doubledi
4、st(doublex1,doubley1,doublex2,doubley2);doubledist(Vector3Dp1,Vector3Dp2);doublediffer_two_angle(doublea1,doublea2);Vector3Dturn_blue(Vector3Dp);Vector3Dturn_yellow(Vector3Dp);doubleturn_blue(doublerotate);doubleturn_yellow(doublerotate);//策略函数组voidact
5、_v(intno,doublevl,doublevr,Environment*env);voidrotation_to(intpo,doublerotation,Environment*env);//po号机器人面向rotation角度,基于坐标变换后的角度值voidrun_to_pos(intpo,Vector3Dpos,Environment*env);//po号机器人跑到pos位置voidrun_to_pos2(intpo,Vector3Dpos,Environment*env);#endif
6、3在stdfx.cpp中添加基础数据处理函数实现过程#include"math.h"doublediffer_two_angle(doublea1,doublea2){doublea=fabs(a1-a2);-12-if(a>180)a=360-a;returna;}Vector3Dturn_blue(Vector3Dp){Vector3Dpp;pp.x=p.y-41.8061;pp.y=93.4259-p.x;returnpp;}Vector3Dturn_yellow(Vector3Dp){Vec
7、tor3Dpp;pp.x=41.8061-p.y;pp.y=p.x-6.8118;//6.8118FieldLeftxcoordinatereturnpp;}doubleturn_blue(doublerotate){if(rotate<0)rotate+=360;rotate-=90;if(rotate<0)rotate+=360;returnrotate;}doubleturn_yellow(doublerotate)//将系统的角度转换成黄队方坐标的角度{if(rotate<0)rotate+
8、=360;//矫正角度rotate+=90;if(rotate>=360)rotate-=360;//再次矫正角度returnrotate;}doubleangle(Vector3Dp,Vector3Dp0){return(angle(p.x,p.y,p0.x,p0.y));}doubleangle(doublex,doubley,doublex0,doubley0)//x,y为目的点,x0,y0为源点{//(x,y)(x0,y0)两点连线与x轴的夹角doubledx