sot-talos-balance  2.0.5
Collection of dynamic-graph entities aimed at implementing balance control on talos.
test_param_server.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-1
3 from dynamic_graph import plug
4 from dynamic_graph.sot.core import SOT
5 from dynamic_graph.sot.core.meta_tasks_kine import MetaTaskKine6d, MetaTaskKineCom
7  create_com_trajectory_generator,
8  create_example,
9  create_parameter_server,
10 )
11 from dynamic_graph.sot_talos_balance.utils.sot_utils import Bunch
12 
13 
15  import dynamic_graph.sot_talos_balance.talos.control_manager_conf as param_server
16 
17  conf = Bunch()
18  conf.param_server = param_server
19  return conf
20 
21 
22 def main(robot, conf=None):
23  if conf is None:
24  conf = get_default_conf()
25  robot.timeStep = robot.device.getTimeStep()
26  dt = robot.timeStep
27  NJ = robot.dimension - 7
28  robot.comTrajGen = create_com_trajectory_generator(dt, robot)
29 
30  # --- COM
31  robot.taskCom = MetaTaskKineCom(robot.dynamic)
32  robot.dynamic.com.recompute(0)
33  robot.taskCom.featureDes.errorIN.value = robot.dynamic.com.value
34  robot.taskCom.task.controlGain.value = 10
35 
36  # --- CONTACTS
37  # define contactLF and contactRF
38  robot.contactLF = MetaTaskKine6d(
39  "contactLF", robot.dynamic, "LF", robot.OperationalPointsMap["left-ankle"]
40  )
41  robot.contactLF.feature.frame("desired")
42  robot.contactLF.gain.setConstant(100)
43  robot.contactLF.keep()
44  locals()["contactLF"] = robot.contactLF
45 
46  robot.contactRF = MetaTaskKine6d(
47  "contactRF", robot.dynamic, "RF", robot.OperationalPointsMap["right-ankle"]
48  )
49  robot.contactRF.feature.frame("desired")
50  robot.contactRF.gain.setConstant(100)
51  robot.contactRF.keep()
52  locals()["contactRF"] = robot.contactRF
53 
54  # --- SOT
55  robot.sot = SOT("sot")
56  robot.sot.setSize(robot.dynamic.getDimension())
57  plug(robot.sot.control, robot.device.control)
58 
59  robot.sot.push(robot.contactRF.task.name)
60  robot.sot.push(robot.taskCom.task.name)
61  robot.sot.push(robot.contactLF.task.name)
62  robot.device.control.recompute(0)
63 
64  # --- ENTITIES
65  robot.param_server = create_parameter_server(conf.param_server, dt)
66  robot.example = create_example()
67 
68  # --- RUN SIMULATION
69  # plug(robot.comTrajGen.x, robot.taskCom.featureDes.errorIN);
70  # sleep(1.0);
71  # os.system("rosservice call \start_dynamic_graph")
72  # sleep(2.0);
73  # robot.comTrajGen.move(1,-0.025,4.0);
74  # sleep(5.0);
75  # robot.comTrajGen.startSinusoid(1,0.05,8.0);
76  # sleep(1.0)
77  # robot.example.nbJoints.recompute(1)
78  # outputs the number of joints of the robot thanks to a pointer to the RobotUtil
79  # created in parameter server
80  # print(robot.example.nbJoints.value)
create_entities_utils
sot_talos_balance.test.test_param_server.get_default_conf
def get_default_conf()
Definition: test_param_server.py:14
sot_talos_balance.create_entities_utils.create_com_trajectory_generator
def create_com_trajectory_generator(dt, robot)
Definition: create_entities_utils.py:120
sot_talos_balance.create_entities_utils.create_parameter_server
def create_parameter_server(conf, dt, robot_name="robot")
Definition: create_entities_utils.py:619
sot_talos_balance.test.test_param_server.main
def main(robot, conf=None)
Definition: test_param_server.py:22
sot_talos_balance.create_entities_utils.create_example
def create_example(robot_name="robot", firstAdd=0.0, secondAdd=0.0)
Definition: create_entities_utils.py:624