Go to the documentation of this file.00001
00002
00003 try:
00004 from hrpsys.hrpsys_config import *
00005 import OpenHRP
00006 except:
00007 print "import without hrpsys"
00008 import rtm
00009 from rtm import *
00010 from OpenHRP import *
00011 import waitInput
00012 from waitInput import *
00013 import socket
00014 import time
00015
00016 def init ():
00017 global hcf, initial_pose
00018 hcf = HrpsysConfigurator()
00019 hcf.getRTCList = hcf.getRTCListUnstable
00020 hcf.log_use_own_ec = True
00021 hcf.init ("SampleRobot(Robot)0", "$(PROJECT_DIR)/../model/sample1.wrl")
00022
00023 initial_pose = [-7.779e-005, -0.378613, -0.000209793, 0.832038, -0.452564, 0.000244781, 0.31129, -0.159481, -0.115399, -0.636277, 0, 0, 0, -7.77902e-005, -0.378613, -0.000209794, 0.832038, -0.452564, 0.000244781, 0.31129, 0.159481, 0.115399, -0.636277, 0, 0, 0, 0, 0, 0]
00024 hcf.seq_svc.setJointAngles(initial_pose, 2.0)
00025 hcf.waitInterpolation()
00026
00027 def demoSaveLog():
00028 print >> sys.stderr, "1. Save log"
00029
00030
00031 hcf.saveLog("/tmp/test-samplerobot-log")
00032 ret = os.path.exists("/tmp/test-samplerobot-log.sh_qOut")
00033 if ret:
00034 print >> sys.stderr, " save() =>OK"
00035 assert(ret is True)
00036
00037 def demoClearLog():
00038 print >> sys.stderr, "2. Clear buffer"
00039 hcf.clearLog()
00040 print >> sys.stderr, " clear() =>OK"
00041 assert(True)
00042
00043 def demoSetMaxLogLength():
00044 print >> sys.stderr, "3. Set max ring-buffer length : 100 [loop] * 0.002 [s] = 0.2 [s] data"
00045 hcf.setMaxLogLength(100)
00046 hcf.seq_svc.setJointAngles(initial_pose, 0.2)
00047 hcf.waitInterpolation()
00048 hcf.saveLog("/tmp/test-samplerobot-log")
00049 from subprocess import check_output
00050 ret = check_output(['wc', '-l', '/tmp/test-samplerobot-log.sh_qOut']).split(" ")[0] == '100'
00051 if ret:
00052 print >> sys.stderr, " maxLength() =>OK"
00053 assert(ret is True)
00054
00055 def demo ():
00056 init()
00057 demoSaveLog()
00058 demoClearLog()
00059 demoSetMaxLogLength()
00060
00061 if __name__ == '__main__':
00062 demo()