sot-talos-balance  2.0.5
Collection of dynamic-graph entities aimed at implementing balance control on talos.
test_singleTraj.py
Go to the documentation of this file.
1 import os
2 from time import sleep
3 
4 from dynamic_graph import plug
5 from dynamic_graph.sot.core import SOT
6 from dynamic_graph.sot.core.meta_tasks_kine import MetaTaskKine6d
7 
9  create_config_trajectory_generator,
10 )
11 from dynamic_graph.sot_talos_balance.meta_task_config import MetaTaskKineConfig
12 
13 N_JOINTS = 32
14 N_CONFIG = N_JOINTS + 6
15 
16 
17 def main(robot):
18  robot.timeStep = robot.device.getTimeStep()
19  dt = robot.timeStep
20  robot.traj_gen = create_config_trajectory_generator(dt, robot)
21 
22  JOINT = 31
23  QJOINT = JOINT + 6
24 
25  # --- Joint
26  robot.taskJoint = MetaTaskKineConfig(robot.dynamic, [QJOINT])
27  # robot.dynamic.com.recompute(0)
28  robot.taskJoint.featureDes.errorIN.value = N_CONFIG * [0.0]
29  robot.taskJoint.task.controlGain.value = 100
30 
31  # --- CONTACTS
32  # define contactLF and contactRF
33  robot.contactLF = MetaTaskKine6d(
34  "contactLF", robot.dynamic, "LF", robot.OperationalPointsMap["left-ankle"]
35  )
36  robot.contactLF.feature.frame("desired")
37  robot.contactLF.gain.setConstant(100)
38  robot.contactLF.keep()
39  locals()["contactLF"] = robot.contactLF
40 
41  robot.contactRF = MetaTaskKine6d(
42  "contactRF", robot.dynamic, "RF", robot.OperationalPointsMap["right-ankle"]
43  )
44  robot.contactRF.feature.frame("desired")
45  robot.contactRF.gain.setConstant(100)
46  robot.contactRF.keep()
47  locals()["contactRF"] = robot.contactRF
48 
49  robot.sot = SOT("sot")
50  robot.sot.setSize(robot.dynamic.getDimension())
51  plug(robot.sot.control, robot.device.control)
52 
53  robot.sot.push(robot.contactRF.task.name)
54  robot.sot.push(robot.contactLF.task.name)
55  robot.sot.push(robot.taskJoint.task.name)
56  robot.device.control.recompute(0)
57 
58  plug(robot.traj_gen.x, robot.taskJoint.featureDes.errorIN)
59  sleep(1.0)
60  os.system("rosservice call /start_dynamic_graph")
61  sleep(1.0)
62  robot.traj_gen.move(QJOINT, -1.0, 1.0)
63  sleep(1.1)
64  robot.traj_gen.startSinusoid(QJOINT, 1.0, 8.0)
65  sleep(10.0)
66  robot.traj_gen.stop(QJOINT)
create_entities_utils
sot_talos_balance.test.test_singleTraj.main
def main(robot)
Definition: test_singleTraj.py:17
sot_talos_balance.create_entities_utils.create_config_trajectory_generator
def create_config_trajectory_generator(dt, robot)
Definition: create_entities_utils.py:102