I'm trying to apply position control in a wheeled robot, controlled by an arduino mega. The robot has two wheels powered by two dc motors (1 motor for each wheel) and one castor wheel. In order to implement the position control, I'm using classic PID control applied to each wheel seperately. My goal is to achieve some accuracy of moving and of course that the robot is moving in straight lines when told so (this means the wheels shall spin with the same speed, for the same distance and at the same time - otherwise the robot, would of course, turn). Following, I have gathered how I try to do this, some issues I face and some questions that I would like to ask.
The way I'm trying to achieve these robot functionalities is the following:
the error feeded as input to the control unit is estimated by the position generated from a trajectory profile that i wish the robot to follow, minus the actual position the robot has actually travelled.
afterwards, the output of the control is fed, in the form of pwm value, from the arduino to the motor controller, which i guess is (something similar to) an h-bridge.
about the desired position: as mentioned i have made a trajectory generator function. This trajectory is actually the integral of a trapezoid velocity profile. The desired position (des_pos) is actually a function of the pwm value, that i send from the arduino to the motor controller board. For example, for the accelerating phase, the position is calculated from the formula: 0.5(vmax/tacc)t^2 , where tacc is the time of acceleration. and vmax is the pwm value.
about the actual position: the encoder provides feedback of the position of the motor. This information is translated into actual (centi)meters that the robot has travelled (using the diameter of the wheel and the total number of ticks per revolution generated by the encoder)
the des_pos as said is a function of pwm. That means that its units are not meters. Which in principle is wrong. To make things worst, the error is computed between dissimilar quantities.. My idea was that I could either try and make some tests and map different values of pwm to the corresponding velocity of the robot. Then, by interpolation I could transform pwm values to velocity. Another option is to "absorb" this error inside the values of the gains. In other words, that during gain tuning I would be able to make this issue "hide".
the robot in order to move in the ground, where is placed, requires a threshold pwm value. Otherwise, if less pwm value than the threshold is provided then the robot can not start moving. This is perfectly normal, since friction, dynamics of the motor etc are opposing the movement. When applying PID though, the output of the control has to be mapped to produce values of "pwm adjustment" with respect to this minimum pwm value.
What is the proper way to implement position control here? What is the "proper" approach in this kind of robots? My approach has many issues (see above) and it seems like gain tuning is tough.
How can I handle the issues I mentioned or what is the best practise?
The response I get from testing the aforementioned setup is that the motors are doing an interrupted movement. In other words, it seems like the robot alternates between 0 and minimum pwm value, instead of progressively increasing speed. Theoritically, is this a result of bad pid tuning? Or is it because of the minimum pwm value required to ignite movement in the robot?
Something different, but more general let's say, regarding control theory. My understanding is that velocity and position control are actually different sides of the same coin. If I am not mistaken, the main difference has to do with the feature (velocity or position) which we pay attention in [for example in position control, you can manage the same result with velocity control - meaning you reach the same distance - but you have overshooting and all aspects of control focused on position whereas in velocity control you have focused on velocity], as mentioned also here. Also, what is the case when you need to take into account the dynamics of the motor? Or in other words, when is it necessary to insert the dynamics of the motor inside the control scheme?
Thanks in advance and sorry for the long post. I m looking forward to any help!