mirror of
https://github.com/apirrone/Open_Duck_Mini_Runtime.git
synced 2025-09-02 19:23:54 +00:00
update
This commit is contained in:
parent
489da82052
commit
5b72401055
3 changed files with 19 additions and 13 deletions
|
@ -109,6 +109,7 @@ class Imu:
|
|||
try:
|
||||
# imu returns scalar first
|
||||
raw_orientation = np.array(self.imu.quaternion).copy() # quat
|
||||
gyro = np.array(self.imu.gyro).copy() # gyro
|
||||
euler = (
|
||||
R.from_quat(raw_orientation, scalar_first=True)
|
||||
.as_euler("xyz")
|
||||
|
@ -126,23 +127,27 @@ class Imu:
|
|||
# gives scalar last, which is what isaac wants
|
||||
final_orientation_quat = R.from_euler("xyz", euler).as_quat()
|
||||
|
||||
self.imu_queue.put(final_orientation_quat.copy())
|
||||
self.imu_queue.put(
|
||||
{"orientation": final_orientation_quat.copy(), "gyro": gyro.copy()}
|
||||
)
|
||||
took = time.time() - s
|
||||
time.sleep(max(0, 1 / self.sampling_freq - took))
|
||||
|
||||
def get_data(self, euler=False, mat=False):
|
||||
def get_data(self, as_euler=False, as_mat=False):
|
||||
try:
|
||||
self.last_imu_data = self.imu_queue.get(False) # non blocking
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
if not euler and not mat:
|
||||
return self.last_imu_data
|
||||
elif euler:
|
||||
return R.from_quat(self.last_imu_data).as_euler("xyz")
|
||||
elif mat:
|
||||
return R.from_quat(self.last_imu_data).as_matrix()
|
||||
if as_euler:
|
||||
euler = R.from_quat(self.last_imu_data["orientation"]).as_euler("xyz")
|
||||
self.last_imu_data["orientation"] = euler
|
||||
elif as_mat:
|
||||
mat = R.from_quat(self.last_imu_data["orientation"]).as_matrix()
|
||||
self.last_imu_data["orientation"] = mat
|
||||
|
||||
return self.last_imu_data
|
||||
|
||||
except Exception as e:
|
||||
print("[IMU]: ", e)
|
||||
|
@ -156,6 +161,6 @@ if __name__ == "__main__":
|
|||
data = imu.get_data()
|
||||
# print(data)
|
||||
print("gyro", np.around(data["gyro"], 3))
|
||||
print("accelero", np.around(data["accelero"], 3))
|
||||
print("orientation", np.around(data["orientation"], 3))
|
||||
print("---")
|
||||
time.sleep(1 / 25)
|
||||
|
|
Binary file not shown.
|
@ -5,7 +5,8 @@ import numpy as np
|
|||
from mini_bdx_runtime.rustypot_position_hwi import HWI
|
||||
from mini_bdx_runtime.onnx_infer import OnnxInfer
|
||||
|
||||
from mini_bdx_runtime.raw_imu import Imu
|
||||
# from mini_bdx_runtime.raw_imu import Imu
|
||||
from mini_bdx_runtime.imu import Imu
|
||||
from mini_bdx_runtime.poly_reference_motion import PolyReferenceMotion
|
||||
from mini_bdx_runtime.xbox_controller import XBoxController
|
||||
from mini_bdx_runtime.feet_contacts import FeetContacts
|
||||
|
@ -159,7 +160,7 @@ class RLWalk:
|
|||
imu_data["accelero"],
|
||||
cmds,
|
||||
dof_pos - self.init_pos,
|
||||
dof_vel * 0.05,
|
||||
dof_vel * 0.1,
|
||||
self.last_action,
|
||||
self.last_last_action,
|
||||
self.last_last_last_action,
|
||||
|
@ -347,12 +348,12 @@ if __name__ == "__main__":
|
|||
required=False,
|
||||
default=f"{HOME_DIR}/duck_config.json",
|
||||
)
|
||||
parser.add_argument("-a", "--action_scale", type=float, default=0.25)
|
||||
parser.add_argument("-a", "--action_scale", type=float, default=1.0)
|
||||
parser.add_argument("-p", type=int, default=30)
|
||||
parser.add_argument("-i", type=int, default=0)
|
||||
parser.add_argument("-d", type=int, default=0)
|
||||
parser.add_argument("-c", "--control_freq", type=int, default=50)
|
||||
parser.add_argument("--pitch_bias", type=float, default=0, help="deg")
|
||||
parser.add_argument("--pitch_bias", type=float, default=-10, help="deg")
|
||||
parser.add_argument(
|
||||
"--commands",
|
||||
action="store_true",
|
||||
|
|
Loading…
Reference in a new issue