pid package#

Submodules#

pid.position_pid module#

class pid.position_pid.PositionPID#

Bases: Node

This node is responsible for applying PID control to the error between the wanted position of the drone and the actual postion on each axis, finding the appropriate velocities in the direction on each axis to achieve the wanted position.

clamp_values()#

Clamps PWM values to the 1000-2000 range.

publish_new_vals()#

Publishes values to the ‘VelPIDInput’ topic.

received_new_vals(msg)#

Called when new values from the ‘PosPIDInput’ topic are received. Uses the new values to regulate position errors by finding needed velocities.

pid.position_pid.main(args=None)#

pid.velocity_pid module#

class pid.velocity_pid.VelocityPID#

Bases: Node

This node is responsible for applying PID control to the error between the wanted velocities in each direction of the drone and the actual velocity in these directions, finding the appropriate control signals on each axis to achieve the wanted velocity.

clamp_pwm(pwm)#

Clamps PWM values to the 1000-2000 range.

find_heading_error(real_hdg, wish_hdg)#

Finds the shortest path to travel to the wanted heading and returns this as the error.

publish_joystick()#

Publishes values to the ‘Joystick’ topic.

received_real_vals(msg)#

Called when new values from the ‘gps_heading’ topic are received. Updates members with the new values.

received_wish_vals(msg)#

Called when new values from the ‘VelPIDInput’ topic are received. Uses the new values to regulate velocity and heading errors by calculating control signals for the flight controller.

pid.velocity_pid.main(args=None)#

pid.pid_math module#

class pid.pid_math.SingleAxisPID(Kp_t, Ki_t, Kd_t, Kp_f, Ki_f, Kd_f, Kp_l, Ki_l, Kd_l)#

Bases: object

This class is responsible for calculating the PID control variable for an angle along a single axis.

regulate(current_val, wish_val, time, PID_type, max_output=0, max_integral=20.0, integral_zero=False)#

This function produces a regulated output in order to smoothly get rid of the error.

Module contents#