【ROS2】PID motor control

1. Description

        I already had a fully functioning speed control class a few months ago, but I decided it had to do some major cleaning before I could demonstrate it here. In this post, I'll briefly explain how my motor control program is structured, then give some background on the control theory involved, and then I'll explain how that theory is implemented in real code.

        You can find source code and example sketches at github.com/1988kramer/motor_control .


2. Program structure

        I structured my program to mirror the hardware as closely as possible, so I created two classes, Motor and Encoder, to handle the low level functionality of the motor and encoder. The "Speed ​​Control" class uses the "Motor" and "Encoder" classes to precisely control the speed of the motor. See the figure below for a detailed description of the library structure.

        GDE Error: Error retrieving file - turn off error checking if necessary (404: Not Found)

        You'll notice in the diagram above that there are two classes that use SpeedControl's functionality: PositionControl and Differential Drive. PositionControl uses an instance of SpeedControl to provide position control functionality, and Differential Drive uses two instances of PositionControl to provide advanced control for differential drive robots like Colin.

        I'm just going to cover the SpeedControl class today, but you can expect posts on PositionControl and Differential Drive in the next few weeks.


3. Basic knowledge of control loop

        in my

Guess you like

Origin blog.csdn.net/gongdiwudu/article/details/131938516