Probably a very basic question but I'm programming a robot to turn with a gyroscope and have hit the limits of what I can remember from my math classes.
I'm polling for the current angle of robots gyroscope and I can tell the degrees that I need to turn d (values of -360 to 360)
I need the turning power to apply to the wheel motors at each poll interval t. Basically sending t to the left motor and -t to the right motor.
I'm not sure what unit of measurement that t has, but the tests I've run show that if I pass along values under about 6 the wheels don't turn at all and if I pass values over about 110 the robot spins fast enough that it messes with the gyroscope and I loose accuracy.
I'd ideally need a function that generically follows the following sets:
Less than -360 : about -110
-360 to -1 : between -110 to -5.
0 : doesn't matter (but having it be 0 would be nice)
1 to 360 : between 5 and 110
Over 360 : about 110.
The function doesn't have to be exact and I feel something like arc tangent would be a good solution except for the bits in the middle where I don't really know how to get it to just floor out on -5 or 5. Also the micro-controller i'm running this on seems to take a while to run a math.atan for some reason which slows down the poll interval (not a big deal if i'm supplying the right power to get there in only a few intervals though).
Thanks for any help!
dis the degrees that I need to turn. So ifdis 55 i need to turn 55 degrees clockwise. In that specific situation i'd probably want to send the command to supply 70 to 80 amps (volts?) to the motor.During the next evaluation of
di= 30, so I'd want to cut the amps supplied to the motor down to something like 25.During the next evaluation
d= 2 so I'd want to apply 5 amps to the motor.Next evaluation
– WhiteleyJ Dec 24 '19 at 20:33d= -1 so i'd want to supply -5 amps to the motor (wiggling it back into position).