You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
3.4 KiB
93 lines
3.4 KiB
import numpy as np
|
|
from zmp_controller.TrajectoryGenerator import create_multiple_trajectory
|
|
import time
|
|
from zmp_controller.ikine import IKineQuadruped
|
|
|
|
|
|
class Action8():
|
|
def __init__(self,
|
|
freq=300,
|
|
kinematic_scheme='x',
|
|
ef_init_x=0.149,
|
|
ef_init_y=0.13,
|
|
cog_offset_x=0.0,
|
|
cog_offset_y=0.0,
|
|
robot_height=0.17,
|
|
kp=[12, 12, 12],
|
|
kd=[0.1, 0.1, 0.1]):
|
|
|
|
self.freq = freq
|
|
self.kinematic_scheme = kinematic_scheme
|
|
self.ef_init_x = ef_init_x
|
|
self.ef_init_y = ef_init_y
|
|
self.cog_offset_x = cog_offset_x
|
|
self.cog_offset_y = cog_offset_y
|
|
self.robot_height = robot_height
|
|
self.max_kp = np.array(kp[:3])
|
|
self.max_kd = np.array(kd[:3]) + [0.4, 0.4, 0.4]
|
|
|
|
self.finished = False
|
|
self.cur_joint_pos = np.array([0.0]*12)
|
|
self.ref_joint_pos = np.array([0.0]*12)
|
|
self.ref_joint_vel = np.array([0.0]*12)
|
|
self.ref_joint_torq = np.array([0.0]*12)
|
|
self.ref_joint_kp = np.array([0.0]*12)
|
|
self.ref_joint_kd = np.array([0.0]*12)
|
|
|
|
self.ik = IKineQuadruped(theta_offset=[0, -np.pi/2, 0])
|
|
|
|
self.start_time = int(time.time()*1000.0)
|
|
|
|
self.all_theta_refs = [[], [], [], [], [], [], [], [], [], [], [], []]
|
|
self.all_vel_refs = [[], [], [], [], [], [], [], [], [], [], [], []]
|
|
self.all_torq_refs = [[], [], [], [], [], [], [], [], [], [], [], []]
|
|
self.all_kp_refs = [[], [], [], [], [], [], [], [], [], [], [], []]
|
|
self.all_kd_refs = [[], [], [], [], [], [], [], [], [], [], [], []]
|
|
|
|
# print(self.max_kp)
|
|
|
|
def is_finished(self):
|
|
return self.finished
|
|
|
|
def set_cur_joint_pos(self, cur_pos):
|
|
self.cur_joint_pos = cur_pos[:]
|
|
|
|
def get_ref_joint_pos(self):
|
|
return self.ref_joint_pos, self.ref_joint_vel, self.ref_joint_torq, self.ref_joint_kp, self.ref_joint_kd
|
|
|
|
def reset(self):
|
|
self.all_theta_refs = [[], [], [], [], [], [], [], [], [], [], [], []]
|
|
self.all_vel_refs = [[], [], [], [], [], [], [], [], [], [], [], []]
|
|
self.all_torq_refs = [[], [], [], [], [], [], [], [], [], [], [], []]
|
|
self.all_kp_refs = [[], [], [], [], [], [], [], [], [], [], [], []]
|
|
self.all_kd_refs = [[], [], [], [], [], [], [], [], [], [], [], []]
|
|
|
|
def step(self, it):
|
|
self.ref_joint_pos = []
|
|
self.ref_joint_vel = [0]*12
|
|
self.ref_joint_torq = [0]*12
|
|
self.ref_joint_kp = []
|
|
self.ref_joint_kd = []
|
|
|
|
if it >= len(self.all_theta_refs[0]):
|
|
finished = True
|
|
for i in range(12):
|
|
self.ref_joint_pos.append(self.all_theta_refs[i][-1])
|
|
self.ref_joint_kp.append(self.all_kp_refs[i][-1])
|
|
self.ref_joint_kd.append(self.all_kd_refs[i][-1])
|
|
else:
|
|
finished = False
|
|
for i in range(12):
|
|
self.ref_joint_pos.append(self.all_theta_refs[i][it])
|
|
self.ref_joint_kp.append(self.all_kp_refs[i][it])
|
|
self.ref_joint_kd.append(self.all_kd_refs[i][it])
|
|
|
|
# print(self.ref_joint_kp[0])
|
|
|
|
return finished, self.ref_joint_pos, self.ref_joint_vel, self.ref_joint_torq, self.ref_joint_kp, self.ref_joint_kd
|
|
|
|
def execute(self):
|
|
# Put your code here
|
|
pass
|
|
|
|
# Put your functions below |