https://www.aldebaran.com/ja Please get an account at the above site. If you have pepper, I think you already have it. If you don't have one, please get it.
https://community.aldebaran.com/ja/developerprogram Sign up for the Developers Program.
https://community.aldebaran.com/en/resources/software Download the SDK that suits your environment. Python 2.7 SDK version name OS name bit number Example: My environment is ubuntu 64bit and pepper version is 2.4.2, so It's like [Python 2.7 SDK 2.4.2 Linux 64].
Optional for building a python environment. Because This is because OSs other than Windows have the version SDK required for this article installed by default.
If you have already built a python 3.x system or other environment for machine learning or scientific calculations, I think that pyenv is included, but I will link the article below.
Building a Python environment on Mac using pyenv
Below, official materials Python SDK - Installation Guide
Since you will be working in the terminal, define the environment. Editor: emacs (I think there are vi, nano, etc.) OS: Mac (almost the same for linux)
Download pynaoqi-python2.7-2.4.2.26-mac64 from the above site & method. I think it is in zip format, so unzip it to a directory of your choice.
Start up the terminal and add the following to ~ / .bash_profile with various editors.
$ export PYTHONPATH=${PYTHONPATH}:/path/to/python-sdk $ export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/path/to/python-sdk
The part of / path / to / python-sdk is not as it is, I just downloaded and unzipped it. The path to the directory.
Start up the terminal and check the import $ source .bash_profile $ python >>> import qi >>> import naoqi If there is no problem, go to the next.
Recommended site for Windows Apple (Japan)
qiBuild documentation - Getting started ・ What to prepare
-Install with pip. $ sudo pip install qibuild
\ $ qibuild config --create a config file with wizard At the very beginning, you will be asked for the path to bin of cmake, but otherwise it is better if you select 1.
・ Operation check $ qibuild --version qibuild version 3.10.1 Using Python code from /usr/local/lib/python2.7/dist-packages Using CMake code from /usr/local/share/cmake
Python - How to write a qimessaging service Finally the main subject. Can be used locally with pepper apps and dialogs such as ^ pCall and call Let's register the service.
myfooservice.py
import qi
import sys
class MyFooService:
def __init__(self, session):
print "hello,"
def bang(self):
return "world"
def main():
# Create and Start the Application
app = qi.ApplicationSession(sys.argv)
app.start()
# Get the Session
session = app.session
# Create the Service
mf = MyFooService(session)
# Register It
session.registerService("MyFooService", mf)
# Run the Application
app.run()
if __name__ == "__main__":
main()
Yes, in the previous section you have successfully created a python file that will be the masterpiece of the service. All you have to do is register. What you need below.
$ cd /path/to/sakki/no/faile/myfooservice.py \ $ python myfooservice.py --qi-url = tcp: //pepper1.local (or 192.168.0.11)
Then, I think it will look like the following.
I'm wondering if you can say that, but how about it?
Let's verify why it can be used in the actual machine. What you need below
Log in with ssh. $ ssh [email protected]
Make sure your service is properly registered. $ qicli info MyFooService $ qicli call MyFooService.bang
That's it. Next time, I'll write how to incorporate the service into an actual application and run it. If you have any questions, please leave a comment.
Recommended Posts