7 print "import without hrpsys" 12 from waitInput
import *
17 global hcf, hrpsys_version
18 hcf = HrpsysConfigurator()
19 hcf.getRTCList = hcf.getRTCListUnstable
20 hcf.init (
"SampleRobot(Robot)0",
"$(PROJECT_DIR)/../model/sample1.wrl")
21 hrpsys_version = hcf.seq.ref.get_component_profile().version
22 print(
"hrpsys_version = %s"%hrpsys_version)
24 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]
25 hcf.seq_svc.setJointAngles(initial_pose, 2.0)
26 hcf.seq_svc.waitInterpolation()
30 print >> sys.stderr,
"0. startImpedance + stopImpedance python interface" 31 hcf.startImpedance(
"rarm")
32 hcf.startImpedance(
"larm")
33 hcf.stopImpedance(
"larm")
34 hcf.stopImpedance(
"rarm")
38 print >> sys.stderr,
"1. Getter check" 40 for limb
in [
"rarm",
"larm"]:
41 all_get_ret.append(hcf.ic_svc.getImpedanceControllerParam(limb)[0])
42 print >> sys.stderr,
" all_get_ret = ", all_get_ret
43 assert(all(all_get_ret))
44 print >> sys.stderr,
" getImpedanceControllerParam => OK" 48 print >> sys.stderr,
"2. Setter check" 51 for limb
in [
"rarm",
"larm"]:
52 [ret1, icp1]=hcf.ic_svc.getImpedanceControllerParam(limb)
56 all_set_ret.append(hcf.ic_svc.setImpedanceControllerParam(limb, icp1))
57 [ret2, icp2]=hcf.ic_svc.getImpedanceControllerParam(limb)
58 all_value_ret.append((icp1.M_r == icp2.M_r)
and (icp1.D_r == icp2.D_r)
and (icp1.K_r == icp2.K_r))
59 print >> sys.stderr,
" all_set_ret = ", all_set_ret,
", all_value_ret = ", all_value_ret
60 assert(all(all_set_ret)
and all(all_value_ret))
61 print >> sys.stderr,
" setImpedanceControllerParam => OK" 65 print >> sys.stderr,
"3. Start impedance" 69 for limb
in [
"rarm",
"larm"]:
70 [ret, icp]=hcf.ic_svc.getImpedanceControllerParam(limb)
71 all_start_ret.append(hcf.ic_svc.startImpedanceControllerNoWait(limb))
72 all_mode_ret.append(icp.controller_mode == OpenHRP.ImpedanceControllerService.MODE_IDLE)
74 for limb
in [
"rarm",
"larm"]:
75 hcf.ic_svc.waitImpedanceControllerTransition(limb)
76 [ret, icp]=hcf.ic_svc.getImpedanceControllerParam(limb)
77 all_mode_ret.append(icp.controller_mode == OpenHRP.ImpedanceControllerService.MODE_IMP)
79 for limb
in [
"rarm",
"larm"]:
80 all_start_ret.append(
not hcf.ic_svc.startImpedanceControllerNoWait(limb))
81 print >> sys.stderr,
" all_start_ret = ", all_start_ret,
", all_mode_ret = ", all_mode_ret
82 assert(all(all_start_ret)
and all(all_mode_ret))
83 print >> sys.stderr,
" startImpedanceController => OK" 87 print >> sys.stderr,
"4. Set ref force and moment" 88 hcf.seq_svc.setWrenches([0,0,0,0,0,0,
91 20,10,-10,0,0,0,], 1.0);
92 hcf.seq_svc.waitInterpolation();
94 hcf.seq_svc.setWrenches([0,0,0,0,0,0,
98 hcf.seq_svc.waitInterpolation();
100 hcf.seq_svc.setWrenches([0,0,0,0,0,0,
103 0,0,0,0.1,-0.1,0.1], 1.0);
104 hcf.seq_svc.waitInterpolation();
106 hcf.seq_svc.setWrenches([0,0,0,0,0,0,
110 hcf.seq_svc.waitInterpolation();
115 print >> sys.stderr,
"5. Stop impedance" 119 for limb
in [
"rarm",
"larm"]:
120 all_stop_ret.append(hcf.ic_svc.stopImpedanceControllerNoWait(limb))
122 for limb
in [
"rarm",
"larm"]:
123 hcf.ic_svc.waitImpedanceControllerTransition(limb)
124 [ret, icp]=hcf.ic_svc.getImpedanceControllerParam(limb)
125 all_mode_ret.append(icp.controller_mode == OpenHRP.ImpedanceControllerService.MODE_IDLE)
127 for limb
in [
"rarm",
"larm"]:
128 all_stop_ret.append(
not hcf.ic_svc.stopImpedanceControllerNoWait(limb))
129 print >> sys.stderr,
" all_stop_ret = ", all_stop_ret,
", all_mode_ret = ", all_mode_ret
130 assert(all(all_stop_ret)
and all(all_mode_ret))
131 print >> sys.stderr,
" stopImpedanceController => OK" 135 print >> sys.stderr,
"6. Arm tracking check" 136 hcf.ic_svc.startImpedanceController(
"rarm")
137 hcf.setJointAngle(
"RARM_ELBOW", -40.0, 0.5);
138 hcf.waitInterpolation()
139 hcf.setJointAngle(
"RARM_ELBOW", -70.0, 0.5);
140 hcf.waitInterpolation()
144 if hcf.kinematics_only_mode:
145 print >> sys.stderr,
"7. World frame check" 147 icp=hcf.ic_svc.getImpedanceControllerParam(
"rarm")[1]
148 icp.use_sh_base_pos_rpy =
True 149 hcf.ic_svc.setImpedanceControllerParam(
"rarm", icp)
151 hcf.seq_svc.setJointAngles(initial_pose, 2.0)
152 hcf.seq_svc.waitInterpolation()
153 hcf.setJointAngle(
"RLEG_ANKLE_P",40, 1);
154 hcf.waitInterpolation()
155 hcf.setJointAngle(
"RLEG_ANKLE_P",-40, 1);
156 hcf.waitInterpolation()
157 hcf.seq_svc.setJointAngles(initial_pose, 2.0)
158 hcf.seq_svc.waitInterpolation()
160 print >> sys.stderr,
"7. World frame check is not executed in non-kinematics-only-mode" 164 if hcf.kinematics_only_mode:
165 print >> sys.stderr,
"8. World frame ref-force check" 167 icp=hcf.ic_svc.getImpedanceControllerParam(
"rarm")[1]
168 icp.use_sh_base_pos_rpy =
True 169 hcf.ic_svc.setImpedanceControllerParam(
"rarm", icp)
171 hcf.seq_svc.setBaseRpy([0,0,0], 1.0);
172 hcf.seq_svc.waitInterpolation();
173 hcf.seq_svc.setWrenches([0,0,0,0,0,0,
176 -40,0,0,0,0,0], 1.0);
177 hcf.seq_svc.waitInterpolation();
178 hcf.seq_svc.setWrenches([0,0,0,0,0,0,
182 hcf.seq_svc.waitInterpolation();
183 hcf.seq_svc.setBaseRpy([0,45*3.14159/180,0], 1.0);
184 hcf.seq_svc.waitInterpolation();
185 hcf.seq_svc.setWrenches([0,0,0,0,0,0,
188 -40,0,0,0,0,0], 1.0);
189 hcf.seq_svc.waitInterpolation();
190 hcf.seq_svc.setWrenches([0,0,0,0,0,0,
194 hcf.seq_svc.waitInterpolation();
195 hcf.seq_svc.setBaseRpy([0,0,0], 1.0);
196 hcf.seq_svc.waitInterpolation();
198 print >> sys.stderr,
"8. World frame ref-force check is not executed in non-kinematics-only-mode" 202 print >> sys.stderr,
"1. Object Contact Turnaround Detector set param check" 204 detect_time_thre = 0.3
206 for number_disturbance
in [0, 1e-5, -1e-5]:
207 octdp=hcf.octd_svc.getObjectContactTurnaroundDetectorParam()[1];
208 octdp.detect_time_thre = detect_time_thre + number_disturbance
209 octdp.start_time_thre = start_time_thre + number_disturbance
210 hcf.octd_svc.setObjectContactTurnaroundDetectorParam(octdp);
211 octdp2=hcf.octd_svc.getObjectContactTurnaroundDetectorParam()[1];
212 print >> sys.stderr,
" ", octdp2
213 ret9 = ret9
and (octdp2.detect_time_thre == detect_time_thre
and octdp2.start_time_thre == start_time_thre)
215 print >> sys.stderr,
" => OK" 222 from distutils.version
import StrictVersion
223 if StrictVersion(hrpsys_version) < StrictVersion(
'315.5.0'):
236 if __name__ ==
'__main__':
def demoWorldFrameCheck()
def demoArmTrackingCheck()
def demoWorldFrameRefForceCheck()
def demoSetImpedanceControllerParam()
def demoStopImpedanceController()
def demoGetImpedanceControllerParam()
def demoStartImpedanceController()