足球机器人实验报告Word版

上传人:W**** 文档编号:179792096 上传时间:2021-04-12 格式:DOC 页数:13 大小:421KB
返回 下载 相关 举报
足球机器人实验报告Word版_第1页
第1页 / 共13页
足球机器人实验报告Word版_第2页
第2页 / 共13页
足球机器人实验报告Word版_第3页
第3页 / 共13页
足球机器人实验报告Word版_第4页
第4页 / 共13页
足球机器人实验报告Word版_第5页
第5页 / 共13页
点击查看更多>>
资源描述

《足球机器人实验报告Word版》由会员分享,可在线阅读,更多相关《足球机器人实验报告Word版(13页珍藏版)》请在金锄头文库上搜索。

1、机器人足球实验报告专 业: 计算机科学与技术 课程名称: 足球机器人理论与实践 指导老师: 刘钊 学 号: 200813137197 学生姓名: 顾伟 1. 实验目的1) 逐步掌握FIRA平台的使用2) 掌握FIRA客户端智能体的编写3) 完成指定的智能体功能与动作2. 程序清单:#ifndef _AFX_NO_DAO_SUPPORT_5V5_PARAMETER#include #define PI 3.14159265typedef struct double x, y,z; Vector3D; typedef struct long left, right, top, bottom; Bo

2、unds;typedef struct Vector3D pos; Ball;typedef struct Vector3D pos;double rotation; OpponentRobot;typedef struct Vector3D pos;double rotation,velocityLeft, velocityRight; Robot;typedef struct Robot home5;OpponentRobot opponent5;Ball currentBall, lastBall, predictedBall;Bounds fieldBound, goalBound;l

3、ong gameState;long whosBall;void *userData; Environment;/基本数据处理函数组double angle(Vector3D p,Vector3D p0); double angle(double x,double y,double x0,double y0); double angle(Vector3D p0,Vector3D p);double dist(double x1,double y1,double x2,double y2);double dist(Vector3D p1,Vector3D p2);double differ_tw

4、o_angle(double a1,double a2);Vector3D turn_blue(Vector3D p);Vector3D turn_yellow(Vector3D p);double turn_blue(double rotate);double turn_yellow(double rotate);/策略函数组void act_v(int no,double vl,double vr,Environment* env);void rotation_to(int po,double rotation,Environment* env);/po号机器人面向rotation角度,基

5、于坐标变换后的角度值void run_to_pos(int po,Vector3D pos,Environment* env);/po号机器人跑到pos位置void run_to_pos2(int po,Vector3D pos,Environment*env);#endif3在stdfx.cpp中添加基础数据处理函数实现过程#include math.hdouble differ_two_angle(double a1,double a2)double a=fabs(a1-a2);if(a180) a=360-a;return a;Vector3D turn_blue(Vector3D p)

6、Vector3D pp;pp.x=p.y-41.8061;pp.y=93.4259-p.x;return pp;Vector3D turn_yellow(Vector3D p)Vector3D pp;pp.x=41.8061-p.y;pp.y=p.x-6.8118;/6.8118Field Left x coordinatereturn pp;double turn_blue(double rotate)if(rotate0) rotate+=360;rotate-=90;if(rotate0) rotate+=360;return rotate;double turn_yellow(doub

7、le rotate)/将系统的角度转换成黄队方坐标的角度if(rotate=360) rotate-=360;/再次矫正角度return rotate;double angle(Vector3D p,Vector3D p0)return(angle(p.x,p.y,p0.x,p0.y);double angle(double x,double y,double x0,double y0) /x,y为目的点,x0,y0为源点/(x,y)(x0,y0)两点连线与x轴的夹角double dx,dy,dr;dx=x-x0;dy=y-y0;dr=dist(x,y,x0,y0);if(dr=0) retu

8、rn(180*acos(dx/dr)/PI); /避免dy很小else return(360-180*acos(dx/dr)/PI);Vector3D sub(Vector3D p1,Vector3D p2)Vector3D p;p.x=p1.x-p2.x;p.y=p1.y-p2.y;return p;Vector3D add(Vector3D p1,Vector3D p2)Vector3D p;p.x=p1.x+p2.x;p.y=p1.y+p2.y;return p;double dist(Vector3D p1,Vector3D p2)return dist(p1.x,p1.y,p2.x,

9、p2.y);double dist(double x1,double y1,double x2,double y2)/(x1,y1) 和(x2,y2)两点间的距离double r;r=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);return(sqrt(r);bool is_in_rect(Bounds bd, Vector3D p)if(p.x=bd.left&p.x=bd.bottom&p.yhome0.pos.x50)Game_Side = RIGHT;else Game_Side = LEFT; if(Game_Side=RIGHT)for(int i=0;ihome

10、i.pos=turn_blue(env-homei.pos);env-homei.rotation=turn_blue(env-homei.rotation);env-opponenti.pos=turn_blue(env-opponenti.pos);env-opponenti.rotation=turn_blue(env-opponenti.rotation);env-currentBall.pos=turn_blue(env-currentBall.pos);else/LEFTfor(int i=0;ihomei.pos=turn_yellow(env-homei.pos);env-ho

11、mei.rotation=turn_yellow(env-homei.rotation);env-opponenti.pos=turn_yellow(env-opponenti.pos);env-opponenti.rotation=turn_yellow(env-opponenti.rotation);env-currentBall.pos=turn_yellow(env-currentBall.pos);/机器人面向到指定角度rotation_to(1,60,env);/转到指定角run_to_pos(2,env-currentBall.pos,env); /追逐球 extern C vo

12、id Destroy ( Environment *env )/策略组函数实现void act_v(int no,double vl,double vr,Environment* env)if(vl125) vl= 125;if(vl125) vr= 125;if(vrhomeno.velocityLeft=vl;env-homeno.velocityRight=vr;void rotation_to(int no,double jiao,Environment* env)/po号机器人面向rotation角度,基于坐标变换后的角度值double vl,vr;int turn_left=jiao-env-homeno.rotationhomeno.rotation;int qujian=0; double r=5.5;double jiaozhen_rot=jiao-env-homeno.rot

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 高等教育 > 专业基础教材

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号