sot-talos-balance  2.0.5
Collection of dynamic-graph entities aimed at implementing balance control on talos.
test_simple_ankle_admittance.py
Go to the documentation of this file.
1 from time import sleep
2 
3 from dynamic_graph.sot_talos_balance.utils.run_test_utils import (
4  ask_for_confirmation,
5  evalCommandClient,
6  run_test,
7  runCommandClient,
8 )
9 
10 run_test("appli_simple_ankle_admittance.py")
11 
12 sleep(1.0)
13 
14 RightPitchJoint = 10
15 LeftPitchJoint = 4
16 RightRollJoint = 11
17 LeftRollJoint = 5
18 
19 c = ask_for_confirmation("Do you want to use the current torques values as reference?")
20 if c:
22  "robot.rightPitchAnkleController.tauDes.value = "
23  "robot.device.ptorque.value[RightPitchJoint]"
24  )
26  "robot.leftPitchAnkleController.tauDes.value = "
27  "robot.device.ptorque.value[LeftPitchJoint]"
28  )
30  "robot.rightRollAnkleController.tauDes.value = "
31  "robot.device.ptorque.value[RightRollJoint]"
32  )
34  "robot.leftRollAnkleController.tauDes.value = "
35  "robot.device.ptorque.value[LeftRollJoint]"
36  )
37 
38  print("Setting desired torques with current values")
39 else:
40  c2 = ask_for_confirmation("Do you want to use nul torques values as reference?")
41  if c2:
42  runCommandClient("robot.rightPitchAnkleController.tauDes.value = [0.0]")
43  runCommandClient("robot.leftPitchAnkleController.tauDes.value = [0.0]")
44  runCommandClient("robot.rightRollAnkleController.tauDes.value = [0.0]")
45  runCommandClient("robot.leftRollAnkleController.tauDes.value = [0.0]")
46 
47  print("Setting desired torques with nul values")
48  else:
50  "robot.rightPitchAnkleController.tauDes.value = [-2.5164434873140853]"
51  )
53  "robot.leftPitchAnkleController.tauDes.value = [-2.5164434873140853]"
54  )
55  runCommandClient("robot.rightRollAnkleController.tauDes.value = [0.0]")
56  runCommandClient("robot.leftRollAnkleController.tauDes.value = [0.0]")
57 
58  print("Setting desired torques with implemented values")
59 
60 print("Pushing the ankle tasks...")
61 
62 runCommandClient("robot.sot.push(robot.rightAnklePitchTask.task.name)")
63 runCommandClient("robot.sot.push(robot.leftAnklePitchTask.task.name)")
64 runCommandClient("robot.sot.push(robot.rightAnkleRollTask.task.name)")
65 runCommandClient("robot.sot.push(robot.leftAnkleRollTask.task.name)")
66 
67 sleep(5.0)
68 tauRP = evalCommandClient("robot.device.ptorque.value[RightPitchJoint]")
69 tauLP = evalCommandClient("robot.device.ptorque.value[LeftPitchJoint]")
70 tauRR = evalCommandClient("robot.device.ptorque.value[RightRollJoint]")
71 tauLR = evalCommandClient("robot.device.ptorque.value[LeftRollJoint]")
72 
73 tauDesRP = evalCommandClient("robot.rightPitchAnkleController.tauDes.value")
74 tauDesLP = evalCommandClient("robot.leftPitchAnkleController.tauDes.value")
75 tauDesRR = evalCommandClient("robot.rightRollAnkleController.tauDes.value")
76 tauDesLR = evalCommandClient("robot.leftRollAnkleController.tauDes.value")
77 
78 print(
79  "Desired torques: %f, %f, %f, %f"
80  % (tauDesRP[0], tauDesLP[0], tauDesRR[0], tauDesLR[0])
81 )
82 print("Current torques: %f, %f, %f, %f" % (tauRP, tauLP, tauRR, tauLR))
def run_test(appli, verbosity=1, interactive=True)