control-toolbox + ct_ros 安装与示例使用教程

注意事项

  • 此教程针对ubuntu+ros+catkin用户

基础环境

  • ubuntu 18.04
  • ros melodic

依赖

  • clang
sudo apt-get update 
sudo apt-get install clang
  • clang-format
sudo apt-get install clang-format
  • Doxygen
sudo apt-get install doxygen
  • Eigen 3
sudo apt-get install libeigen3-dev
  • boost
sudo apt-get install libboost-all-dev
  • Ipopt & Snopt
sudo apt-get install ros-melodic-ifopt
  • cppad
git clone https://github.com/coin-or/CppAD.git cppad.git
cd cppad.git
mkdir build
cd build
cmake ..
make -j8
sudo make install
  • cppadcogen
git clone https://github.com/joaoleal/CppADCodeGen.git CppADCodeGen
mkdir cppadcg-build
cd cppadcg-build
cmake ../CppADCodeGen
sudo make install
  • blasfeo
git clone https://github.com/giaf/blasfeo.git
cd blasfeo

将blasfeo根目录下的CMakeLists.txt修改为如下形式,以生成动态库

# build shared library
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries")
mkdir build
cd build
cmake …
make
sudo make install
sudo sh -c "echo '/opt/blasfeo/lib/' >> /etc/ld.so.conf"
sudo ldconfig
  • hpipm
git clone https://github.com/giaf/hpipm.git
cd hpipm

将hpipm根目录下的CMakeLists.txt修改为如下形式,以生成动态库

# build shared library
set(BUILD_SHARED_LIBS ON CACHE STRING "Build shared libraries")
mkdir build
cd build
cmake …
make
sudo make install
sudo sh -c "echo '/opt/hpipm/lib/' >> /etc/ld.so.conf"
sudo ldconfig

安装

拉取代码

cd ~/your_catkin_workspace/src
git clone https://github.com/ANYbotics/kindr.git
git clone https://github.com/ethz-adrl/control-toolbox.git
git clone https://github.com/ethz-adrl/ct_ros.git

代码调整

control-toolbox

  • 按照如下代码调整to-your-control-toolbox/ct_models/CMakeLists.txt
if(NOT TARGET ${ct_rbd})
	find_package(ct_rbd REQUIRED)
endif()
find_package(Boost REQUIRED system filesystem)

find_package(blasfeo QUIET)
find_package(hpipm QUIET)

# extract interface compile definitions from previous ct packages as options
importInterfaceCompileDefinitionsAsOptions(ct_core)
importInterfaceCompileDefinitionsAsOptions(ct_optcon)
importInterfaceCompileDefinitionsAsOptions(ct_rbd)
  • 按照如下代码调整to-your-control-toolbox/ct_optcon/CMakeLists.txt
if(blasfeo_FOUND AND hpipm_FOUND)
    message(STATUS "Found HPIPM and BLASFEO")
    set(HPIPM ON)
    list(APPEND HPIPM_LIBS hpipm blasfeo)
    list(APPEND ct_optcon_COMPILE_DEFINITIONS HPIPM)
    list(APPEND blasfeo_INCLUDE_DIRS /opt/blasfeo/include)
    list(APPEND hpipm_INCLUDE_DIRS /opt/hpipm/include)
else()
    message(WARNING "Could not find HPIPM or BLASFEO")
endif()
  • 按照如下代码调整to-your-control-toolbox/ct_rbd/include/ct/rbd/systems/FixBaseFDSystem.h
const ct::core::ControlVector<BASE::NJOINTS> torqueRef = this->computeIDTorques(jStateRef);

ct_ros

若仅需要control-toolbox则可以不执行本小节内容

  • 按照如下代码调整to-your-ct_ros/ct_ros_nodes/CMakeLists.txt

开启hyq示例程序编译

option(BUILD_HYQ_FULL "Compile all examples for HyQ (takes long, should use clang)" on)

加载blasfeo和hpipm库

# after SET(CMAKE_CXX_FLAGS ...)
find_package(blasfeo)
find_package(hpipm)  

开启倒立摆示例程序编译

add_executable(InvertedPendulumNLOC examples/InvertedPendulum/InvertedPendulumNLOC.cpp)
target_link_libraries(InvertedPendulumNLOC ${catkin_LIBRARIES} ct_models)

add_executable(InvertedPendulumNLOC_actDyn examples/InvertedPendulum/InvertedPendulumNLOC_actDyn.cpp)
target_link_libraries(InvertedPendulumNLOC_actDyn ${catkin_LIBRARIES} ct_models)

开启HyANLOC_ObstacleAcc示例程序编译

option(CPPADCG "Compile HyANLOC_ObstacleAcc example" on)
if(CPPADCG)
  add_executable(HyANLOC_ObstacleAcc examples/HyA/HyANLOC_ObstacleAcc.cpp)
  target_link_libraries(HyANLOC_ObstacleAcc ${catkin_LIBRARIES} ct_ros_visualization ct_models)
endif()

编译

cd ~/your_catkin_workspace
catkin build -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=true

上述编译步骤耗时约15min(i5-10210U+16G RAM)

示例运行

control-toolbox

ex_NLOC_boxConstrained

cd ~/your_catkin_workspace
source ~/.bashrc
source devel/setup.bash
rosrun ct_optcon ex_NLOC_boxConstrained

结果
在这里插入图片描述

ct_ros

hya_nloc_example

cd ~/your_catkin_workspace
source ~/.bashrc
source devel/setup.bash
roslaunch ct_ros_nodes hya_nloc_example.launch

结果
在这里插入图片描述

invertedPendulum_actDyn

cd ~/your_catkin_workspace
source ~/.bashrc
source devel/setup.bash
roslaunch ct_ros_nodes invertedPendulum_actDyn.launch

结果
在这里插入图片描述

链接

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值