Skip to content

jayjayhust/open-duck-mini_diy_flow

Repository files navigation

Open Duck Mini手搓

源项目

本项目是对Open Duck Mini项目的DIY复现记录。

流程综述

placo(PlaCo is Rhoban's planning and control library):生成步态相关参数的库

  • placo安装可能碰到的问题(本质是因为pinocchio用的numpy 1.x的版本): Rhoban/placo#18
    # 假设我的源码仓库地址为:/home/jay/workspace/placo,python版本为3.10
    export PYTHONPATH="/home/jay/workspace/placo/build/lib/python3.10/site-packages:$PYTHONPATH"

Open Duck Reference Motion Generator:使用placo,生成polynomial_coefficients.pkl用于后续训练

  • Generate motions(This will write in a directory called recordings/
uv run scripts/auto_waddle.py (-j?) --duck ["go_bdx", "open_duck_mini", "open_duck_mini_v2"] (--num <> / --sweep) --output_dir <>

auto_waddle.py源码中看到加载的参数文件和文件夹有/open_duck_reference_motion_generator/robots/{args.duck}/auto_gait.json/open_duck_reference_motion_generator/robots/{args.duck}/placo_presets

auto_waddle.py源码中看到有调用/open_duck_reference_motion_generator/gait_generator.py去生成步态数据。gait_generator.py的处理核心逻辑是调用/open_duck_reference_motion_generator/placo_walk_engine.py的实例去计算和生成步态:pwe = PlacoWalkEngine(asset_path, robot_urdf, gait_parameters)gait_generator.py是一个命令行脚本,用来基于 PlacoWalkEngine 生成并记录一段机器人步态(motion)数据,然后把记录保存为 JSON 文件以供后续使用(例如播放、训练、分析等)。脚本会以固定采样率(FPS)轮询 PlacoWalkEngine,按帧收集机器人位姿、关节角、速度、脚部位置信息和支撑相(共55个参数:"root_pos": 3,"root_quat": 4,"joints_pos": 14,"left_toe_pos": 3,"right_toe_pos": 3,"world_linear_vel": 3,"world_angular_vel": 3,"joints_vel": 14,"left_toe_vel": 3,"right_toe_vel": 3,"foot_contacts": 2),并把这些帧序列写入一个包含元数据(参数、速度平均值等)的 JSON 文件。支持通过 meshcat(可选)做实时可视化,并支持若干命令行参数(preset、速度、时长、duck 类型等)。

auto_waddle.py源码中出现的脚本参数运行描述为:Generate AMP walking animations,其中AMP是Adversarial Motion Prior的缩写,是一种结合了对抗性学习和物理模拟的技术,主要用于生成自然和生动的物理角色动画。AMP通过一个训练好的判别器来指导策略学习,该判别器能够区分模拟角色的动作和参考运动数据集中的动作,从而为角色的动作提供风格奖励。这种方法不需要手动设计的模仿目标或者动作选择机制,也不需要对数据集进行任务特定的注释或分割‌。主要实现还是在gait_generator.py中。

  • Fit polynomials(This will generate polynomial_coefficients.pkl from data (in json files) in recordings/
uv run scripts/fit_poly.py --ref_motion recordings/

Open Duck Playground:训练和输出onnx模型(这一步是强化学习的关键步骤)

  • 添加一个新机器人,并进行配置和训练
    • Create a new directory in playground named after <your robot>. You can copy the open_duck_mini_v2 directory as a starting point.
    • Edit base.py: Mainly renaming stuff to match you robot's name
    • Edit constants.py: specify the names of some important geoms, sensors etc
      • In your mjcf, you'll probably have to add some sites, name some bodies/geoms and add the sensors. Look at how we did it for open_duck_mini_v2
    • Add your mjcf assets in xmls.
    • Edit joystick.py : to choose the rewards you are interested in
      • Note: for now there is still some hard coded values etc. We'll improve things on the way
    • Edit runner.py and then run it(mujoco will be lauched automatically?)
    # in Windows(unsuccessful)
    pip install uv
    uv venv -p 3.12
    uv run playground/<robot>/runner.py #这一步还是会报You're on Windows (`win_amd64`), but `jax-cuda12-plugin` (v0.6.1) only has wheels for the following platforms: `manylinux2014_aarch64`, `manylinux2014_x86_64`; consider adding your platform to `tool.uv.required-environments` to ensure uv resolves to a version with compatible wheels
    
    # wsl2(ubuntu 22.04.5)
    conda env list
    conda create -n mujoco python=3.11
    conda activate mujoco
    pip install mujoco -i https://mirrors.aliyun.com/pypi/simple/
    git clone https://github.com/apirrone/Open_Duck_Playground.git
    cd Open_Duck_Playground
    curl -LsSf https://astral.sh/uv/install.sh | sh
    uv run playground/open_duck_mini_v2/runner.py
    
    # in linux(suppose to be ok)
    uv run playground/<robot>/runner.py 
  • 在mujoco里跑onnx模型(即查看onnx模型)
uv run playground/open_duck_mini_v2/mujoco_infer.py -o <path_to_.onnx> (-k)

RL related stuff

  • Mujoco Playground
mujoco_rl.mp4
  • Reference motion generation for imitation learning
ref_motion_demo.mp4

Open Duck Mini Runtime:加载onnx模型,实物运行

  • onnx模型的实物加载使用:Run the walk
  • hardware
    • Raspberry Pi zero 2W
    • IMU: BNO055
    • Motor: Feetech 7.4v STS 3215
    • Charger: 2S2A(8.4V, 2A)
      • 输入电压:DC 3-6V(推荐DC 3.7V 5V)
      • 输入电流:1A(1A版);2A(2A版);4A(4A版)
      • 充电电压:8.4V
      • 充电电流:0.55A(1A版);1.1A(2A版);2.2A(4A版)
    • BMS: 7.4V(output)
      • When charger is connected on P+/P- port( and power switch is off), it's for battery charging
      • When charger is disconnected and power switch is on, it's for power output
    • Battery: 18650 x 2
  • OS: Raspberry Pi OS Lite (64-bit)

Windows 10 WSL2方式安装ROS2 Humble和gazebo(mujoco可以在windows直接安装)

Ubuntu 22.04.5安装Isaac Sim 4.5.0(直接上Isaac Sim 5.0 + Isaac Lab 2.2)

  • 硬件资源:RTX 5070ti 16G(NVIDIA-SMI:570.153.02,Driver version: 570.153.02,CUDA Version:12.8)
  • 软件环境:
    • 操作系统:Ubuntu 22.04.5 desktop
    • ROS2 Humble版本:小鱼ROS
    • gazebo版本:Gazebo Classic Simulator (ROS2 Humble),注意不是更新的Gazebo Harmonic Simulator (ROS2 Jazzy&Humble)版本
    • mujoco版本:3.3.3
    • Issac Sim及对应的Isaac Sim Assets版本:5.0
      • Isaac Lab版本:2.2
      # isaaclab install(https://isaac-sim.github.io/IsaacLab/main/source/setup/installation/pip_installation.html#installing-isaac-lab)
      conda create -n env_isaaclab python=3.11  # isaaclab 5.0 needs python 3.11
      conda activate env_isaaclab
      pip install --upgrade --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cu128
      ./isaaclab.sh --install  # cd isaaclab root directory
      source _isaac_sim/setup_conda_env.sh  # avoid ModuleNotFoundError: No module named 'isaacsim' error
      ./isaaclab.sh -p scripts/tutorials/00_sim/create_empty.py
      # or
      python scripts/tutorials/00_sim/create_empty.py
      ./isaaclab.sh -p scripts/reinforcement_learning/rsl_rl/train.py --task=Isaac-Ant-v0 --headless
  • issues:
    • GUI blur: Need to wait for the upgration of isaac sim (kit version should upper than 106.5.3, you can see the kit version in 'help'->'about'). You can try to upgrade issac sim from 4.5.0 to 5.0(not release the production version yet, you can build from github repository)?
    • saac Sim ROS Workspace
      • 先安装python 3.11
      • 执行./build_ros.sh -d humble -v 22.04可能下载有些包失败,直接修改对应的dockerfile(例如dockerfiles/ubuntu_22_humble_python_311_minimal.dockerfile),把python镜像源加入相应失败的下载指令后
    • ROS on Ubuntu 20.04, No module named 'rclpy._rclpy_pybind11':切换默认的python的版本
  • 脚本记录(Isaac Sim和ROS2互相通讯,用h1跑强化学习policy)
  # ros2 cmd init
  source /opt/ros/humble/setup.bash

  # ros2 cmd
  ros topic list

  ros2 run demo_nodes_cpp talker
  ros2 run demo_nodes_py listener

  # ros2 isaac sim workspace init(https://github.com/isaac-sim/IsaacSim-ros_workspaces)
  source /opt/ros/humble/setup.bash
  #cd repository/humble_ws, for example: ~/IsaacSim-ros_workspaces/humble_ws
  cd ~/IsaacSim-ros_workspaces/humble_ws
  source install/local_setup.bash
  # cd the h1_fullbody_controller ROS2 package and then run the ROS2 policy
  cd ~/IsaacSim-ros_workspaces/humble_ws/src/humanoid_locomotion_policy_example/h1_fullbody_controller/launch
  ros2 launch h1_fullbody_controller h1_fullbody_controller.launch.py # run the ROS2 policy
  • [Isaac Sim倒入]

其他

Issues记录

About

Open Mini Duck手搓流程记录

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors