1 2013/11/29 Project based Learning: Soccer Agent Program
1 2012/12/9 Project based Learning: Soccer Agent Program
PBL Learning by doing
Schedule 1,2 2013 11/29 Make 2013 12/6 2013 12/13 2013 12/20 2014 1/10, 2014 1/24 ( ) 2014 1/31
Schedule 3,4 2013 12/9 Make 2013 12/16 2014 1/6 2014 1/20 2014 1/23, 2014 1/27 ( ) 2014 2/3
RoboCup
RoboCup
2D 1997
....
http://www.er.ams.eng.osaka-u.ac.jp/user/ogino/ ogiwiki/wiki.cgi/lec2009
Example http://www.er.ams.eng.osaka-u.ac.jp/user/ogino/ lecture/pbl2009a/demo.swf RoboCup2012 Mexico City Soccer Simulation 2D League Final Match. HELIOS2011 (Fukuoka University, Osaka Prefecture University, Japan) vs. WrightEagle (University of Science and Technology of China, China) http://www.youtube.com/watch?v=cdhsjsypvde
(Exercises)
An agent is anything that can be viewed as perceiving its environment through sensors and acting upon that environment through effectors. (Russell & Norvig, 1995)
float root(float A, float B, float C) { /* A*x*x + B*x + C = 0 */ float discriminant = B*B - 4*A*C;// if (discriminant < 0) printf("error: discriminant is less than zero."); return (-B + sqrt(discriminant)) / (2*A); }
Programming an agent is different Agent program: Perceive Act Think
int main() { ecobe_init( "testecobe" ); while (ecobe_update()) {... ecobe_flush(); } ecobe_close(); }
UNIX http://www.k-tanaka.net/unix/ http://www.fse.cs.ritsumei.ac.jp/ ~takayuki/unix.html emacs
Unix ( )
Unix )
hellotest emacs hello.c #include <stdio.h> int main(void) { prin9( Hello World ); return 0; }
bin bin hello
Unix
5 which ls ls which hello 6 bin $PATH export PATH=$PATH:~/bin ( ~ 7. echo $PATH which hello hello
Unix
8. hellotest sleeptest.c #include <stdio.h> int main(void) { sleep(10); prin9( Hello World ); return 0; } 9. killall
Exercises 1. agent 2. 3.
1).profile 2 export PATH=$PATH:/home/toyonaka/share/rc/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./ source ~/.profile 2) mkdir ~/.rcssserver cp /home/toyonaka/share/rc/share/server.conf ~/.rcssserver/ 3) rcsoccersim & 4) rcssclient
Exercises 1. first.c agent 2. #include "cinterface.h" int main() { ecobe_init( "happyteam" ); while (ecobe_update()) { ecobe_set_velocity(2,2); ecobe_flush(); } ecobe_close(); } 3. 4.
Makefile It allows creating dependency rules for controlling automatic compilation
Makefile 1- Makefile http://www.er.ams.eng.osaka-u.ac.jp/user/ogino/ lecture/pbl2009a/makefile 2- Makefile 3- first make first CC=gcc LFLAGS=-lpthread DEPS = ecobetrilearn.so %: %.c $(DEPS) $(CC) -o $@ $^ $(LFLAGS)
Vector Arithmetics A/2 Vectors are relative Sum Subtract Scale Unit vector: V / V A 2A unit(a) A+B B A -B for any V, always: unit(v) = 1 A-B
Vector Arithmetics Example 1: can kick if Vrb < dr+db rr Vrb rb
Kicking to goal Task: compute V in the C program Download A A/2 C Vrgl B Vrgr rb D rb = 0.085 rr = 0.3 A= Vrgr - Vrgl Vrb V B= Vrgl + A/2 C= B - Vrb D= unit(c) rr V= Vrb + D
cinterface.h struct strct_vector { float length; float angle; }; struct strct_robot { int id; struct strct_vector position; }; struct strct_goal { struct strct_vector pole1; struct strct_vector pole2; }; int ecobe_init(char *team_name); void ecobe_close(); int ecobe_update(); void ecobe_flush();
cinterface.h /* sum(p1,p2) returns the sum of two given vectors p1 and p2 * */ struct strct_vector ecobe_sum(struct strct_vector p1, struct strct_vector p2); struct strct_vector ecobe_subtract(struct strct_vector p1, struct strct_vector p2); /* scale: * scales a strct_vector by multiplying it's lenght with a float scale value */ struct strct_vector ecobe_scale(struct strct_vector p, float scalar); /* normalize: * normalizes a strct_vector by setting it's lenght to 1 */ struct strct_vector ecobe_unit(struct strct_vector p); /* get_ballpos: * gives you a vector pointing towards the ball */ struct strct_vector ecobe_get_ballpos(); struct strct_goal ecobe_get_leftgoal(); struct strct_goal ecobe_get_rightgoal();
Exercise 1 http://www.er.ams.eng.osaka-u.ac.jp/user/ogino/lecture/pbl2009a/ exercise-1.pdf
Exercise 2, 3