hi
i am trying to move the robot with PID code implement in the arduino code and drive the robot by teleop twisted
now i have problem in response i use rosserial as interface between ros and arduino.
loop time in the pid code is 100ms that mean its 10hz as frequency and i publish the encoder data at 10 hz
but while i am changing the direction or move for left to forward there is some lake of response i tryed to play with the parameter but not help is there any way that i can use PID in ROS and just controll the movement of the robot by telope twisted without and lake of response just move it around and speed controled by ros not arduino .
i use arduino due and ros indigo this is the PID code in arduino :
int updatePid(int id, int command, double targetValue, double currentValue) {
double pidTerm = 0; // PID correction
double error = 0;
double new_pwm = 0;
double new_cmd = 0;
static double last_error1 = 0;
static double last_error2 = 0;
static double int_error1 = 0;
static double int_error2 = 0;
error = targetValue-currentValue;
if (id == 1) {
int_error1 += error;
pidTerm = Kp*error + Kd*(error-last_error1) + Ki*int_error1;
last_error1 = error;
}
else {
int_error2 += error;
pidTerm = Kp*error + Kd*(error-last_error2) + Ki*int_error2;
last_error2 = error;
}
return constrain(double(command)+ pidTerm,-120, 120);
i toke this code from : https://sungjik.wordpress.com/
now this code work for him with just proportional gain
for me there is a lake of response if i use just proportional gain so i use Kp and Ki
its better but still have some problem .
i am using 2 h-bridge IBT-4 arduino
i hope all of this information can help you to give some answer. thanks.
↧