Inverted pendulum is a classic case of automatic control theory or analysis of modern control theory, several blog posts blog and analysis of topics given in this case:
Data in this chapter inverted pendulum realized in ROS2 trolley system as an example, is described in detail.
Why use inverted pendulum in real-time demo of it?
Inverted pendulum balance is one of the classic examples of real-time calculation is usually addressed by control problems. If the controller is blocked for too long, the pendulum will drop or become unstable. However, if the controller running control over motor speed pendulum faster surely updated, the pendulum will respond successfully to balance the pendulum sensor data.
This is a demanding real-time control of the scene!
Installation Notes:
The need to ensure ROS2 Dashing such as the installation is complete, and configured 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
Example run Description:
Terminal 1: Start the pendulum pendulum_bringup
ros2 launch pendulum_bringup pendulum_bringup.launch.py
Terminal 2: Boot Manager pendulum_manager
ros2 run pendulum_manager pendulum_manager
Terminal 3: Start three-dimensional visualization 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
If all goes well, you can see the pendulum:
You can use topic, node, service, rqt commands were reviewed.
Basic Course Reference Links: ROS2 zero-based Quick Start
If you want to learn Gazebo simulation, reference: Gazebo and ROS2 instructions for use
Detailed tutorial will gradually supplement.
Then open a new terminal, the input setting position command, so that the inverted pendulum carriage in position 0:
ros2 topic pub -1 /pendulum_setpoint pendulum_msgs_v2/msg/PendulumCommand "cart_position: 0.0"
Location +4:
ros2 topic pub -1 /pendulum_setpoint pendulum_msgs_v2/msg/PendulumCommand "cart_position: 4.0"
Location-3:
ros2 topic pub -1 /pendulum_setpoint pendulum_msgs_v2/msg/PendulumCommand "cart_position: -3.0"
In addition to location settings, and other inputs also supportive, self-study and research.
ros2 topic pub -1 /pendulum_setpoint pendulum_msgs_v2/msg/PendulumCommand "cart_position: -5.0"
ros2 topic pub -1 /pendulum_disturbance pendulum_msgs_v2/msg/PendulumCommand "cart_force: 100"
节点管理
演示中使用的主要节点是/pendulum_controller和/pendulum_driver。 也就是说,它们从生命周期节点继承,可以控制节点状态。
所有配置和内存分配必须在onConfigure转换中完成。 在活动状态下,所有计算都应实时兼容。 目前可能还不完全正确,但这是目标。
创建包pendulum_manager的目的是为了更轻松地控制节点的状态。 这个软件包还处于初期,其想法是使这个软件包成为带有控制面板的rqt插件。
只是为了好玩,可以尝试在仿真处于活动状态时停用控制器节点,以查看摆锤的下落。
更多介绍,后续补充……