ROS2实时性案例分析之倒立摆系统使用(Inverted pendulum)

倒立摆是自动控制原理或现代控制理论等经典分析案例,博客有数篇博文针对这样案例给出题目和分析:

本篇主要针对倒立摆小车在ROS2系统中的实现为例,进行详细介绍。


为什么选择使用倒立摆进行实时演示呢?

rviz2中倒立摆小车

平衡倒立摆是通常由实时计算解决的控制问题的经典示例之一。 如果控制器阻塞时间过长,摆锤将掉落或变得不稳定。 但是,如果控制器比控制摆锤的电动机运行的速度更快的速度可靠地更新,则摆锤将成功地对传感器数据做出反应平衡摆锤。

这是一个对实时性要求很高的控制场景!

安装说明:

需要确保ROS2 Dashing等安装完成,并配置好rosdep:

source /opt/ros/dashing/setup.bash
mkdir -p ~/pendulum_ws/src
cd ~/pendulum_ws/src
git clone https://github.com/ros2-realtime-demo/pendulum
cd ~/pendulum_ws
sudo rosdep init
rosdep update
rosdep install -q -y --from-paths src --ignore-src --rosdistro dashing
colcon build --merge-install # OR colcon build --symlink-install

示例运行说明:

终端1:启动倒立摆pendulum_bringup

ros2 launch pendulum_bringup pendulum_bringup.launch.py
初始化

终端2:启动管理器pendulum_manager

ros2 run pendulum_manager pendulum_manager
详细管理选项

终端3:启动三维可视化rviz2

export LC_NUMERIC="en_US.UTF-8" # Make sure that your locales are correctly setup.
ros2 run rviz2 rviz2 -d `ros2 pkg prefix pendulum_bringup --share`/config/pendulum.rviz
rviz2

如果一切正常,即可看到倒立摆:

倒立摆三维可视化界面

可以使用topic、node、service、rqt等命令进行复习。

rqt

基础课程参考链接:ROS2零基础快速入门

如果想要学习Gazebo仿真,参考:Gazebo和ROS2的使用说明

详细教程会逐步补充。

再开启一个新终端,输入设置位置命令,使倒立摆小车位于位置0:

ros2 topic pub -1 /pendulum_setpoint pendulum_msgs_v2/msg/PendulumCommand "cart_position: 0.0"
位置0

位置+4:

ros2 topic pub -1 /pendulum_setpoint pendulum_msgs_v2/msg/PendulumCommand "cart_position: 4.0"
位置4

位置-3:

ros2 topic pub -1 /pendulum_setpoint pendulum_msgs_v2/msg/PendulumCommand "cart_position: -3.0"
位置-3

除了位置设置,还支持力输入等,自行学习研究。

ros2 topic pub -1 /pendulum_setpoint pendulum_msgs_v2/msg/PendulumCommand "cart_position: -5.0"

position

ros2 topic pub -1 /pendulum_disturbance pendulum_msgs_v2/msg/PendulumCommand "cart_force: 100"

force

节点管理

演示中使用的主要节点是/pendulum_controller和/pendulum_driver。 也就是说,它们从生命周期节点继承,可以控制节点状态。

标题

所有配置和内存分配必须在onConfigure转换中完成。 在活动状态下,所有计算都应实时兼容。 目前可能还不完全正确,但这是目标。

创建包pendulum_manager的目的是为了更轻松地控制节点的状态。 这个软件包还处于初期,其想法是使这个软件包成为带有控制面板的rqt插件。

只是为了好玩,可以尝试在仿真处于活动状态时停用控制器节点,以查看摆锤的下落。

取消控制,摆下落

更多介绍,后续补充……


 

The “INVERTED PENDULUM, ANALYSIS, DESIGN AND IMPLEMENTATION” is a collection of MATLAB functions and scripts, and SIMULINK models, useful for analyzing Inverted Pendulum System and designing Control System for it. This report & MATLAB-files collection are developed as a part of practical assignment on Control System Analysis, Design & Development practical problem. The assigned problem of INVERTED PENDULUM is a part of Lab Work of Control System – III Course at the INSTITUTE OF INDUSTRIAL ELECTRONICS ENGINEERING (IIEE), KARACHI, PAKISTAN. The Inverted Pendulum is one of the most important classical problems of Control Engineering. Broom Balancing (Inverted Pendulum on a cart) is a well known example of nonlinear, unstable control problem. This problem becomes further complicated when a flexible broom, in place of a rigid broom, is employed. Degree of complexity and difficulty in its control increases with its flexibility. This problem has been a research interest of control engineers. Control of Inverted Pendulum is a Control Engineering project based on the FLIGHT SIMULATION OF ROCKET OR MISSILE DURING THE INITIAL STAGES OF FLIGHT. The AIM OF THIS STUDY is to stabilize the Inverted Pendulum such that the position of the carriage on the track is controlled quickly and accurately so that the pendulum is always erected in its inverted position during such movements. This practical exercise is a presentation of the analysis and practical implementation of the results of the solutions presented in the papers, “Robust Controller for Nonlinear & Unstable System: Inverted Pendulum” [3] and “Flexible Broom Balancing” [4], in which this complex problem was analyzed and a simple yet effective solution was presented. The details of these papers can be looked in the BIBLIOGRAPHY section.
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zhangrelay

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值