The PID is for Proportional, Integral, Derivative. This is the coefficients used for the motor loopback.
Those coefs depend of your motors and your setup. You have to tune those values to have a stable position and speed on your setup.
Here is an article writen by @Simon with more complete explanations about it : https://medium.com/luosrobotics/an-introduction-to-pid-control-with-dc-motor-1fa3b26ec661
This is used to enable or not the motor. At startup the motor is disable so you can move it by hand freely so it comply to your hand => it is compliant. I think you have the same kind of thing on MisBkit but you don’t call it the same.
To resume :
- compliant = True => motor disable
- compliant = False => motor enable
So to make your motor move you have to disable compliant :
r.controlled_mot0.compliant = False
control mode ?
There is 3 way to control the movement of your motor :
power mode: This mode don’t use any feedback loop so no PID for this one you just control the power sent to the motor between -100.0% and 100.0%.
speed mode : This mode use feedback loop to maintain the motor speed as we target it regardless of disturbance. For this one you need to setup the speedPid. You control the speed of your motor in °/s. This mode is contradictory with the power mode, so when you enable it the container disable the power mode.
position mode : This mode use feedback loop to maintain the motor position as we target it regardless of disturbance. For this one you need to setup the positionPid. You control the position of your motor in °. This mode is contradictory with the power mode, so when you enable it the container disable the power mode.
Speed and position mode are not contradictory, you can enable both at the same time. When positionMode and speedMode are both enabled the motor container only use positionPid and control the speed of the motor using a motion planner algorithm.
Here is a small basic code allowing you to move (not perfectly because of not optimized PID) your motor :
# after connection
# ControlledMotor type settings
r.controlled_mot0.positionPid = [3,0.002,100] # position PID [P, I, D]
r.controlled_mot0.speedPid = [0.4,0.02,0] # speed PID [P, I, D]
r.controlled_mot0.encoder_res = 16 # Encoder resolution before reduction
r.controlled_mot0.reduction = 47 # gear reduction ratio of your motor
r.controlled_mot0.wheel_size = 100 # Wheel Diameter mm
# Motor control mode
r.controlled_mot0.compliant = False # enable the motor
r.controlled_moto.rot_position_mode(True) # enable position mode so disable power mode
r.controlled_moto.rot_speed_mode(True) # enable speed mode
r.controlled_moto.target_rot_speed = 100.0 # set speed at 100°/s
r.controlled_moto.target_rot_position = 100.0 # set position in °
After execution of the
# ControlledMotor type settings section, you should be able to do the other part of the code using the