来自地平线上的四足机器人第一期-前期准备

地平线RDK套件概述

Horizon Robotics Developer Kits,简称地平线RDK套件,是基于地平线智能芯片打造的机器人开发者套件,包括RDK X3(旭日X3派)、RDK X3 Module(旭日X3模组)。

产品介绍

RDK X3(旭日X3派) 是一款全功能开发板,具备强大的处理能力和丰富的外设接口,通过搭配丰富的传感器和扩展组件,为开发者提供了灵活的硬件扩展和连接选项。

RDK X3 Module(旭日X3模组) 是一款紧凑型核心模组,与RDK X3保持了同等规格,并在尺寸、接口上兼容树莓派CM4模组。通过搭配扩展板,可以为各种应用场景提供高效的计算和通信能力。

实物图片

产品规格

RDK X3

RDK X3 Module开发套件

CPU

Quad-core ARM® Cortex® A53@1.5G

BPU

Dual-core Bernoulli Arch, ~5Tops

内存

2GB/4GB LPDDR4 RAM

存储

16G/32G/64G eMMC or Micro SD

多媒体

H.265 (HEVC) Encoding and Decoding Main profile, L5.1 4K@60fpsH.264 Encoding and Decoding Baseline/Main/High profiles, L5.1 4k@60fps.JPEG Encoding and Decoding 16MpixelsCBR, VBR, AVBR, FixQp and QpMap bitrate control

Sensor接口

1 x 4-lane MIPI CSI2 x 2-lane MIPI CSI

USB接口

1 x USB3.0

4 x USB 3.0 type A,host mode1 x Micro USB 2.0,device mode

Debug串口

1 x UART,Debug串口

1 x Micro USB 2.0,UART转USB

显示接口

1 x HDMI 1.4 (up to 1080p60 )1 x MIPI-DSI (up to 1080p60)

无线网络接口

WiFi/Bluetooth二合一模块(可选)WiFi 2.4GHz/5GHz、Bluetooth 4.2

有线网络接口

1 x GPHY

1 x RJ45接口

其他IO

32 x GPIOs:3 x UART、2 x SPI、2 x I2S、4 x I2C、PWM等

40PIN(UART、SPI、I2S、I2C、PWM、GPIO)6 x 控制使能脚1 x GPIO_VREF1 x PWM风扇接口1 x RTC接口

电源输入

5V 3A

12V 2A

系统支持

Ubuntu 20.04

Go1机器狗介绍

•全球首款消费级伴随仿生四足机器人,最快奔跑速度4.7m/s(17km/h,接近专业长跑运动员速度),打破近似规格世界纪录

ISS 智能伴随系统,专利无线矢量定位及控制技术

SSS 超感知系统,5组鱼眼双目深度感知+鱼眼AI感知+3组超声波

内置超级AI算力,16核顶级CPU+ GPU(384Core,1.5TFLOPS)-

unitree_legged_sdk

The unitree_legged_sdk is mainly used for communication between PC and Controller board. It also can be used in other PCs with UDP.

Notice:

support robot: Go1

前期准备

供电

由于没有及时备件,所以采取外部电源供电的方案,RDK X3 Module开发套件电源输入12V 2A。

远程登陆

为了解决能够同事远程登陆,以及外部联网安装依赖的需求,使用自带的网口与自己电脑连接,使用usb转网口的拓展坞作为外部联网。

  • 有线以太网:开发板默认采用静态IP模式,IP地址为192.168.1.10,掩码255.255.255.0,网关 192.168.1.1配置完之后远程登陆直接使用以下命令。

    ssh root@192.168.1.10
    

    远程密码是root

外部联网自动分配ip:

系统更新

/etc/apt/source.list文件中,保存了apt命令的软件源列表,在安装软件前,需要先通过apt命令更新package列表。

首先打开终端命令行,输入如下命令:

sudo apt update

其次,升级所有已安装的软件包到最新版本,命令如下:

sudo apt full-upgrade

注意,推荐使用full-upgrade而不是upgrade选项,这样当相关依赖发生变动时,也会同步更新依赖包。

当运行sudo apt full-upgrade命令时,系统会提示数据下载和磁盘占用大小,但是apt不会检查磁盘空间是否充足,建议用户通过df -h命令手动检查。此外,升级过程中下载的deb文件会保存在/var/cache/apt/archives目录中,用户可以通过sudo apt clean命令删除缓存文件以释放磁盘空间。

执行apt full-upgrade命令后,可能会重新安装驱动、内核文件和部分系统软件,建议用户手动重启一下设备使更新生效,命令如下:

sudo reboot

摘自官方文档

常见问题

  1. 在系统更新小节之中,我们可以发现命令之中带有sudo,但是在实际测试发现板卡自带的测试系统没有开放sudo权限,解决方法有两个:

    一:重刷系统,具体步骤可以参考官方文档 安装系统

    二:查找资料发现可以使用下面命令重新吧sudo权限开启,记住必须远程登录root用户系统

    chmod 644 /usr/lib/sudo/sudoers.so
    chown -R root /usr/lib/sudo
    chown root:root /etc/sudoers
    chown -R root:root /etc/sudoers.d
    chmod u=rwx,g=rx,o=rx /etc/sudoers.d/
    chmod u=r,g=r,o= /etc/sudoers.d/*
    

    继续更新中

机器狗sdk移植编译

基本配置

官方sdk下载链接,本次项目使用了Go1机器狗产品,所以需要使用版本3.8.6.

unitree_legged_sdk 本身封装python接口需要在CMakeLists.txt文件中将python接口开启

找到代码

option(PYTHON_BUILD "build python wrapper" OFF)
if(PYTHON_BUILD)
  add_subdirectory(python_wrapper)
endif()

将off改为ON之后,

编译

cd unitree_legged_sdk
mkdir build
cd build
cmake ..
make

由于开启python接口,一般会遇到一个错误,如下

常见错误

fatal error: msgpack.hpp: No such file or directory #include <msgpack.hpp>

这是缺少一个序列库,

安装即可。

sudo apt install libmsgpack*

unitree_legged_sdk 部分高层api解释

HighCmd结构体中主要的控制命令

uint8_t mode

0

Idle.

1

Standing, in force control.

2

Walking, following target velocity.

3

Walking, following target position, reserve for future release.

4

Walking, following a given path, reserve for future release.

5

Stand down, in position control.

6

Stand up, in position control.

7

Damping mode, all motors.

8

Recovery mode.

9

backflip

10

jumpYaw

11

straightHand

12

dance1

13

dance2

uint8_t gaitType

0

Idle.

1

Trot walking.

2

Trot running.

3

Stairs climbing.

4

Trot obstacle.

uint8_t speedLevel

0

Default low speed.

1

Default medium speed.

2

Default high speed.

SpeedLevel setting is now only used for mode 3.

floatfootRaiseHeight(unit: m)

Swing foot height adjustment from default swing height.delta valuedefault: 0.08m

floatbodyHeight(unit: m)

Body height adjustment from default body height.delta valuedefault: 0.28m

floatposition[2](unit: m)

Desired x and y position in the inertial frame, which is established at the beginning instance of the sport mode. Position setting is used in mode 3 as target position.

floateuler[3](unit: rad)

Desired yaw-pitch-roll Euler angle, with euler[0] = Roll,euler[1] = Pitch,euler[2] = Yaw.RPY setting can be used in mode 1 as target orientation.Yaw setting can be used in mode 3 as target yaw angle.

float velocity[2](unit: m/s)

Desired robot forward speed and side speed in the body frame. Velocity setting is used in mode 2 as target linear velocity.

float yawSpeed(unit: rad/s)

Desired rotational yaw speed. YawSpeed setting is used in mode 2 as target rotational speed.

Go1 SDK HighCmd mode

mode

state

controlled by

previous mode

mode 0

Idle.

none

all mode

mode 1

Standing, in force control.

euler, bodyHeight

mode 2 6

mode 2

Walking, following target velocity.

velocity+yawSpeed, bodyHeight, footRaiseHeight

mode 1

mode 3

Walking, following target position.

reserve for future release

mode 1

mode 4

Walking, following a given path, reserve for future release.

reserve for future release

mode 1

mode 5

Stand down, in position control.

none

mode 6 7

mode 6

Stand up, in position control.

none

mode 1 5

mode 7

Damping mode, all motors.

none

all mode

mode 8

Recovery mode.

none

mode 7

HighCmd变量初始化

HighCmd结构体变量,申请变量后需要初始化变量(主要是其中的标志位变量初始化),可以使用udp.InitCmdData(&HighCmd highcmd)函数来实现。如图所示,初始化之后可以正常使用。

Go1 SDK HighState

HighState结构体中有效的状态反馈

head

包头

levelFlag

高层模式、底层模式标志位;0x00为高层,0xff为底层

frameReserve

保留位

SN

SN码

version

版本信息

bandWidth

保留位

IMU imu

惯导信息,参考2.2 Go1 SDK HighState IMU

MotorStatemotorState[20]

电机数据,20个MotorState结构体数组,其中前12个有效,各个电机的编号可以参考quadruped.hMotorState结构体参考2.4 MotorState

int16_t footForce[4]

足端传感器数值,触地检测。这个值是飘的,每个气囊的值不一样,需要实际测试,通常是通过变化量来检测是否触地。

int16_t footForceEst[4]

估计的足端力,单位应该是N

uint8_t mode

参考1.1 HighCmd中mode的注释

float progress

保留位

uint8_t gaitType

参考1.1 HighCmd中gaitType的注释

float footRaiseHeight(unit: m)

行走时的抬腿高度,默认0.08m

float bodyHeight(unit: m)

机身高度,默认0.28m

float position[3](unit: m)

机器人的位置坐标反馈,通过机器人在惯性系(世界坐标系)中里程计的数据获得的位置坐标,会漂移position[0] = xposition[1] = yposition[2] = z

float velocity[3](unit: m/s)

机器人在各个方向的速度反馈velocity[0] = forwardSpeedvelocity[1] = sideSpeedvelocity[2] = updownSpeed

float yawSpeed(unit: rad/s)

机器人的旋转速度

float rangeObstacle[4]

避障数据

Cartesian footPosition2Body[4](unit: m)

足端相对于身体的位置(机身坐标系)footPosition2Body[0] = 右前腿足端的位置footPosition2Body[1] = 左前腿足端的位置footPosition2Body[2] = 右后腿足端的位置footPosition2Body[3] = 左后腿足端的位置

Cartesian footSpeed2Body[4](unit: m/s)

足端相对于身体的速度(机身坐标系)footSpeed2Body[0] = 右前腿足端的速度footSpeed2Body[1] = 左前腿足端的速度footSpeed2Body[2] = 右后腿足端的速度footSpeed2Body[3] = 左后腿足端的速度

uint8_t wirelessRemote[40]

遥控器键值的反馈,可参考提供的手柄例程源码

reserve

保留位

crc

校验位

Go1 SDK HighState IMU

float quaternion[4]

归一化的四元数quaternion[0] = w,quaternion[1] = x,quaternion[2] = y,quaternion[3] = z

float gyroscope[3](unit: rad/s)

陀螺仪,角速度,原始数据gyroscope[0] = x,gyroscope[1] = y,gyroscope[2] = z

float accelerometer[3](unit: m/s²)

加速度计,加速度,原始数据accelerometer[0] = x,accelerometer[1] = y,accelerometer[2] = z

float rpy[3](unit: rad)

欧拉角rpy[0] = Roll,rpy[1] = Pitch,rpy[2] = Yaw

int8_t temperature

IMU温度

在加速运动时,由 IMU 计算出的机器人姿态会发生漂移。