Compiling

How to compile code
Here, we assume that you want to compile code that will interface with the robot.

Some of the instructions below are specific to the RoboCup codebase, but you can adapt it to your project.

Going to the right directory

 * If you are compiling the Main Module or Motion Module, go to robot/modules/MainModule or robot/modules/MotionModule respectively
 * If you are compiling a tool, go to tools//Module (e.g. tools/RemoteControl/RemoteControlModule)

Running on the robot

 * Go to the module's directory
 * Make sure crosscompile.sh is executable
 * chmod +x crosscompile.sh
 * Go to the robot_build directory (create it if necessary)
 * e.g. robot/modules/MainModule/robot_build
 * ../crosscompile.sh path_to_ctc ..
 * e.g. ../crosscompile.sh /opt/naoctc .. if you are building on one of the lab PCs
 * ccmake .
 * Set MODULE_IS_REMOTE to OFF
 * c g to generate the Makefile
 * make
 * scp generated_.so_file root@robot_ip:/opt/naoqi/modules/lib
 * e.g. scp src/libmainbroker.so root@nao-zeus.wv.cc.cmu.edu:/opt/naoqi/modules/lib
 * ssh into the robot
 * e.g. ssh root@nao-zeus.wv.cc.cmu.edu
 * Edit /opt/naoqi/modules/lib/autoload.ini and insert the project name
 * e.g. 'mainbroker for Main Module
 * if the generated file is libxyz.so, then the project name is xyz
 * Restart NaoQi (via the web interface) and check that the module appears under Modules

Running remotely from a computer
When you run remotely from a computer, a Broker has to be created that runs on your computer, and connects to the robot. The modules then run under this remote broker.


 * Go to the pc_build directory
 * e.g. robot/modules/MainModule/pc_build
 * cmake ..
 * ccmake .
 * Set BROKER_IS_REMOTE to ON
 * e.g. REMOTECONTROLBROKER_IS_REMOTE change it to ON by pressing  at that line
 * c g to generate the Makefile
 * make
 * If you have g++-4.x (i.e. on Ubuntu 8.04), this needs to be compiled with g++-3.x. Install g++-3.x (for example, apt-get install g++-3.4). Instead of make, run CXX=/usr/bin/g++-3.4 make.
 * 'src/module_executable -pip robot_ip -b your_ip''
 * e.g. src/mainbroker -pip nao-zeus.wv.cc.cmu.edu -b 192.168.1.100
 * Check that the Broker appears (via the web interface) under Child Brokers

Copying config files to the robot
To figure out what config files to copy to the robot, see Config Directory.

How to add a Library to CMake

 * Edit CMakeLists.txt under robot/modules/ or tools//Module
 * Note: if you want to create a new tool, please go to Creating Tools for more instructions
 * Add the library into the file:
 * e.g. Find_Package ( SDL REQUIRED )

How to include a new .cpp file

 * Edit CMakeLists.txt under robot/modules//src or tools//Module/src
 * Add your .cpp file names (search for "PROJECT SOURCE FILES")