File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ import numpy as np
2
+
3
+ np .set_printoptions (suppress = True , precision = 2 )
4
+
5
+ import libodri_control_interface_pywrap as oci
6
+
7
+ robot = oci .robot_from_yaml_file ("config_testbench.yaml" )
8
+
9
+ des_pos = np .array ([np .pi / 2 , - np .pi / 2 ])
10
+
11
+ robot .initialize (des_pos )
12
+
13
+ kp , kd = 0.125 , 0.0025
14
+ c = 0
15
+ while not robot .is_timeout :
16
+ robot .parse_sensor_data ()
17
+
18
+ positions = robot .joints .positions
19
+ velocities = robot .joints .velocities
20
+
21
+ # Compute the PD control on the zero position.
22
+ torques = kp * (des_pos - positions ) - kd * velocities
23
+
24
+ robot .joints .set_torques (torques )
25
+ robot .send_command_and_wait_end_of_cycle (0.001 )
26
+
27
+ c += 1
28
+
29
+ if c % 1000 == 0 :
30
+ print ("joint pos: " , positions )
31
+ print ("joint vel: " , velocities )
32
+ print ("torques: " , torques )
33
+ robot .robot_interface .PrintStats ()
34
+
35
+ print ("timeout detected" )
You can’t perform that action at this time.
0 commit comments