customized PID on top of pybrick PID controller #2506
Unanswered
familynygood
asked this question in
Q&A
Replies: 1 comment 2 replies
-
|
What is the underlying goal here? Adjust performance? What about adjusting the Kp, Ki, Kd of the existing controller instead of building another on top? You can separately adjust the PID values for forward/reverse ( from pybricks.parameters import Direction, Port
from pybricks.pupdevices import Motor
from pybricks.robotics import DriveBase
# Set up all devices.
left = Motor(Port.A, Direction.COUNTERCLOCKWISE)
right = Motor(Port.B, Direction.CLOCKWISE)
robot = DriveBase(left, right, 56, 128)
# Get and display the original values
head_kp, head_ki, head_kd, *_ = robot.heading_control.pid()
print(f"Original heading control: kp={head_kp}, ki={head_ki}, kd={head_kd}")
dist_kp, dist_ki, dist_kd, *_ = robot.distance_control.pid()
print(f"Original distance control: kp={dist_kp}, ki={dist_ki}, kd={dist_kd}")
# Do a test drive with the original for comparison.
robot.straight(250)
# Use double the original kp and half the original kd.
robot.distance_control.pid(dist_kp * 2, dist_ki, dist_kd * 0.5)
# Test again
robot.straight(250) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I posted my question here a month ago: https://github.com/orgs/pybricks/discussions/2470 and no one answers.
Let me ask another question: what do you think of the idea of creating a customized PID on top of pybrick PID controller? Will the robot be confused with what PID to use? Please share what thoughts of pros and cons.
Thank you,
Beta Was this translation helpful? Give feedback.
All reactions