I'm trying to write a small programm to have Pepper check for landmarks inside a room through Choregraphe. The regular Python code for landmark detection works just fine, but i can't port it to Choregraphe.http://doc.aldebaran.com/2-5/dev/python/examples/vision/landmark.html
I could already import the simple Python File in Choregraphe according to this video, but there's always an error when doing it with the landmark detection. https://www.youtube.com/watch?v=orDWxHQxw5s
This code
gives this error message :
[ERROR] behavior.box :createPythonModule:0
_Behavior__lastUploadedChoregrapheBehaviorbehavior_11118986952:/Landmark
Detektor_1: Box creation failed with the error: <type
'exceptions.RuntimeError'> Application was already initialized
How do I successfully port the Python landmark detection to Choregraphe code?
I wouldn't recommended doing too much custom Python directly in Choregraphe. It's possible, sure, but it's often difficult to debug and maintain.
The reason the two work differently is that standalone Python scripts have to take care of the connection to the robot, session management, etc. all of which is already handled when the Python is being executed in Choregraphe.
So some approaches:
qi.Application
, and inside a box you can get the session with self.session()
(instead of application.session or ALProxy in standalone Python). This will work, but it will be hard to keep track of your project with source control, and hard to debug it (e.g. if you have an infinite loop somewhere, it can keep running even if the behavior is stopped, and all your logs get lost in the middle of all the other NAOqi logs)./var/log/naoqi/servicemanager/
). This is what I usually do.(edit to add) One advantage to this last approach is that you can run your standalone Python script on your work computer (passing --qi-url your-peppers-ip as a command-line parameter) while testing it (so you get all your logs directly in your favourite IDE, and only those logs), and once you're satisfied with the result, install it on the robot with Choregraphe).