MIT License

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

深度技术分析:Teddy-Liao/walk-these-ways-go2

项目背景与痛点

Unitree Go2 是一款在市场上关注度很高的机器人平台,其灵活性和可定制性使其成为众多开发者和研究者的首选。然而,对于很多开发者来说,直接操作硬件或者编写固件会遇到较大的技术壁垒。walk-these-ways-go2 项目正好针对这个痛点,它为开发者提供了一个完整的软件栈,用于部署在 Unitree Go2 机器人上,使得用户能够更加专注于应用程序本身而非底层硬件的配置和优化。

核心技术揭秘

架构设计

walk-these-ways-go2 项目采用了分层的设计模式,分别对驱动层、控制层和应用层进行了细粒度的划分。每一层之间通过 API 进行解耦,保证了系统的灵活性和可扩展性。下面是项目的核心架构图:

graph TD A[用户接口] --> B("应用程序控制") B --> C{"控制算法决策"} C -->|"决策通过"| E[动作指令生成] C -->|"决策失败"| F{"调试日志记录"} E --> G{"驱动指令生成"} G -->|"指令生成"| H("串行通信") H --> I[硬件驱动] I --> J[传感器读取] J --> K("数据处理") K --> L[状态更新] L --> M("数据展示")

关键技术栈及实现原理

  • 驱动层:提供与硬件交互的接口,包括传感器和执行器的数据读写,通过标准化的 API 减少开发者的负担。
  • 控制层:包括了控制算法的部分,例如姿态稳定器、步态规划器等,通过这一层把高级抽象的控制需求转化为具体的动作指令。
  • 应用层:开放了丰富的 API,使开发人员能够基于这些 API 编写自定义的应用或者进行科研工作。比如,通过 API 获得传感器数据并计算出步态,然后把结果下发给控制层进行执行。

功能亮点与差异

相比市场上同类竞品,walk-these-ways-go2 通过以下几个方面有所创新:

  • 高灵活性的 API 设计:项目的接口设计清晰而灵活,允许开发者按需调整功能,而不必受制于现成的“黑箱”模式。
  • 丰富的文档支持:良好的开发者文档和社区支持,提供了详细的安装指南、代码示例和常见问题解答,减少了项目入门和调试的时间成本。

应用场景与落地建议

对于开发者来说,walk-these-ways-go2 项目适用于各种科研和商业应用场景,无论是机器人巡检、仓库自动化还是健康护理等领域,都有较大的应用潜力。不过在实际部署时需要注意硬件兼容性和维护问题:

  • 硬件兼容性:确保机器人的硬件设备是兼容的,特别是传感器和通讯接口这一类细节。
  • 兼容的固件版本:固件和硬件版本兼容性是实现系统性稳定的关键,务必关注固件的更新动态。

综合评价

优点

  • 技术架构合理:清晰的分层设计和灵活的 API 使得该项目具有高度的可拓展性和可维护性。
  • 社区支持:丰富的文档支持和活跃的社区带来了良好的用户体验,降低了上手门槛。

缺点

  • 初期调试难度:面对新手开发者而言,深入了解每个层级的原理和调试可能需要一定的学习曲线。
  • 硬件依赖:项目高度依赖于硬件的兼容性,硬件设施更换时需要进行额外的适配工作。

总的来看,walk-these-ways-go2 项目提供了一个强大的基础框架,不仅为开发者节约了大量时间,也为机器人应用的普及和创新提供了一个良好的起点。

关于

GitHub 原始描述(英文)

Deploy walk-these-ways project on Unitree Go2

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
1358
价值分
446
活跃状态
活跃

语言占比

C
C++
CMake
Makefile
Python
Shell

贡献者

README

Sim-to-Real project on Unitree Go2

Overview

This repository is forked from walk-these-ways, which is a Go1 Sim-to-Real Locomotion Starter Kit. It seems that walk-these-ways can be untilized on Unitree A1 with simple modifications, since those robots are base on unitree-legged-sdk.

However, the brand-new architecture unitree-sdk2 is not based on UDP anymore, so this project aims to train and deploy walk-these-ways on Unitree Go2 by modifying SDK interfaces.

Requirements

  • miniconda
  • pytorch 1.10 with cuda-11.3
  • Isaac Gym
  • Nvidia GPU with at least 8GB of VRAM

Train and Play

Clone this repository and install:

git clone https://github.com/Teddy-Liao/walk-these-ways-go2.git
cd walk-these-ways-go2
pip install -e .

Start training:

python scripts/train.py

go2_gym and go2_gym_learn folders are the main folders for training process.

Play the model:

cd scripts
python play.py

Alt text

Go2 pretrained model is provided in ./runs, you can choose whether to use provide pretrained model by modifying the label line label = "gait-conditioned-agility/pretrain-go2/train" to your own trained model.

Known Issues

  • flip_visual_attachments in go2_config should be set to True, otherwise errors would occur when visualizing.
  • To change configuration parameters of env or the robot, you should modify parameters in go2_config, not in legged_robot_config

Deploy on PC

Trained policy is only supported to be deployed through your PC or laptop now, because I am not familiar with Jetson Orin, and hope I can fix it and deploy on Jetson Orin.

Requirements

Install LCM

Since walk-these-ways implement an interface based on Lightweight Communications and Marshalling (LCM) to pass sensor data, motor commands, and joystick state between their code and the low-level control SDK provided by Unitree, LCM should be installed firstly in your PC or laptlop.

Clone LCM repository to any location (where you usually place installed softwares), then install LCM:

git clone https://github.com/lcm-proj/lcm.git
mkdir build
cd build
cmake ..
make
sudo make install
Unitree_SDK2

unitree_sdk2 has been inclued in go2_gym_deploy/unitree_sdk2_bin/library/unitree_sdk2, you can also clone from Unitree Robotics to make sure the sdk is updated version.

cd go2_gym_deploy/unitree_sdk2_bin/library/unitree_sdk2

Delete build file

rm -r build

Install and build:

sudo ./install.sh
mkdir build
cd build
cmake ..
make

Build lcm_position_go2

go2_gym_deploy/unitree_sdk2_bin/lcm_position_go2.cpp is the core file of this project, which is similar to lcm_position.cpp in walk-these-ways, but replace unitree_legged_sdk with unitree_sdk2.

Build lcm_position_go2 and generate runfile lcm_position_go2

cd go2_gym_deploy
rm -r build
mkdir build
cd build
cmake ..
make -j

All LCM messages files in go2_gym_deploy/lcm_types are set as the same format shown in walk-these-ways to ensure successful connection with python files. LCM message files are provided in this project, and you can also generate customized LCM message files through the following instructions:

xxx_lcmt.hpp files are generated by:

lcm-gen -x xxx.lcm

Verify connection

Connect your PC/Laptop with Go2 robot with ethernet cable and check connection by:

ping 192.168.123.161

Check the network interface address, and copy the network interface address.

ifconfig

If error occurs, please check Unitree Support for details.

Test communication between LCM and unitree_sdk2

You can verify LCM send by opening a new terminal:

cd go2_gym_deploy/build
sudo ./lcm_receive

If LCM and unitree_sdk2 are correctly connected with each other, messages will be shown in the terminal:

Alt text

Start LCM

Before starting LCM, ensure that lcm_receive has been properly shut down. It’s important not to run lcm_receive and lcm_position_go2 simultaneously.

cd go2_gym_deploy/build
sudo ./lcm_position_go2 eth0

Replace eth0 with your own network interface address. According to the messages shown in terminal, press Enter for several times and the communication between LCM and unitree_sdk2 will set up.

This command will automatically shut down Unitree sport_mode Service and set the robot to LOW-LEVEL. Please make sure This will Go2 is hung up or lie on the ground.

Load and run policy

Open a new terminate and run:

cd go2_gym_deploy/scripts
python deploy_policy.py

According to the hints shown in terminal, Press button [R2] to start the controller. You can check RC mapping in the following subsection.

Joystick Mapping

Joystick Mapping

To view the details of joystick mapping or even modify default mapping logic, please refer to the get_command function within the cheetah_state_estimator.py file. In this project, the default gait is set to trot.

Caution:

  • Press [L2+B] to switch to damping mode if any unexpected situation occurs!!!
  • This is research code; use at your own risk; we do not take responsibility for any damage.

Test Video on Unitree Go2:


Deploy on Nvidia Jetson Orin

The Unitree Go2 robot is equipped with an onboard Nvidia Jetson Orin Nano/NX, which operates on an ARM-based architecture. Default information of this onboard computer is shown below, and you can connnect to Jetson by SSH, VScode(remote development) or plugging a HDMI cable.

IP:192.168.123.18
user name:unitree
password:123

Requirements for Jetson

  • cuda
  • pytorch
  • miniconda (Omitted here; please install it by yourself)
  • cudnn (Omitted here; please install it by yourself)

Two different ways are provided to set up correct environments in Jetson: through Internet or through Docker.

Through Internet

Connecting a Nvidia Jetson device to the internet can be done in two primary ways:

  1. Wired Connection: Directly plug an Ethernet cable with internet access into the Jetson’s Ethernet port. This method provides a stable and fast internet connection, suitable for tasks that require high bandwidth or low latency.

  2. Wireless Connection via USB Wi-Fi Adapter: Purchase a USB Wi-Fi adapter compatible with the Jetson device. This method adds wireless connectivity, offering the flexibility to connect to the internet without the need for physical cables. However, it’s important to ensure the USB Wi-Fi adapter is supported by the Jetson’s operating system and drivers.

Check Jetpack Version

Jetpack toolbox has been preinstalled on Jetson, you should check the jetpack vertsion firstly.

sudo -H pip install jetson-stats  #Install jetson-stats toolkit
sudo jtop

According to the detail information printed in the terminal window, the Jetpack version of my Unitree Go2 is Jetpack 5.1.1 [L4T 35.3.1]

You can also check libraries that have been preinstalled:

sudo jetson_release
Install cuda for jetson

Check if there is a preinstalled version of cuda.

nvcc -V # check preinstalled cuda version

If the preinstalled version if too high, you should uninstall it because, for instance, there is no Pytorch version that is compatible with cuda-12.2.

sudo apt-get remove cuda
sudo apt autoremove 
sudo apt-get remove cuda*
sudo dpkg -l |grep cuda # check if any residual cuda file exists
sudo dpkg -P Residual filename

Personally, I recommend to install cuda-11.8. Click the link, CUDA Toolkit 11.8 Downloads , to check installation commands.

Install Pytorch for Jetson

Please download pre-built PyTorch pip wheel installers for Jetson Nano, which is different from the way we install Pytorch on PC. Note that correct pytorch version should be chosen to make it compatible with specific version of cuda and Jetpack.

Run codes without cable

As long as the environment and requirements on the Jetson are properly configured, you can follow the same deployment guidelines as you would on a PC. This liberates the robot! Now, you can test the code cable-free, offering more freedom to the robot’s movements and applications.

Through Docker

To be continue …


🌟🌟🌟 Please star this repository if it does help you! Many Thanks! 🌟🌟🌟


Acknowledgements

  • Many thanks to Leolar, who provide Nvidia 3060ti and supporting.
  • Many thanks to Jony and Peter for their support and encourage me to learn basic kownledge about RL.
  • Many thanks to Simonforyou, who provide Go2 pretrained model.

TO DO

  • Do not inherit config and env from go1_gym, build customized config and env files for Go2
  • Deploy on Jeston Orin Nano
  • Deploy through Docker

评论

暂无评论