# cartpole_nmpc **Repository Path**: craipy/cartpole_nmpc ## Basic Information - **Project Name**: cartpole_nmpc - **Description**: 使用ocs2实现的cartpole控制 - **Primary Language**: Unknown - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 6 - **Forks**: 2 - **Created**: 2023-11-09 - **Last Updated**: 2025-02-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 简介 这是一个使用 [ocs2](https://github.com/leggedrobotics/ocs2.git) 优化控制框架完成的 倒立摆模型的控制。包括普通的倒立摆运动控制和控制倒立摆达到指定的稳定状态。 目前实现了 一阶倒立摆,二阶倒立摆和三阶倒立摆。在完成了一阶倒立摆之后花了2个小时完成了二阶倒立摆,二阶倒立摆到三阶倒立摆的控制仅仅花了十几分钟。 ### 视频 一阶倒立摆视频:[一阶倒立摆](https://www.bilibili.com/video/BV13P4y1k7oH) 二阶倒立摆视频:[二阶倒立摆](https://www.bilibili.com/video/BV1dG4y1k72A) 三阶倒立摆视频:[三阶倒立摆](https://www.bilibili.com/video/BV1GY41197Pd) ## 安装 主要使用的是 ocs2 优化控制框架,需要先安装 ocs2。安装过程见 [ocs2安装](https://leggedrobotics.github.io/ocs2/installation.html#installation) 创建一个ros的工作空间 以 `~/project/catkin_ws` 为例 ```bash # 创建工作空间 mkdir -p ~/project/catkin_ws/src cd ~/project/catkin_ws/src # clone ocs2 git clone https://github.com/leggedrobotics/ocs2.git # clone pinocchio git clone --recurse-submodules https://github.com/leggedrobotics/pinocchio.git # clone hpp-fcl git clone --recurse-submodules https://github.com/leggedrobotics/hpp-fcl.git # clone ocs2_robotic_assets git clone https://github.com/leggedrobotics/ocs2_robotic_assets.git # install dependencies sudo apt install liburdfdom-dev liboctomap-dev libassimp-dev sudo apt install doxygen doxygen-latex ``` 使用`catkin tool`代替 `catkin_make` 编译此包 需要安装 `catkin tool` ```bash sudo apt install python3-catkin-tools ``` ## 编译 ```bash catkin config -DCMAKE_BUILD_TYPE=RelWithDebInfo catkin build cartpole_gazebo_ros ``` ## 运行 ```bash roslaunch cartpole_gazebo_ros gazebo.launch ```