-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge Fix/low velocity error to development #99
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
+40 −24 | README.md | |
+228 −42 | generator/Generator.py | |
+47 −0 | generator/README.md |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,8 +170,21 @@ void wheels_Update(){ | |
wheelsK[wheel].I = 0; | ||
} | ||
|
||
float feed_forward[4]; | ||
float threshold = 0.05; | ||
|
||
if (abs(wheels_commanded_speeds[wheel]) < threshold) { | ||
feed_forward[wheel] = 0; | ||
} | ||
else if (wheels_commanded_speeds[wheel] > 0) { | ||
feed_forward[wheel] = wheels_commanded_speeds[wheel] + 13; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to document on why 13 is being added (or subtracted on line 183). It would be better to rename it to some constant that can then have its own documentation string too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes 13 came from implementing the dry friction. The constant was found after testing our robot. But yes you're right I will rename it as a constant, it is probably more clear. |
||
} | ||
else if (wheels_commanded_speeds[wheel] < 0) { | ||
feed_forward[wheel] = wheels_commanded_speeds[wheel] - 13; | ||
} | ||
|
||
// Add PID to commanded speed and convert to PWM | ||
int32_t wheel_speed = OMEGAtoPWM * (wheels_commanded_speeds[wheel] + PID(angular_velocity_error, &wheelsK[wheel])); | ||
int32_t wheel_speed = OMEGAtoPWM * (feed_forward[wheel] + PID(angular_velocity_error, &wheelsK[wheel])); | ||
|
||
// Determine direction and if pwm is negative, switch directions | ||
// PWM < 0 : CounterClockWise. Direction = 0 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just wondering about the reason for this threshold value, since there is also already a PWM treshold that makes sure that the robot is not slightly jittering on the field, if no explicit instructions are send out.
See
roboteam_microcontroller5.0/Core/Src/peripherals/wheels.c
Line 325 in fc08aa7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no I don't think this is linked to the PWM signal. It is only linked to the wheel velocity and the dry friction. Here the code simply adds (if driving forward) or subtract (if driving backwards) 13 to the feedforward term. However the feedforward term is equal to 0 if wheel velocity is almost 0 (< 0.05), thus 0.05 if your threshold.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
picture b