# Mapping PID output to motors in 2WD line tracker

Recently at a small robotics design competition, a part of the challenge involved line tracking. Our implementation included six photo resistors on the bottom of the base and differential steering. The error in line position was fed into a PID controller and based on experimental tuning we found some nice constants to use and effectively tracked the line.

I was left with some ideas and uncertainty as to how to map the PID controller's output to the line in this sort of competition setting. I have seen other implementations which look like:

right_pwm = BASE_PWM + pid_output;
left_pwm = BASE_PWM - pid_output;


which works fine but it seems that more could be considered.

I played with the idea of having a function between the PID output and the pwm to the motor driver such as the image below which is what we ended up using in competition:

This is just an example of some mapping. The blue line would be the left motor's mapping and the orange line would be the right motor's mapping assuming a positive PID output means the line is to the right. The steering becomes more aggressive and progressively decreases the steering radius as the error increases.

There's an infinite number of mappings you can use by modifying the y-intercept, labelled a, or using a different piece wise linear configuration or even a new curve. I think the only thing you are controlling is the turn radius as error changes which affects how much forward movement you are preserving or how much your robot prioritizes not losing the line.

My questions are the following:

• Are these curves completely competition specific and subjective or is there a way to define some sort of optimal behavior?
• Is there an industry standard for these deciding a mapping from PID output or some rule of thumb to follow? Is analysis of these curves even useful?

I have tried to find some literature on this topic but had no success. Part of the problem may be not having the right search terms. Any help is appreciated.