ALMEMORY_KEY_NAMES = [
"Device/SubDeviceList/HeadYaw/Position/Actuator/Value",
"Device/SubDeviceList/HeadYaw/Position/Sensor/Value",
"Device/SubDeviceList/HeadYaw/ElectricCurrent/Sensor/Value",
"Device/SubDeviceList/HeadYaw/Temperature/Sensor/Value",
"Device/SubDeviceList/HeadYaw/Hardness/Actuator/Value",
"Device/SubDeviceList/HeadYaw/Temperature/Sensor/Status",]
ROBOT_IP = "10.34.111.131"
import os
import sys
import time
from naoqi import ALProxy
def recordData(nao_ip):
print "Recording data ..."
memory = ALProxy("ALMemory", nao_ip, 9559)
data = list()
for i in range (1, 500):
line = list()
for key in ALMEMORY_KEY_NAMES:
value = memory.getData(key)
line.append(value)
data.append(line)
time.sleep(0.005)
return data
def main():
if len(sys.argv) < 2:
nao_ip = ROBOT_IP
else:
nao_ip = sys.argv[1]
data = recordData(nao_ip)
#output ="record.csv"
output = ("/home/nao/.local/share/logkayit/logkayit.txt")
with open(output, "w") as fp:
for line in data:
fp.write("; ".join(str(x) for x in line))
fp.write("\n")
print "Results written to", output
if __name__ == "__main__":
main()
第一步:我还要保存本地机器人/home/nao/.local/share/logkayit/logkayit.txt
。
但这没有用,我不知道解决方案是什么。
第二步:我还想保存有关对话框详细信息的日志。我可以通过Monitor App很好地进行检查,但是我想要.cvs
。
最后一步:是否可以保存.cvs
的onTime?例如每天2 PM-4 PM
答案 0 :(得分:0)
如果运行此代码,它将打印出错误-在您的情况下,问题是“ data”变量不存在,而那个是因为您没有调用recordData函数在代码中的任何位置。
答案 1 :(得分:0)
我认为您的问题是您在计算机上启动了代码。如果要在机器人上编写logkayit.txt,则需要在机器人上启动.py。否则,您的代码将仅尝试在计算机上写入txt文件并引发错误。