ev3dev / ev3dev-lang-python

Pure python bindings for ev3dev
MIT License
425 stars 144 forks source link

Invert gyro angle in code for MoveTank.follow_gyro_angle? #736

Closed WesleyJ-128 closed 4 years ago

WesleyJ-128 commented 4 years ago

In my robot, the gyro sensor is mounted such that the gyro is inverted relative to the motors. This means that when the robot turns clockwise, the angle decreases instead of increasing. Therefore, when I run tank = MoveTank(OUTPUT_B, OUTPUT_C) tank.gyro = GyroSensor(INPUT_2) tank.follow_gyro_angle(kp, ki, kd, Speed, Heading, 0.01, follow_for_forever) with kp, ki, kd, Speed, and Heading equaling 1, 0, 0, 25, and 0, respectively, the robot tries to correct in the wrong direction, and the robot spirals faster and faster until the program throws the FollowGyroAngleErrorTooFast error. Is there any way for the gyro angle to be inverted in code? I have tried tank.gyro.circle_angle(), but this causes the program to throw the same error as before, before the robot moves at all.

WasabiFan commented 4 years ago

Interesting! There's no way to explicitly rotate it as far as I know, but you I believe can make it behave like that. Can you negate your P, I and D coefficients so that kp=-1 and ki=kd=0 and try again?

WesleyJ-128 commented 4 years ago

I have tried that already, and when I try to run the program, it gives the same error, before it moves at all.

WasabiFan commented 4 years ago

@WesleyJ-128 It sounds to me like your kp might be too large. Could you change it to 0.1 and try again, with both positive and negative signs just in case?

WesleyJ-128 commented 4 years ago

This worked! Thank you.