Hi, I found, for example in the Python interface the function set_motor_position_kp
and set_motor_position_kp
. But I also found this thread saying that the driver does not support setting p and d. So I am bit confused if the BrickPi has built-in PID support or not. Thanks.
My comment in that thread is outdated, and has now been edited. You can indeed use set_motor_position_kp
and set_motor_position_kp
to set the P and D constants (kp and kd). The default values for kp and kd of 25 and 70 respectively are hard-coded in the firmware, but kd and kp can be adjusted with the python drivers as needed.
The BrickPi3 supports PD motor control for running motors to a specific position. Similar to PID, just without the I
part (unnecessary for this application). The default kp and kd constants of 25 and 70 respectively are well suited for a large majority of applications with NXT and EV3 motors.
This documentation comment explains in simple terms the effects of adjusting kp and kd.
The BrickPi3 uses PD to control the position of a motor. You can specify a target position, and the BrickPi3 will run the motor to the target position. BrickPi3 also supports speed control, where you can specify a target speed (for example 200 degrees per second). With speed control, the firmware uses the same algorithm as with position control, and essentially just keeps adjusting the target position. For example, with a speed target of 200 dps, every 10ms the firmware will add 2 degrees to the target position. The result of a moving position target is that the motor will have an instant and average speed of nearly exactly the speed specified.
Do you have an application where the default kp and kd values are not suitable? If so, I’d like to hear about it.