mirror of
https://github.com/apirrone/Open_Duck_Mini_Runtime.git
synced 2025-09-03 03:33:54 +00:00
- Added config file support to v2_rl_walk_mujoco.py
- Altered rustypot_position_hwi.py to accept offset parameters. - updated files that use HWI to include the offsets parameter. These currently do not use the config file data, but could do so if required. Possible example here is to use find_soft_offsets.py to fine tune positions by loading the config data to set the motors to their offset positions. - Added an example config json file. - Added config.json to ignore file to hopefully stop it getting checked in
This commit is contained in:
parent
b3cb137656
commit
8aa4b156b9
6 changed files with 135 additions and 25 deletions
|
@ -6,7 +6,7 @@ import rustypot
|
|||
|
||||
|
||||
class HWI:
|
||||
def __init__(self, usb_port="/dev/ttyACM0"):
|
||||
def __init__(self, offsets, usb_port="/dev/ttyACM0"):
|
||||
|
||||
# Order matters here
|
||||
self.joints = {
|
||||
|
@ -100,22 +100,7 @@ class HWI:
|
|||
# "right_knee": 0.002,
|
||||
# "right_ankle": -0.093,
|
||||
# }
|
||||
self.joints_offsets = {
|
||||
"left_hip_yaw" : 0.082,
|
||||
"left_hip_roll" : -0.089,
|
||||
"left_hip_pitch" : -0.004,
|
||||
"left_knee" : 0.077,
|
||||
"left_ankle" : -0.1,
|
||||
"neck_pitch" : 0.057,
|
||||
"head_pitch" : 0.069,
|
||||
"head_yaw" : -0.101,
|
||||
"head_roll" : 0.08,
|
||||
"right_hip_yaw" : -0.166,
|
||||
"right_hip_roll" : 0.115,
|
||||
"right_hip_pitch" : 0.089,
|
||||
"right_knee" : -0.098,
|
||||
"right_ankle" : -0.125
|
||||
}
|
||||
self.joints_offsets = offsets
|
||||
|
||||
init_pos_with_offsets = {
|
||||
joint: np.rad2deg(pos + self.joints_offsets[joint])
|
||||
|
|
|
@ -9,8 +9,7 @@ import time
|
|||
input(
|
||||
"Press any key to start. The robot will move to its zero position. Make sure it is safe to do so. At any time, press ctrl+c to stop, the motors will be turned off."
|
||||
)
|
||||
hwi = HWI()
|
||||
hwi.joints_offsets = {
|
||||
joints_offsets = {
|
||||
"left_hip_yaw": 0,
|
||||
"left_hip_roll": 0,
|
||||
"left_hip_pitch": 0,
|
||||
|
@ -27,6 +26,9 @@ hwi.joints_offsets = {
|
|||
"right_ankle": 0,
|
||||
}
|
||||
|
||||
hwi = HWI(joints_offsets)
|
||||
|
||||
|
||||
hwi.init_pos = hwi.zero_pos
|
||||
hwi.set_kds([0] * len(hwi.joints))
|
||||
hwi.turn_on()
|
||||
|
|
|
@ -18,7 +18,25 @@ antennas = Antennas()
|
|||
|
||||
eyes = Eyes()
|
||||
projector = Projector()
|
||||
hwi = HWI()
|
||||
|
||||
joints_offsets = {
|
||||
"left_hip_yaw": 0,
|
||||
"left_hip_roll": 0,
|
||||
"left_hip_pitch": 0,
|
||||
"left_knee": 0,
|
||||
"left_ankle": 0,
|
||||
"neck_pitch": 0,
|
||||
"head_pitch": 0,
|
||||
"head_yaw": 0,
|
||||
"head_roll": 0,
|
||||
"right_hip_yaw": 0,
|
||||
"right_hip_roll": 0,
|
||||
"right_hip_pitch": 0,
|
||||
"right_knee": 0,
|
||||
"right_ankle": 0,
|
||||
}
|
||||
|
||||
hwi = HWI(joints_offsets)
|
||||
|
||||
kps = [8] * 14
|
||||
kds = [0] * 14
|
||||
|
|
|
@ -1,4 +1,21 @@
|
|||
from mini_bdx_runtime.rustypot_position_hwi import HWI
|
||||
|
||||
hwi = HWI()
|
||||
joints_offsets = {
|
||||
"left_hip_yaw": 0,
|
||||
"left_hip_roll": 0,
|
||||
"left_hip_pitch": 0,
|
||||
"left_knee": 0,
|
||||
"left_ankle": 0,
|
||||
"neck_pitch": 0,
|
||||
"head_pitch": 0,
|
||||
"head_yaw": 0,
|
||||
"head_roll": 0,
|
||||
"right_hip_yaw": 0,
|
||||
"right_hip_roll": 0,
|
||||
"right_hip_pitch": 0,
|
||||
"right_knee": 0,
|
||||
"right_ankle": 0,
|
||||
}
|
||||
|
||||
hwi = HWI(joints_offsets)
|
||||
hwi.turn_off()
|
||||
|
|
|
@ -1,6 +1,23 @@
|
|||
from mini_bdx_runtime.rustypot_position_hwi import HWI
|
||||
import time
|
||||
|
||||
hwi = HWI()
|
||||
joints_offsets = {
|
||||
"left_hip_yaw": 0,
|
||||
"left_hip_roll": 0,
|
||||
"left_hip_pitch": 0,
|
||||
"left_knee": 0,
|
||||
"left_ankle": 0,
|
||||
"neck_pitch": 0,
|
||||
"head_pitch": 0,
|
||||
"head_yaw": 0,
|
||||
"head_roll": 0,
|
||||
"right_hip_yaw": 0,
|
||||
"right_hip_roll": 0,
|
||||
"right_hip_pitch": 0,
|
||||
"right_knee": 0,
|
||||
"right_ankle": 0,
|
||||
}
|
||||
|
||||
hwi = HWI(joints_offsets)
|
||||
hwi.turn_on()
|
||||
time.sleep(1)
|
||||
|
|
|
@ -3,6 +3,10 @@ import pickle
|
|||
|
||||
import numpy as np
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
from mini_bdx_runtime.rustypot_position_hwi import HWI
|
||||
from mini_bdx_runtime.onnx_infer import OnnxInfer
|
||||
|
||||
|
@ -78,13 +82,79 @@ class RLWalk:
|
|||
self.control_freq, cutoff_frequency
|
||||
)
|
||||
|
||||
self.hwi = HWI(serial_port)
|
||||
|
||||
|
||||
IMU_upside_down = False
|
||||
self.phase_frequency_factor_offset = 0.0
|
||||
|
||||
# Read config file
|
||||
print("Read Config")
|
||||
try:
|
||||
with open('config.json') as f:
|
||||
buf = f.read()
|
||||
config_data = json.loads(buf)
|
||||
print("Ok")
|
||||
f.close()
|
||||
except:
|
||||
# check file exists if it does'nt create an empty config.
|
||||
if os.path.isfile("config.json") == False:
|
||||
with open("config.json","w") as newFile:
|
||||
newFile.write("{\n")
|
||||
newFile.write(" ""start_paused"": false,\n")
|
||||
newFile.write(" ""imu_upside_down"": false,\n")
|
||||
newFile.write(" ""phase_frequency_factor_offset"": 0.0,\n")
|
||||
newFile.write(" ""left_hip_yaw"": 0.0,\n")
|
||||
newFile.write(" ""left_hip_roll"": 0.0,\n")
|
||||
newFile.write(" ""left_hip_pitch"": 0.0,\n")
|
||||
newFile.write(" ""left_knee"": 0.0,\n")
|
||||
newFile.write(" ""left_ankle"": 0.0,\n")
|
||||
newFile.write(" ""neck_pitch"": 0.0,\n")
|
||||
newFile.write(" ""head_pitch"": 0.0,\n")
|
||||
newFile.write(" ""head_yaw"": 0.0,\n")
|
||||
newFile.write(" ""head_roll"": 0.0,\n")
|
||||
newFile.write(" ""right_hip_yaw"": 0.0,\n")
|
||||
newFile.write(" ""right_hip_roll"": 0.0,\n")
|
||||
newFile.write(" ""right_hip_pitch"": 0.0,\n")
|
||||
newFile.write(" ""right_knee"": 0.0,\n")
|
||||
newFile.write(" ""right_ankle"": 0.0\n")
|
||||
newFile.write("}")
|
||||
newFile.close()
|
||||
print("Config not found, new config.json file created, aborting execution")
|
||||
print("Fill out config file with motor offsets using find_soft_offsets.py")
|
||||
sys.exit()
|
||||
|
||||
|
||||
joint_offsets = {
|
||||
"left_hip_yaw": config_data.get("left_hip_yaw"),
|
||||
"left_hip_roll": config_data.get("left_hip_roll"),
|
||||
"left_hip_pitch": config_data.get("left_hip_pitch"),
|
||||
"left_knee": config_data.get("left_knee"),
|
||||
"left_ankle": config_data.get("left_ankle"),
|
||||
"neck_pitch": config_data.get("neck_pitch"),
|
||||
"head_pitch": config_data.get("head_pitch"),
|
||||
"head_yaw": config_data.get("head_yaw"),
|
||||
"head_roll": config_data.get("head_roll"),
|
||||
"right_hip_yaw": config_data.get("right_hip_yaw"),
|
||||
"right_hip_roll": config_data.get("right_hip_roll"),
|
||||
"right_hip_pitch": config_data.get("right_hip_pitch"),
|
||||
"right_knee": config_data.get("right_knee"),
|
||||
"right_ankle": config_data.get("right_ankle")
|
||||
}
|
||||
|
||||
self.hwi = HWI(joint_offsets, serial_port)
|
||||
|
||||
IMU_upside_down = config_data.get("imu_upside_down")
|
||||
self.phase_frequency_factor_offset = config_data.get("phase_frequency_factor_offset")
|
||||
|
||||
|
||||
|
||||
# end Config load section
|
||||
self.start()
|
||||
|
||||
self.imu = Imu(
|
||||
sampling_freq=int(self.control_freq),
|
||||
user_pitch_bias=self.pitch_bias,
|
||||
upside_down=False,
|
||||
upside_down=IMU_upside_down,
|
||||
)
|
||||
|
||||
self.eyes = Eyes()
|
||||
|
@ -121,7 +191,7 @@ class RLWalk:
|
|||
|
||||
self.last_commands = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
|
||||
|
||||
self.paused = False
|
||||
self.paused = config_data.get("start_paused")
|
||||
|
||||
self.sounds = Sounds(volume=1.0, sound_directory="../mini_bdx_runtime/assets/")
|
||||
self.antennas = Antennas()
|
||||
|
@ -137,6 +207,7 @@ class RLWalk:
|
|||
self.phase_frequency_factor = 1.0
|
||||
self.phase_frequency_factor_offset = 0.0
|
||||
|
||||
|
||||
def add_fake_head(self, pos):
|
||||
# add just the antennas now
|
||||
assert len(pos) == self.num_dofs
|
||||
|
|
Loading…
Reference in a new issue