CS344M: Autonomous Multiagent Systems -- Fall 2010:-- -- 3D Programming Assignment 1


3D Programming Assignment 1 - Part 1 for Autonomous Multiagent Systems (cs344M)


 

The following instructions are designed to work once you have logged onto a publinux machine. You can see a list of such machines by doing "cshosts publinux". Currently it is recommended that you work on the lab machines in ENS 1 or ENS 31NR as they are setup with the proper paths and features turned on (specifically direct rendering) to run the 3D simulator smoothly.

If you would like to work remotely and have a slow connection, you should look into installing the RoboCup 3D Soccer Server System on your local machine. We will be using rcssserver3d-0.6.4 and simspark 0.2.1 for this class. Note that if you'd like to install the server on your laptop or home machine, there are links to instructions on how to do this in the middle of the page at http://simspark.sourceforge.net/wiki/index.php/Main_Page .

Get familiar with the 3D soccer simulator

  1. Make sure nobody else is running the simulator on the machine you're on:
    	% ps aux | grep rcss
    
    If someone is on, you will see a line with the word "rcssserver3d" in it. (For future reference, there IS a way to run multiple servers on the same machine.)

  2. If you are not running the server on the local machine, run the following command:
    	% xhost a.cs.utexas.edu 
    	    where 'a' is the name of the machine you are using.
    
  3. In one shell, start the simulator:
            % rcsoccersim3d
    
    If the command rcsoccersim3d cannot be found, make sure that your PATH environment variable is set correctly (see the instructions above). You will likely see a lot of text including error messages being printed out as the simulator starts up but don't worry as you can ignore these.

  4. In another shell, start a player.
    First copy a sample agent to any directory in your account.
            % cp -r /projects/cs344M.pstone/3d/nao-agent .
    
    Then start the agent running
            % cd nao-agent
            % ./agentspark --host=localhost --team myteam --unum 2 --paramsfile paramfiles/defaultParams.txt&
    	[instead of myteam, use your own name]
    
    The agent should appear in the center circle of the field.

  5. Now try changing the viewpoint of the camera in the simulator. The following are controls for the camera:
            left_mouse_botton - look
            a, left_arrow - move left
            d, right_arrow - move right
            w, up_arrow - move forward
            s, down_arrow - move backward
            page_up - move camera up
            page_down - move camera down
            1-7 - jump to fixed viewpoint
    
    Additional camera controls and other simulator commands can be found on page 30 of the 3d simulator manual.

    Note: If the graphics are really slow and choppy there's a chance you're working on a machine that doesn't have direct rendering turned on. If direct rendering is not enabled you might want to move to a machine that does have this feature enabled (which should include the lab computers in ENS 1 and ENS 31NR).

  6. Now type 'k' in the simulator to kickoff. You should see the time start running. The agent won't move however as it hasn't been told to take any actions.

  7. Now lets quit the simulator by typing 'q'. After quitting the simulator it's likely that the agent will still be running which is bad as it will become a runaway process just eating up CPU. Check for the agent process with the following:
            % ps aux | grep agentspark
    
    If the agentspark process is still running go ahead and kill it by running the following:
            % sh kill.sh
    
    It's a good idea to run the kill.sh script everytime after quitting the simulator to clean up potential runaway agent processes.

  8. Now lets go ahead and have the agent actually do something instead of just stand there after kickoff. Open startegy.cc and go to the selectSkill() method. You should see that it returns an eunmerated value type of SKILL_STAND. Change this return value to be SKILL_WALK_FRONT and save your changes to strategy.cc. Now recompile the agent with the make command:
            % make
    
    Then start the simulator and agent running again as before. After the agent appears in the center circle type 'k' to kickoff again. This time instead of just standing there the agent should start walking forward. Go ahead and quit the simulator and agent processes again as before.
    The selectSkill() method is called almost every cycle of the simulator and its return value determines what skill or action the agent will perform next. In addition to standing and walking the agent has many other skills which we have designed for it including kicking. Try having selectSkill() return SKILL_KICK_LONG_RIGHT_LEG to see it kick the ball. The following is a list of the enumerated values you can have selectSkill() return in order to perform different actions...feel free to try some of them out!
            SKILL_STAND - stand
            SKILL_WALK_FRONT - walk forward
            SKILL_WALK_BACK - walk backward
            SKILL_WALK_LEFT - walk sideways to the left
            SKILL_WALK_RIGHT - walk sideways to the right    
            SKILL_TURN_LEFT - turn to the left
            SKILL_TURN_RIGHT - turn to the right
            SKILL_WALK_FRONT_CURVED_LEFT - forward walk that curves left
            SKILL_WALK_FRONT_CURVED_RIGHT - forward walk that curves right
    	SKILL_KICK_LONG_LEFT_LEG - long kick left leg
            SKILL_KICK_LONG_RIGHT_LEG - long kick right leg
            SKILL_KICK_MED_LEFT_LEG - medium kick left leg
            SKILL_KICK_MED_RIGHT_LEG - medium kick right leg
            SKILL_DIVE_LEFT - goalie dive to the left
            SKILL_DIVE_RIGHT - goalie dive to the right
            SKILL_DIVE_CENTER - goalie dive to the center
    
  9. Another thing we control is an agent's starting position at the beginning of the game. This is determined by the beam() method in strategy.cc which "beams" an agent to a particular position at the beginning of a match. In order to change this try changing the values set in beam() to the following:
            beamX = -1; //-0.2;
            beamY = 1; //0.05;
            beamAngle = 180; //0;
    
    Now if you recompile and run the simulator and agent you should see the agent start in a different postition with it facing toward its own goal.

Watch a game

In a shell, go to the game logs directory
        % cd /projects/cs344M.pstone/3d/logs
        % ls 
Pick at least two of the games to watch.
        % rcssmonitor3d --logfile  <game>  (e.g. "sparkmonitor.log") 
(A full game is 600 seconds. The logs are halves which go for 300 seconds (5 minutes). If the log player doesn't work, see the instructions above to make sure that nobody is running the soccer server on your computer.

Create a game log

Open the simspark.rb file located in the same directory as the strategy.cc file you have been editing. Change $recordLogfile to be true (this should be one of the first lines in the file) and save your change.
        $recordLogfile = true 
Now repeat the sequence from "Get familiar with the 3D soccer simulator" to start the simulator and run an agent however this time make sure to run the simulator from the same directory as the simspark.rb file you edited as otherwise your change won't be processed and no log will be created. After killing the server, notice that there will be a log file in the directory from which you ran the server:
	% ls *.log
replay your log:
        % rcssmonitor3d --logfile <file>.log  
(where <file> is the name of the log displayed by the previous command) Turn in the logfile as directed on the main assignments page. During this course, you will often be sending us such logfiles as the results of your programming assignments.

[Back to Department Homepage]

Page maintained by Patrick MacAlpine
Questions? Send me mail