File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-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+ imu_attitude = robot .imu .attitude_euler
19+ positions = robot .joints .positions
20+ velocities = robot .joints .velocities
21+
22+ # Compute the PD control on the zero position.
23+ torques = kp * (des_pos - positions ) - kd * velocities
24+
25+ robot .joints .set_torques (torques )
26+ robot .send_command_and_wait_end_of_cycle (0.001 )
27+
28+ c += 1
29+
30+ if c % 1000 == 0 :
31+ print ("joint pos: " , positions )
32+ print ("joint vel: " , velocities )
33+ print ("torques: " , torques )
34+ robot .robot_interface .PrintStats ()
35+
36+ print ("timeout detected" )
You can’t perform that action at this time.
0 commit comments