您的位置:首页 > 产品设计 > UI/UE

How to build a Naoqi module - the basics

2013-12-26 13:02 211 查看
[For my colleagues]

So, if you want to build a Naoqi (LOCAL) module that will eventually run on the Nao robot, you have to use Ubuntu (12.04)

First install qibuild, the current version is v3.2, but it seems to have some problems. So if v3.2 somehow does not work, use v3.1 instead (that's what I use). The v3.1 qibuild can be found here

https://github.com/aldebaran/qibuild/releases/tag/v3.1


Extract the zip folder, then run

./generate-sourceme.sh


And put the following line into the end of .bashrc

source ~/qibuild/sourceme.sh


Restart the terminal, and you will be able to callqibuild and
qitoolchain directly.

Then you can create a worktree:

$ cd /path/to/your/worktree
$ qibuild init


This will create a
.qi directory in your worktree path. It contains a
qibuild.xml and worktree.xml, which are pretty much empty for now (will be modified by following commands). Note before you runqibuild init,
the current directory has to be empty.

Then it's time to create a project. According to the Aldebaran official documentation, one could simply typeqibuild create yourproject, and everything
will be taken care of. But a funny thing is, since v3.1qibuild create is
GONE. And there are NO substitutes. So, if you want a new qibuild project, you have to modify theworktree.xml yourself. Oh, and write yourCMakeLists.txt
from scratch. EDIT: you also need to manually compose a
project.xml file in your project folder. I forgot about this last time and misled my colleagues. My appologies.
A typical project.xml looks like

<project name="helloworld">
<depends buildtime="true" runtime="true" names="libnaoqi" />
</project>


So, my recommendation: always start from an existing projects.

For example, if in your project folder is named
helloworld, then you should update your
worktree.xml as

<worktree>
<project src="helloworld" />
</worktree>


Later you can add more
<project/> nodes into it.

Then create a toolchain. You need to download the proper Naoqi SDK. For example, if you use Ubuntu 12.04 64-bit, and you want to create a REMOTE module, you should downloadnaoqi-sdk-1.rr.x.y-linux64,
but if you want to create a LOCAL module, you should use a cross-compilation SDK such aslinux64-nao-atom-cross-toolchain-1.rr.x.y-2013-mm-dd.

The command is

$ qitoolchain create my-toolchain /path/to/your/sdk/toolchain.xml


I strongly do NOT recommend the use of--default argument. It makes compiling less flexible and mistake-prone. I would recommend to
use-c to specify your toolchain every time youconfigure and
make. Note this command has to be run inside the worktree directory.

Now, suppose your CMakeLists.txt and source code are ready in your project folder. You can do

$ qibuild configure helloworld -c my-toolchain
$ qibuild make helloworld -c my-toolchain


If you are building a REMOTE module, this will create an executable in the build directory, you can run it directly from your Ubuntu machine with the proper IP and port number.

If you are building a LOCAL module, this will generate a shared library, you need to copy the shared library to the robot

$ scp helloworld/build-my-toolchain/sdk/lib/naoqi/libhelloworld.so nao@10.0.222.100:~/


Then add the following line into theautoload.ini under
/home/nao/naoqi/preferences/

/home/nao/libhelloworld.so


Then ssh to the robot and restart naoqi

$ nao restart


Now you will see your own module in the package list in the robot webpage.

So, this article does not cover how the CMakeLists and the source code should be composed. It is just a flow description of compilation under qibuild framework. The examplehelloworld that is shipped
with SDK package is a good start
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: