線形速度でメッセージを送信することにより、シミュレーションでロボットを正確な距離移動させようとしています。現在、私の実装では、ロボットが正確な距離を移動することはありません。これはいくつかのサンプルコードです:
void Robot::travel(double x, double y)
{
// px and py are the current positions (constantly gets updated as the robot moves in the simulation)
// x and y is the target position that I want to go to
double startx = px;
double starty = py;
double distanceTravelled = 0;
align(x, y);
// This gets the distance from the robot's current position to the target position
double distance = calculateDistance(px, py, x, y);
// Message with velocity
geometry_msgs::Twist msg;
msg.linear.x = 1;
msg.angular.z = 0;
ros::Rate loop_rate(10);
while (distanceTravelled < distance)
{
distanceTravelled = calculateDistance(startx, starty, px, py);
// Publishes message telling the robot to move with the linear.x velocity
RobotVelocity_pub.publish(msg);
ros::spinOnce();
loop_rate.sleep();
}
}
周りに尋ねたところ、フィードバック ループに PID コントローラーを使用することでこの問題が解決すると誰かが提案しましたが、ウィキペディアのページを読んだ後、このコンテキストでそれをどのように使用するかがよくわかりません。ウィキペディアのページには PID アルゴリズムの疑似コードがありますが、何が何に対応するのかわかりません。
previous_error = setpoint - process_feedback
integral = 0
start:
wait(dt)
error = setpoint - process_feedback
integral = integral + (error*dt)
derivative = (error - previous_error)/dt
output = (Kp*error) + (Ki*integral) + (Kd*derivative)
previous_error = error
goto start
速度と距離のコンテキストでこれをどのように実装しますか? 距離誤差ですか?それとも速度?誰でも助けてもらえますか?積分とは何ですか?派生物?Kp? き?K D?等
ありがとう。