当前位置: 首页 > 工具软件 > ControlTool > 使用案例 >

Control Toolbox 学习过程

满才
2023-12-01

Control Toolbox 学习过程

Overview

Control Toolbox

  1. 这个库可以用于建模, 控制, 估计, 轨迹优化和模型预测控制.
  2. 可以对由微分方程或者差分方程表达的系统直接建模.intuitive modelling of systems governed by ordinary differential- or difference equations.
  3. 依赖 Eigen 和 Kindr 两个库.
  4. CT 的结构:
    1. 三个主要模块: The Core module (ct_core), the Optimal Control (ct_optcon) module and the rigid body dynamics (ct_rbd) module.
    2. ct_core: 提供通用的数据类型定义和数学工具,比如:数据类型定义,系统定义,控制器定义,数值积分
    3. ct_optcon: 依赖于ct_core, 增加了用于定义和解决最佳控制问题的基础架构, 能够定义损失函数, 约束条件, 求解器后端, 和一个同用的 MPC 封装.
    4. ct_rbd: 刚体动力学建模工具,
    5. 还有一个额外的包 ct_models: 包含各种机器人模型,包括四足机器人,机械臂,普通四旋翼和带有倾斜负载的四旋翼.
  5. CT Core

fatal error: Python.h: No such file or directory #include <Python.h>

解决方案:

  1. 在CmakeLists.txt文件里面添加
    find_package(PythonLibs REQUIRED)
    include_directories(${PYTHON_INCLUDE_DIRS})
    target_link_libraries( ${PYTHON_LIBRARIES})

无法加载matplotlib

退出anaconda的工作环境,在CMakeLists.txt文件里面添加
include_directories(/usr/include/python3.6)
include_directories(/usr/lib/python3/dist-packages/matplotlib)

target_link_libraries(ct_plot ${ct_core_LIBS} /home/sjtuer/anaconda3/lib/libstdc++.so.6
/usr/lib/x86_64-linux-gnu/libboost_python-py36.so
/usr/lib/x86_64-linux-gnu/libpython3.6m.so)

安装编译过程:

安装blasfeo

git clone https://github.com/giaf/blasfeo.git;
cd blasfeo
mkdir build
cd build
cmake …
make
sudo make install

再安装 hpipm

git clone https://github.com/giaf/hpipm.git
cd hpipm
mkdir build
cd build
cmake …
make
sudo make install

从git上面直接clone下来的ct源码是基于ROS 1.0的,为了在ROS 2.0里面能够正常编译且可以用ros2run启动节点,需要的修改内容:

在每个package的package.xml文件里面,将

ct_core里面

<package format="3">
  <name>ct_core</name>
  <version>3.0.2</version>
  <description>
    Control toolbox - core module.
  </description>
  <author>Markus Giftthaler</author>
  <author>Michael Neunert</author>
  <author>Markus Stäuble</author>
  <maintainer email="markusgft@gmail.com">Markus Giftthaler</maintainer>
  <license>BSD-2</license>

  <buildtool_depend>ament_cmake</buildtool_depend>
  <depend>eigen</depend>
  <!-- <exec_depend>catkin</exec_depend>  ROS compatibility -->

  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>

  <export>    <!-- Specify that this is not a ROS package-->
    <build_type>ament_cmake</build_type>
  </export>
</package>

ct_doc里面:

<package format="3">
  <name>ct_doc</name>
  <version>3.0.2</version>
  <description>
    Control toolbox - Documentation
  </description>

  <maintainer email="markusgft@gmail.com">Markus Giftthaler</maintainer>

  <license>BSD-2</license>

  <buildtool_depend>ament_cmake</buildtool_depend>

  <depend>ct_core</depend>
  <depend>ct_optcon</depend>
  <depend>ct_rbd</depend>
  <depend>ct_models</depend>

  <!-- <exec_depend>catkin</exec_depend>  ROS compatibility -->

  <export>    <!-- Specify that this is not a ROS package-->
    <build_type>ament_cmake</build_type>
  </export>

</package>

ct_models里面:

<package format="3">
	<name>ct_models</name>
	<version>3.0.2</version>
	<description>
        Control toolbox - models module.
	</description>

	<maintainer email="markusgft@gmail.com">Markus Giftthaler</maintainer>

	<license>BSD-2</license>

	<buildtool_depend>ament_cmake</buildtool_depend>

	<depend>ct_rbd</depend>
	<!-- <exec_depend>catkin</exec_depend>	ROS compatibility -->

	<export>		<!-- Specify that this is not a ROS package-->
		<build_type>ament_cmake</build_type>
	</export>
</package>

ct_optcon里面:

<package format="3">
  <name>ct_optcon</name>
  <version>3.0.2</version>
  <description>
    Control toolbox - optcon module.
  </description>
  <license>BSD-2</license>

  <author>Markus Giftthaler</author>
  <author>Michael Neunert</author>
  <author>Markus Stäuble</author>
  <maintainer email="markusgft@gmail.com">Markus Giftthaler</maintainer>

  <buildtool_depend>ament_cmake</buildtool_depend>
  <depend>ct_core</depend>

  <!-- <exec_depend>catkin</exec_depend>  ROS compatibility -->

  <export>    <!-- Specify that this is not a ROS package-->
    <build_type>ament_cmake</build_type>
  </export>
</package>

ct_rbd里面:

<package format="3">
  <name>ct_rbd</name>
  <version>3.0.2</version>
  <description>
    Control toolbox - rbd module.
  </description>
  <license>BSD-2</license>
  
  <author>Markus Giftthaler</author>
  <author>Michael Neunert</author>
  <maintainer email="markusgft@gmail.com">Markus Giftthaler</maintainer>

  <buildtool_depend>ament_cmake</buildtool_depend>
  <depend>ct_optcon</depend>
  <depend>kindr</depend>

  <!-- <exec_depend>catkin</exec_depend>  ROS compatibility -->

  <export>    <!-- Specify that this is not a ROS package-->
    <build_type>ament_cmake</build_type>
  </export>
</package>

CMakeLists.txt文件里面

添加

find_package(ament_cmake REQUIRED)
ament_package()

添加后编译可能会报错,有些包提示找不到ct_core,这个时候在将对应报错的包的ament_package()注释掉,然后再编译一边就可以了.

 类似资料: