赞
踩
人形机器人移动的基础在于双足直立行走,而在真实环境下进行试验迭代,需要昂贵的硬件设备和较长的迭代周期,因此仿真试验环境显得尤为重要。在仿真环境下确定大致方向后,再进行实物试验,可以节约成本、缩短迭代周期。本文将介绍Hector Simulation双足机器人仿真环境的搭建和模拟。(操作系统:Ubuntu20.04;ros版本:noetic(gazebo11);底层架构:x86_64)
安装依赖
sudo apt-get install ros-noetic-controller-manager ros-noetic-ros-control ros-noetic-ros-controllers ros-noetic-joint-state-controller ros-noetic-effort-controllers ros-noetic-velocity-controllers ros-noetic-position-controllers ros-noetic-robot-controllers ros-noetic-robot-state-publisher ros-noetic-gazebo-ros-pkgs ros-noetic-gazebo-ros-control
下载源码并编译
- cd ~
- git clone https://github.com/DRCL-USC/Hector_Simulation.git
- mkdir -p ~/catkin_ws/src
- mkdir -p ~/catkin_ws/scripts
- cp ~/Hector_Simulation/Hector_ROS_Simulation/* ~/catkin_ws/src
- cd ~/catkin_ws
- catkin_make
- # 如果是首次编译,则加上下列参数
- # catkin_make -DCMAKE_BUILD_TYPE=Release
编译过程中可能遇到报错,是没有安装lcm包导致的,安装好再编译就不会出错了
- In file included from /home/wangml71/catkin_ws/src/hector_control/src/../include/common/../interface/../sdk/include/unitree_legged_sdk/unitree_legged_sdk.h:12,
- from /home/wangml71/catkin_ws/src/hector_control/src/../include/common/../interface/CmdPanel.h:38,
- from /home/wangml71/catkin_ws/src/hector_control/src/../include/common/DesiredCommand.h:15,
- from /home/wangml71/catkin_ws/src/hector_control/src/../include/common/ControlFSMData.h:4,
- from /home/wangml71/catkin_ws/src/hector_control/src/main.cpp:7:
- /home/wangml71/catkin_ws/src/hector_control/src/../include/common/../interface/../sdk/include/unitree_legged_sdk/lcm.h:9:10: fatal error: lcm/lcm-cpp.hpp: No such file or directory
- 9 | #include <lcm/lcm-cpp.hpp>
- | ^~~~~~~~~~~~~~~~~
- compilation terminated.
解决方案
- cd ~
- git clone https://github.com/lcm-proj/lcm.git
- cd lcm
- mkdir build
- cd build
- cmake ..
- make -j4
- sudo make install
加入环境变量
- vim ~/.bashrc
-
- #在.bashrc文件末尾添加下列代码
- source /opt/ros/noetic/setup.bash
- source /usr/share/gazebo-11/setup.sh
- source ~/catkin_ws/devel/setup.bash
- export ROS_PACKAGE_PATH=~/catkin_ws:${ROS_PACKAGE_PATH}
- export GAZEBO_PLUGIN_PATH=~/catkin_ws/devel/lib:${GAZEBO_PLUGIN_PATH}
- export LD_LIBRARY_PATH=~/catkin_ws/devel/lib:${LD_LIBRARY_PATH}
使能环境变量
source ~/.bashrc
运行测试
- #打开一个终端,运行下列代码
- roslaunch unitree_gazebo biped.launch
- # 另起一个终端,运行下列代码
- rosrun hector_control hector_ctrl
在gazebo仿真界面单击启动按钮,则可以看到机器人开始运行
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。