sot-talos-balance  2.0.5
Collection of dynamic-graph entities aimed at implementing balance control on talos.
appli_kinematics.py
Go to the documentation of this file.
1 # flake8: noqa
2 from dynamic_graph import plug
3 from dynamic_graph.sot.core import SOT
4 from dynamic_graph.sot.core.matrix_util import matrixToTuple
5 from dynamic_graph.sot.core.meta_tasks_kine import (
6  MetaTaskKine6d,
7  MetaTaskKineCom,
8  gotoNd,
9 )
10 
11 import dynamic_graph.sot_talos_balance.talos.control_manager_conf as cm_conf
12 import dynamic_graph.sot_talos_balance.talos.parameter_server_conf as param_server_conf
14 
15 robot.timeStep = robot.device.getTimeStep()
16 dt = robot.timeStep
17 robot.comTrajGen = create_com_trajectory_generator(dt, robot)
18 
19 # --- COM
20 robot.taskCom = MetaTaskKineCom(robot.dynamic)
21 robot.dynamic.com.recompute(0)
22 robot.taskCom.featureDes.errorIN.value = robot.dynamic.com.value
23 robot.taskCom.task.controlGain.value = 10
24 
25 # --- CONTACTS
26 # define contactLF and contactRF
27 robot.contactLF = MetaTaskKine6d(
28  "contactLF", robot.dynamic, "LF", robot.OperationalPointsMap["left-ankle"]
29 )
30 robot.contactLF.feature.frame("desired")
31 robot.contactLF.gain.setConstant(0)
32 robot.contactLF.keep()
33 robot.contactLF.task.setWithDerivative(True)
34 robot.contactLF.featureDes.velocity.value = [0.0] * 6
35 locals()["contactLF"] = robot.contactLF
36 
37 robot.contactRF = MetaTaskKine6d(
38  "contactRF", robot.dynamic, "RF", robot.OperationalPointsMap["right-ankle"]
39 )
40 robot.contactRF.feature.frame("desired")
41 robot.contactRF.gain.setConstant(0)
42 robot.contactRF.keep()
43 robot.contactRF.task.setWithDerivative(True)
44 robot.contactRF.featureDes.velocity.value = [0.0] * 6
45 locals()["contactRF"] = robot.contactRF
46 
47 robot.taskRH = MetaTaskKine6d("taskRH", robot.dynamic, "RH", "arm_right_7_joint")
48 robot.taskRH.feature.frame("desired")
49 robot.taskRH.gain.setConstant(0)
50 robot.taskRH.keep()
51 robot.taskRH.task.setWithDerivative(True)
52 robot.taskRH.featureDes.velocity.value = [0.0] * 6
53 locals()["taskRH"] = robot.taskRH
54 
55 robot.taskLH = MetaTaskKine6d("taskLH", robot.dynamic, "LH", "arm_left_7_joint")
56 robot.taskLH.feature.frame("desired")
57 robot.taskLH.gain.setConstant(0)
58 robot.taskLH.keep()
59 robot.taskLH.task.setWithDerivative(True)
60 robot.taskLH.featureDes.velocity.value = [0.0] * 6
61 locals()["taskLH"] = robot.taskLH
62 
63 # robot.taskRH = MetaTaskKine6d('taskRH', robot.dynamic, 'RH', 'arm_right_7_joint')
64 # handMgrip = np.eye(4)
65 # handMgrip[0:3, 3] = (0.1, 0, 0)
66 # robot.taskRH.opmodif = matrixToTuple(handMgrip)
67 # robot.taskRH.feature.frame('desired')
68 # robot.taskRH.feature.selec.value = '111111'
69 # robot.taskRH.task.setWithDerivative(True)
70 # robot.taskRH.task.controlGain.value = 0
71 # robot.taskRH.feature.position.value = np.eye(4)
72 # robot.taskRH.feature.velocity.value = [0., 0., 0., 0., 0., 0.]
73 # robot.taskRH.featureDes.position.value = np.eye(4)
74 # robot.taskRH.featureDes.velocity.value = [0., 0., 0., 0., 0., 0.]
75 
76 # robot.taskLH = MetaTaskKine6d('taskLH', robot.dynamic, 'LH', 'arm_left_7_joint')
77 # handMgrip = np.eye(4)
78 # handMgrip[0:3, 3] = (0.1, 0, 0)
79 # robot.taskLH.opmodif = matrixToTuple(handMgrip)
80 # robot.taskLH.feature.frame('desired')
81 # robot.taskLH.feature.selec.value = '111111'
82 # robot.taskLH.task.setWithDerivative(True)
83 # robot.taskLH.task.controlGain.value = 0
84 # robot.taskLH.feature.position.value = np.eye(4)
85 # robot.taskLH.feature.velocity.value = [0., 0., 0., 0., 0., 0.]
86 # robot.taskLH.featureDes.position.value = np.eye(4)
87 # robot.taskLH.featureDes.velocity.value = [0., 0., 0., 0., 0., 0.]
88 
89 robot.sot = SOT("sot")
90 robot.sot.setSize(robot.dynamic.getDimension())
91 
92 # --- Plug SOT control to device through control manager
93 plug(robot.sot.control, robot.device.control)
94 
95 plug(robot.comTrajGen.x, robot.taskCom.featureDes.errorIN)
96 
97 robot.sot.push(robot.contactRF.task.name)
98 robot.sot.push(robot.contactLF.task.name)
99 robot.sot.push(robot.taskRH.task.name)
100 robot.sot.push(robot.taskLH.task.name)
101 robot.sot.push(robot.taskCom.task.name)
102 robot.device.control.recompute(0)
create_entities_utils
sot_talos_balance.create_entities_utils.create_com_trajectory_generator
def create_com_trajectory_generator(dt, robot)
Definition: create_entities_utils.py:120