-
Notifications
You must be signed in to change notification settings - Fork 38
Running the code
First, ensure that you are Connected to a robot.
In UPennDev/Player/, there's an important file called game. This is an executable file that oversees all the different processes running on Nao. There are many different arguments to this executable, please read the file for more info. Here's a short list of the most used commands:
-
./game
: run the basic code where robot can see properly -
./game v
: run basic code and a demo thread where the robot can walk around, kick the ball and turn with keyboard control. -
./game p
: run vision on robot as well as a thread to adjust the camera parameters, this is used at the beginning of a colortable making process. -
./game main
: start all game processes except whistle detection (explained in Parallel Processes) -
./game mainw
: start all game processes including whistle detection
Each "screen" has a name, and a value associated to this "screen". The name can be anything and has some conventions and the value is always generated at execution.
-
screen -S <some screen name>
: start a new thread -
screen -ls
: list all the existing threads, you can see the name, thread id (a value) and status and the total number of threads running -
screen -r <some screen name>
: resume an existing thread -
ctrl + a + d
: keep the thread running in the background -
ctrl + c
: terminate the current thread, note that doing this might cause system crashing -
killall screen
: terminate all existing threads -
kill <value associated to that screen>
: terminate a specific thread currently running
If there's any missing screens, that means some threads are not started properly and might have crashed. First try manually starting the thread again and see if an error message occurs. For detailed assistance for debugging crashed screens, check out Fixing crashed processes and Debugging tips
Each "screen" that you see when doing screen -ls
is a separate process / thread that runs independently (might share memory and low level dependencies). For instance, the Hardware Abstraction Level runs separate from the behavior code, the Nao kernel (its OS) runs separate from vision or sound detection. Another advantage of using parallel threads is to allow the execution to be more modular and build on each other. For instance, after ./game is run on the robot, one only needs to start a new script called "run_main.lua" to start the game code. Similarly, whistle detection or camera calibration can be easily added to and removed from the basic structures depending on the situations.
Here are some common threads that are used:
hal
naoqi
v1
v2
arb
main
sound
naohal stands for Nao Hardware Abstraction Layer, this process formats the commands and sensors properly from hardware to the kernel/OS level on Nao.
/usr/bin/hal
for manually starting this thread
naoqi is the name of the Nao Operating System. It is a variation based on Linux/unix OS. naohal and naoqi have to function in order for all the other threads and code to run properly on the robot.
naoqi-bin
for manually starting this thread
v1 runs the camera initialization and vision detection code for the top camera.
luajit run_parallel_cognition.lua 1
for manually starting this thread
Note: please use luajit instead of lua, otherwise you WILL get error, it has argument 1 or 2, this stands for the indexing of cameras (1 is for starting on top camera and 2 for bottom camera)
v2 waits to make sure that v1 is running properly and then runs the camera initialization and vision detection code for the bottom camera.
luajit run_parallel_cognition.lua 2
for manually starting this thread
Note: please use luajit instead of lua, otherwise you WILL get error, it has argument 1 or 2, this stands for the indexing of cameras (1 is for starting on top camera and 2 for bottom camera)
lua run_arbitrator.lua
for manually starting this thread
lua run_main.lua
for manually starting this thread
Sound thread is a new addition due to the rule changes in 2016. Now game starts with a whistle and the robot that can't detect whistle for game start has to wait for 15 seconds before they can play. Sound runs a script called detect_whistle. For the detailed explanation and usage of this file and the sound thread, please go to Whistle detection
lua detect_whistle.lua
for manually starting this thread