宇树go2 edu 调试指南记录

go2还在路上,先仿真

系统:ubuntu18.04
cpp

1.安装宇树sdk2

  1. clone sdk2
cd /opt
sudo mkdir unitree_robotics
cd unitree_robotics
sudo git clone https://github.com/unitreerobotics/unitree_sdk2.git
cd unitree_sdk2
sudo mkdir build
cmake .. -DCMAKE_INSTALL_PREFIX=/opt/unitree_robotics

cmake指定make install时的安装目录:通过设置 CMAKE_INSTALL_PREFIX 的值来控制

编译完成后 显示如下界面
在这里插入图片描述

sudo make install

问题

错误1:

编译到4%报错

Scanning dependencies of target test_publisher
[  1%] Building CXX object example/helloworld/CMakeFiles/test_publisher.dir/publisher.cpp.o
[  3%] Building CXX object example/helloworld/CMakeFiles/test_publisher.dir/HelloWorldData.cpp.o
[  4%] Linking CXX executable ../../bin/test_publisher
../../../lib/x86_64/libunitree_sdk2.a(log_initor.cpp.o):在函数‘unitree::common::Exception::ToString[abi:cxx11]() const’中:
log_initor.cpp:(.text._ZNK7unitree6common9Exception8ToStringB5cxx11Ev[_ZNK7unitree6common9Exception8ToStringB5cxx11Ev]+0x38):对‘std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()’未定义的引用
../../../lib/x86_64/libunitree_sdk2.a(dds_factory_model.cpp.o):在函数‘void unitree::common::Logger::Log<char const (&) [36], unsigned int&>(int, char const (&) [36], unsigned int&)’中:
dds_factory_model.cpp:(.text._ZN7unitree6common6Logger3LogIJRA36_KcRjEEEviDpOT_[_ZN7unitree6common6Logger3LogIJRA36_KcRjEEEviDpOT_]+0x88):对‘std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()’未定义的引用
../../../lib/x86_64/libunitree_sdk2.a(dds_factory_model.cpp.o):在函数‘void unitree::common::Logger::Log<char const (&) [36]>(int, char const (&) [36])’中:
dds_factory_model.cpp:(.text._ZN7unitree6common6Logger3LogIJRA36_KcEEEviDpOT_[_ZN7unitree6common6Logger3LogIJRA36_KcEEEviDpOT_]+0x81):对‘std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()’未定义的引用
/opt/unitree_robotics/unitree_sdk2/thirdparty/lib/x86_64/libddscxx.so:对‘std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream()@GLIBCXX_3.4.26’未定义的引用
collect2: error: ld returned 1 exit status
example/helloworld/CMakeFiles/test_publisher.dir/build.make:121: recipe for target 'bin/test_publisher' failed
make[2]: *** [bin/test_publisher] Error 1
CMakeFiles/Makefile2:381: recipe for target 'example/helloworld/CMakeFiles/test_publisher.dir/all' failed
make[1]: *** [example/helloworld/CMakeFiles/test_publisher.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

查看gcc 和g++版本,发现gcc版本是7.5.0

(base) yfzx@yfzx-Z390-D:/opt/unitree_robotics/unitree_sdk2/build$ gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

(base) yfzx@yfzx-Z390-D:/opt/unitree_robotics/unitree_sdk2/build$ g++ --version
g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

查看文档需求gcc版本为9.4.0
升级gcc版本到9.4.0 升级
升级完成后,查看版本确认为9.4.0
在这里插入图片描述

错误2

[ 72%] Building CXX object example/g1/CMakeFiles/g1_dex3_example.dir/dex3/g1_dex3_example.cpp.o
/opt/unitree_robotics/unitree_sdk2/example/g1/dex3/g1_dex3_example.cpp:14:10: fatal error: eigen3/Eigen/Dense: 没有那个文件或目录
   14 | #include <eigen3/Eigen/Dense>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
example/g1/CMakeFiles/g1_dex3_example.dir/build.make:82: recipe for target 'example/g1/CMakeFiles/g1_dex3_example.dir/dex3/g1_dex3_example.cpp.o' failed
make[2]: *** [example/g1/CMakeFiles/g1_dex3_example.dir/dex3/g1_dex3_example.cpp.o] Error 1
CMakeFiles/Makefile2:948: recipe for target 'example/g1/CMakeFiles/g1_dex3_example.dir/all' failed
make[1]: *** [example/g1/CMakeFiles/g1_dex3_example.dir/all] Error 2
Makefile:149: recipe for target 'all' failed
make: *** [all] Error 2

找不到Eigen库头文件


解决: 运行
sudo apt-get install libeigen3-dev

在这里插入图片描述
再次编译,成功!

2. mujoco 安装

mujoco版本为:3.2.8

sudo apt install libglfw3-dev libxinerama-dev libxcursor-dev libxi-dev

依次运行

git clone https://github.com/google-deepmind/mujoco.git
mkdir build && cd build
cmake ..
make -j4
sudo make install

在这里插入图片描述

3. 安装yaml-cpp

sudo apt install libyaml-cpp-dev

4. 编译 unitree_mujoco中simulate

cd simulate/
mkdir build && cd build
cmake ..
make -j4

问题

[ 84%] Building CXX object CMakeFiles/unitree_mujoco.dir/src/main.cc.o
In file included from /usr/include/yaml-cpp/node/iterator.h:13,
                 from /usr/include/yaml-cpp/node/impl.h:11,
                 from /usr/include/yaml-cpp/yaml.h:17,
                 from /home/yfzx/project/robot_dog_go2/unitree_mujoco/simulate/src/main.cc:33:
/usr/include/yaml-cpp/node/detail/iterator.h: In member function ‘void YAML::detail::iterator_base<V>::increment()’:
/usr/include/yaml-cpp/node/detail/iterator.h:48:54: error: ‘next’ is not a member of ‘boost’
   48 |   void increment() { this->base_reference() = boost::next(this->base()); }
      |                                                      ^~~~
/usr/include/yaml-cpp/node/detail/iterator.h:48:54: note: suggested alternatives:
In file included from /usr/include/c++/9/bits/stl_algobase.h:66,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from /home/yfzx/project/robot_dog_go2/unitree_mujoco/simulate/src/main.cc:20:
/usr/include/c++/9/bits/stl_iterator_base_funcs.h:213:5: note:   ‘std::next’
  213 |     next(_InputIterator __x, typename
      |     ^~~~
In file included from /usr/local/include/boost/mpl/next.hpp:17,
                 from /usr/local/include/boost/mpl/bind.hpp:25,
                 from /usr/local/include/boost/mpl/lambda.hpp:18,
                 from /usr/local/include/boost/mpl/apply.hpp:25,
                 from /usr/local/include/boost/iterator/iterator_facade.hpp:36,
                 from /usr/include/yaml-cpp/node/detail/node_iterator.h:12,
                 from /usr/include/yaml-cpp/node/detail/iterator.h:12,
                 from /usr/include/yaml-cpp/node/iterator.h:13,
                 from /usr/include/yaml-cpp/node/impl.h:11,
                 from /usr/include/yaml-cpp/yaml.h:17,
                 from /home/yfzx/project/robot_dog_go2/unitree_mujoco/simulate/src/main.cc:33:
/usr/local/include/boost/mpl/next_prior.hpp:29:8: note:   ‘boost::mpl::next’
   29 | struct next
      |        ^~~~
CMakeFiles/unitree_mujoco.dir/build.make:160: recipe for target 'CMakeFiles/unitree_mujoco.dir/src/main.cc.o' failed
make[2]: *** [CMakeFiles/unitree_mujoco.dir/src/main.cc.o] Error 1
make[2]: *** 正在等待未完成的任务....
[ 92%] Linking CXX executable test
[ 92%] Built target test
CMakeFiles/Makefile2:99: recipe for target 'CMakeFiles/unitree_mujoco.dir/all' failed
make[1]: *** [CMakeFiles/unitree_mujoco.dir/all] Error 2
Makefile:103: recipe for target 'all' failed
make: *** [all] Error 2

make时报错, 报yaml没有next

解决方法:

/usr/include/yaml-cpp/node/detail/iterator.h 文件中,增加头文件#include <boost/next_prior.hpp>
在这里插入图片描述
再次make 成功
在这里插入图片描述
运行 ./unitree_mujoco,成功
在这里插入图片描述


在新的终端 运行 ./test, 会输出机器人在仿真器中的姿态和位置信息,同时机器人的每个电机都会持续输出 1Nm 的转矩。

在这里插入图片描述
在这里插入图片描述

5.编译unitree_mujoco中example

运行命令

cd unitree_mujoco/example/cpp
mkdir build
cd build
cmake ..
make -j4

编译完成后,显示

在这里插入图片描述
运行./stand_go2, 效果如下
在这里插入图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值