I'm using Choregraphe on Windows to implement programms with Python for my NAO robot. I have two problems which I can't solve by myself:
I used the following code in a Python Box:
import logging
filepath = os.path.join(os.path.dirname(ALFrameManager.getBehaviorPath(self.behaviorId)), "fileName.txt")
maybeContains = None
try:
with open(filepath, "r") as textfile:
maybeContains = textfile.readlines()
except:
pass
with open(filepath, "a") as textfile:
if maybeContains == "":
agenda = "type1;type2;\n"
textfile.write(agenda)
textfile.write(storedData)
else:
textfile.write(storedData)
self.onStopped()
When I try to download the file "fileName.txt" via Connection > Advanced > File Transfer there isn't that file in one of those listed orders.
I added to the onLoad() method of a "Say Text"-box the following code:
def onLoad(self):
self.logging.basicConfig(filename="20180712.log", format='%(asctime)s %(levelname)s-8s [%(filename)s:%(lineno)d]%(message)s', level=logging.DEBUG)
self.logger = self.logging.getLogger("Behavior - Box") `
Before a command, which should be logged I call
` self.logger("what happened here")
the "Connection > Advanced > File Transfer" open a file at a specific location. Depending on the version of your robot. Some years ago it was "/var/www" or "~/ftp/" ...
On my current NAO (2.1), it's in "/home/nao".
So the good way in my case is to create the file at this place:
filepath = "/home/nao/myfile.txt"
That being said, there's better way to get a file from your robot, on windows, you can use winscp (gui) or pscp (cli), it's far more convenient than Choregraphe...
Good luck.