code for 2 motors speed control using one throttle and angle sensor

sir, i need a coding help. i seen your hub motors post and mailing you my problem statement.

i have a tricycle with two rear hub motors. and i need to operate them with one throttle. problem comes when steering left or right. im trying to use a steering sensor which outputs angle from 0-360 degree.

so i need a code to vary two independent rear hub motors using steering angle sensor and parallely taking input from throttle.

ex: vehicle turning right, steering position detected - 15 derees right, throttle 20 % . i need a code to run left motor fast to take a turn to right easily.

throttle output & motor input - analogue - 0-5v
sensor output - angle value - 0-360 degrees or -90 to 90 degrees

You need to know the geometry of the vehicle - track and radius of the tricycle wheels

Please cut out the "sir" nonsense - there are ladies present.

What I would do is use a PID control loop. The Setpoint would be 0. The Input would be the difference between the current heading and the desired heading (-180 to +180). The Output range would be set to +/- X, where 'X' is a constant representing the number of steps of control desired in the motor speed. I think X=255 makes sense.

If Output is < 0, steer left by setting the LeftThrottle to Throttle * (X+Output) / X. For small negative values of Output, this is a number near (but less than) Throttle. For large negative values of X, this is a value near 0.

If Output is > 0, steer right by setting the RightThrottle to Throttle * (X-Output) / X. For small positive values of Output, this is a number near (but less than) Throttle. For large positive values of X, this is a value near 0.