In automatic competitions, forward and rotation are especially important. At present, I use a gyroscope to solve the problem of rotation angle. For example, when the robot rotates 90 degrees, the robot can correctly rotate 89-90 degrees. However, the problem of forward movement has not been solved. Due to the imbalance of the machine structure, it will shift slightly to the left when moving forward. How should this problem be solved, or what sensors need to be used to assist.
I’d use the gyroscope to adjust its angle as it moves, correcting for any drift as a result of mechanical problems.
Can you elaborate on how you solved it? :微笑:
As a simple algorithm, you can just use a p-loop to control the difference in the two drive speeds. For example, if the angle offset received by the gyroscope is 5 degrees, you might make the left side slow down by, say, 10 rpm. You’ll have to experiment with this proportion to see what works for you.
Ill give a really really simple example of this.
void Move (double movementAngle, double speed, double kp, double s)
double ioffset;
double inertStore = inert;
while (not destination reached){
ioffset = inertStore-inert;
if (ioffset<-180){
ioffset+=360
}
if (ioffset>180){
ioffset-=360
}
double disToDes = how far you are from target;
FR.setvelocity((whatever movement you want to do+ ioffset x kp)x speed x disToDesx x s, pct));
FL.setvelocity((whatever movement you want to do + ioffset x kp)x speed x disToDesx x s, pct));
BR.setvelocity((whatever movement you want to do + ioffset x kp)x speed x disToDesx x s, pct);
BL.setvelocity((whatever movement you want to do + ioffset x kp)x speed x disToDesx x s, pct));
}
}
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.