CS344M: Autonomous Multiagent Systems -- Fall 2012:-- -- 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.6 and simspark 0.2.3 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 . You will also probably want to install RoboViz 3D soccer monitor for which you can find installation instructions here.

Get familiar with the 3D soccer simulator

  1. Set up your environment by adding the following line to to the end of your ~/.bashrc file so that the correct executables are in your path.
    	export PATH=/projects/cs344M.pstone/3d:$PATH
    You will need to open a new terminal or type the command bash into existing terminals for this change to take effect.

  2. 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.)

  3. If there isn't a simulator already running on the machine then proceed with the following step, otherwise skip to the next step with instructions for running the simulator on a remote machine.

    In one shell, start the simulator:
            % rcroboviz
    The above command is a script that starts both the simulator server (rcssserver3d) and monitor (roboviz). 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. If you were able to complete the previous step for running the simulator on your local machine you can skip these instructions for running the simulator on a remote machine and move on to the next step. In order to run the simulator on a remote machine do the following:

    Choose a machine to run the server on from the list of available machines:
            % cshosts pub64
    In one shell, start the server on the remote machine:
            % ssh <remote_machine_name>
    	% run_server3d  (be sure to check first that there isn't
    	already a simulator running on the remote machine following
    	the instructions in an earlier step, and if so choose a
    	different machine to run the server on)
    In another shell, start the roboviz monitor on the local machine:
            % export RCSS_HOST=<remote_machine_name>
    	% run_roboviz
    You will likely see a lot of text including error messages being printed out as the server and monitor start up but don't worry as you can ignore these.

  5. 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 build the agent
            % cd nao-agent
            % make
    Then start the agent running
            % ./agentspark --host=localhost --team myteam --unum 2 --paramsfile paramfiles/defaultParams.txt&
    	[instead of myteam, use your own name]
    	[if you're running the server on a remote machine use the name of that machine for the host instead of localhost]
    The agent should appear in the center circle of the field.

  6. 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-8 - jump to fixed viewpoint
    	space - camera follows ball
    Additional camera controls and other simulator commands can be found on the RoboViz controls page.

  7. 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.

  8. Now lets quit the simulator by typing 'q' or closing the roboviz window. When running the simulator remotely (not through the rcroboviz script) the server will likely need to be quit manually. In order to ensure that the server is killed run the following command on the machine the server is running on:
            % kill_server3d

  9. Now lets go ahead and have the agent actually do something instead of just stand there after kickoff. Open strategy.cc and go to the selectSkill() method. You should see that it returns an enumerated value type of SKILL_STAND. Change this return value to be SKILL_KICK_LONG_RIGHT_LEG 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 kick the ball forward toward the opponent's goal. 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 kicking the agent has many other skills which we have designed for it including walking. For walking we use an omnidirectional walk engine allowing us to specify walk direction, rotation, and speed all at the same time. Try having selectSkill() return getWalk(0, 0, 1) to see the agent walk forwards (this time when starting the simulator type 'b' to start play with a drop ball as otherwise the agent will be penalized for touching the ball twice in a row on the kickoff). The following is a list of some 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
    	getWalk(0, 0, 1) - walk forwards
    	getWalk(180, 0, 1) - walk backwards
    	getWalk(-90, 0, 1) - walk sideways to the right
    	getWalk(90, 0, 1) - walk sideways to the left
    	getWalk(0, -90, 0) - turn clockwise
    	getWalk(0, 90, 0) - turn counter-clockwise
    	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_KICK_QUICK_LEFT_LEG - quick kick left leg
            SKILL_KICK_QUICK_RIGHT_LEG - quick 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
  10. 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;
            beamY = 1; 
            beamAngle = 180; 
    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.
        % run_roboviz --logfile <full_path_to_game_log_file>  (e.g. "/projects/cs344M.pstone/3d/logs/2012_final_second_extrahalf_UTAustinVilla_vs_RoboCanes.log") 
A full game is 600 seconds. The logs are halves which go for 300 seconds (5 minutes) or if they are extra time periods they go for 180 seconds (3 minutes). If the log doesn't work double check that you are providing the full (absolute) path to the log file.

Create a game log

Open the rcssserver3d.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 rcssserver3d.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:
        % run_roboviz --logfile <full_path_to_log_file>  
Turn in the logfile as directed on the main assignments page. Note that these logfiles can often be quite large so please compress them first before turning them in with the following command:
        % gzip <log_file>  
This will compress your log into a file called <log_file>.gz.

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