pid_pluto module¶
-
class
pid_pluto.PID(config, droneNo)¶ Bases:
objectThis is the implementation of the PID controller. The current states are the x, y, z coordinates.The control variables are thrust, roll, pitch in the range of 900-2100. Kp, Kd and Ki are the PID gains required to tune the control variables.
-
calc_diff_err(diff_frame, err_list)¶ Calculating the differential error and storing the differtial error in list of length diff_moving_win_len and then storing the corresponding min, average or low pass filter function being called in the diff_fn.
-
calc_err()¶ Calculating the error terms for the proportional, integral and derivative gain of the PID controller corresponding to the thrust, roll, pitch and yaw. Simultaneously appending the list containing prev_err_list with the current error term for thrust, roll, pitch and yaw. Clipping the error term to the range of -100 to 100 for thrust and -30 to 30 for roll, pitch and yaw respectively. Calculating the err_pitch_with_sse, err_roll_with_sse and err_thrust_with_sse for the steady state error in pitch, roll and thrust respectively.
-
isReached()¶ Boolean function to check if the quadrotor has reached the target pose. When the error in velocity and position is less than a threshold value, the quadrotor is considered to have reached the target pose, function returns True, else False.
-
low_pass_filter(diff_error_list)¶ Filter to smoothen the error signal for PID controller.
-
reset()¶ Reset the error terms.
err_thrust: error in thrust.
err_roll: error in roll.
err_pitch: error in pitch.
err_roll_with_sse: Bias term corresponding to the steady state error in roll due to external disturbances at the setpoint.
err_pitch_with_sse: Bias term corresponding to the steady state error in pitch due to external disturbancesat the setpoint.
err_thrust_with_sse: Bias term corresponding to the steady state error in thrust due to external disturbances at the setpoint.
err_yaw: error in yaw.
prev_err: previous error.
prev_err_list: list of previous errors corresponding to thrust, roll, pitch and yaw respectively.
-
set_pitch_and_roll()¶ Calculating output of the PID controller corresponding to Pitch and Roll and clipping it to the range of -250 to 250 respectively.
-
set_target_pose(point, axis)¶ Updating the target position using the carrot approach.
-
set_thrust()¶ Calculating output of the PID controller corresponding to Thrust and clipping it to the range of -250 to 250.
-
set_yaw()¶ Calculating output of the PID controller corresponding to Yaw and clipping it to the range of -150 to 150 respectively.
-
update_pos(curPose)¶ Updating the previous position and the current position of the quadrotor respectively.
-