我试图通过发送100赫兹的位置来控制机器人。它在发出这么多的位置时会发出震动的动作。当我发送一个位置,这是像50毫米,从他的开始位置,它移动平稳。当我使用我的传感器转向,(所以它发送的每个位置从0到50毫米),它是摇动。我可能在发送X0-X1-X2-X3-X4-X5-X4-X5,这就是为什么它可能会抖动的原因。当我用鼠标操纵机器人时,我如何解决这个问题?
这是我的密码。
while(true)
// If sensor 1 is recording IR light.
if (listen1.newdata = true)
{
coX1 = (int) listen1.get1X(); //
coY1 = (int) listen1.get1Y();
newdata = true;
} else {
coX1 = 450;
coY1 = 300;
}
if (listen2.newdata = true)
{
coX2 = (int) listen2.get1X();
coY2 = (int) listen2.get1Y();
newdata = true;
} else {
coY2 = 150;
}
// If the sensor gets further then the workspace, it will automaticly correct it to these
// coordinates.
if (newdata = true)
{
if (coX1< 200 || coX1> 680)
{
coX1 = 450;
}
if (coY1<200 || coY1> 680)
{
coY1 = 300;
}
if (coY2<80 || coY2> 300)
{
coY2 = 150;
}
}
// This is the actually command send to a robot.
Gcode = String.format( "movej(p[0.%d,-0.%d, 0.%d, -0.5121, -3.08, 0.0005])"+ "\n", coX1, coY1, coY2);
//sends message to server
send(Gcode, out);
System.out.println(Gcode);
newdata = false;
}
}
private static void send(String movel, PrintWriter out) {
try {
out.println(movel); /*Writes to server*/
// System.out.println("Writing: "+ movel);
// Thread.sleep(250);
}
catch(Exception e) {
System.out.print("Error Connecting to Server\n");
}
}
}@ Edit
我发现我可以做到这一点。是通过min和max。因此,我认为我必须做的是:*把每个单独的坐标放在一个数组中( 12坐标)*从这个数组中得到min和max *输出min和max的平均值。
发布于 2013-05-06 08:45:53
在不了解您的机器人特性和如何控制它的情况下,以下是一些一般性的注意事项:
为了使机器人的运动平稳,你应该用一个设计良好的PID控制器算法来控制它的速度。
如果你只能控制它的位置,你能做的最好的就是监视这个位置&在发送下一个位置之前,等待它离目标位置“足够近”。
如果你想要一个更详细的答案,请给出更多的信息,你发送给机器人(movej),我怀疑你可以做更多的事情,不仅仅是发送x,y坐标。
https://stackoverflow.com/questions/16394748
复制相似问题