Skip to content
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

Car cannot run in a straight line #1020

Closed
mseld opened this issue Jun 15, 2022 · 3 comments
Closed

Car cannot run in a straight line #1020

mseld opened this issue Jun 15, 2022 · 3 comments

Comments

@mseld
Copy link

mseld commented Jun 15, 2022

The car cannot run in a straight line and I'm looking for something like STEERING_MID to adjust it

PWM Servo Driver PCA9685 16 Channel (SunFounder)

DRIVE_TRAIN_TYPE = "PWM_STEERING_THROTTLE"

PWM_STEERING_THROTTLE = {
    "PWM_STEERING_PIN": "PCA9685.1:40.1",   # PWM output pin for steering servo
    "PWM_STEERING_SCALE": 1.0,              # used to compensate for PWM frequency differents from 60hz; NOT for adjusting steering range
    "PWM_STEERING_INVERTED": False,         # True if hardware requires an inverted PWM pulse
    "PWM_THROTTLE_PIN": "PCA9685.1:40.0",   # PWM output pin for ESC
    "PWM_THROTTLE_SCALE": 1.0,              # used to compensate for PWM frequence differences from 60hz; NOT for increasing/limiting speed
    "PWM_THROTTLE_INVERTED": False,         # True if hardware requires an inverted PWM pulse
    "STEERING_LEFT_PWM": 460,               #pwm value for full left steering
    # STEERING_MID_PWM 400
    "STEERING_RIGHT_PWM": 290,              #pwm value for full right steering
    "THROTTLE_FORWARD_PWM": 420,            #pwm value for max forward throttle
    "THROTTLE_STOPPED_PWM": 370,            #pwm value for no movement
    "THROTTLE_REVERSE_PWM": 320,            #pwm value for max reverse throttle
}
@sctse999
Copy link
Contributor

https://docs.donkeycar.com/guide/calibrate/

@sctse999
Copy link
Contributor

Follow the doc. This is probably not a bug therefore I am closing the issue now. Reopen if I misunderstand your question.

@sctse999 sctse999 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 15, 2022
@Ezward
Copy link
Contributor

Ezward commented Jun 15, 2022

The midpoint is assumed to be the average of the two steering values. So that means you need to be calibrated such that the left and right wheels are at the same angles (relative to straight ahead) at their maximum steering. Calibration is a little tricky; make sure you are picking the value that just barely makes the servo whine, then back off by 1 until it stops whining. Do this for both left and right. Generally you will find that if you add the left and right PWM values and divide by two you should get something very close to 370. If you do not you may not be evenly calibrated between left and right. So in our case (460 + 290) / 2 = 375, so it is close, but I would apply the 'just until it whines' methodology I suggested.

Another way to try this is to start with the wheel turned using your full left value, then set to the average of the left and right values to see if it goes in the middle. do this again starting at the full right value. Does it stop in a straight ahead position? If not then keep adjusting your leflt/right values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants