如何让我在ROS中控制的另一个turtlebot周围绕着圆圈移动?

huangapple go评论65阅读模式
英文:

How can I make a turtlebot in ROS circle around another turtlebot that I am controlling?

问题

假设我有一个我正在控制的海龟机器人,还有一个第二个海龟机器人,它应该以半径 r 和恒定角速度 w 围绕第一个海龟机器人运动。假设已知第一个海龟机器人在第二个海龟机器人坐标系中的坐标(x,y,theta),我需要设置第二个海龟机器人的平移速度和角速度,使其围绕第一个海龟机器人运动。

英文:

Let's say I have a turtlebot which I am controlling and a second turtlebot that should circle around the first turtlebot with a radius r and constant angular speed w. Given the first turtlebot's coordinates in the second turtlebot's coordinate frame (x, y, theta) what translational and angular velocity do I need to set to the second turtlebot to make it circle around the first turtlebot?

答案1

得分: 1

这将是一个既可变又依赖于第一个物体相对运动的问题,而这种运动是非确定性的(因为您在控制它)。更简单的方法是持续更新第二个物体的目标位置,并逐渐确定到达该位置的路径(方位角,距离)。

例如,如果您希望第一个物体的期望角速度为每秒5度,并且您每100毫秒更新一次位置,那么每次迭代的增量将为0.05度。因此,给定时间t时的当前角度θ和第一个物体的位置x1、y1,那么第二个物体的目标位置x2’、y2’将为:

  • x2’ = x1 + r cos(θ)
  • y2’ = y1 + r sin(θ)

因此,在时间t和当前位置x2、y2时,您确定从x2、y2到x2’、y2’的距离和方位,速度由距离和时间增量(100毫秒)决定,然后执行该操作。

在时间t + n(其中n是更新间隔,例如我的示例中是100毫秒)时,您根据当前位置(而不是之前可能未实现的目标)和更新后的角度θ计算新的目标位置。

这种方法的优点在于,如果起始位置不在轨道上,它将“追赶”(受某种最大速度限制的限制)以减小误差趋于零,直到被“捕获”。

基本上,这是一个“在第一个物体的当前位置下,第二个物体应该在哪”的过程,然后目标是达到那个位置。

您可以通过根据第一个物体的当前轨迹来预测其在t+n时的位置并瞄准该位置来优化这个过程。但是,如果n的值足够小,那么这可能是一个不必要的优化。

可能需要进行的一种可能的优化是在初始捕获方面。上述建议可能导致在尝试围绕移动的目标达到移动的目标时出现相当不稳定的行为。在这种情况下,如果两者之间的距离 >> r,那么您不应该随时间更新θ,而应该将其设置为两者之间的角度,直到接近r。

您还可以通过计算“碰撞点”轨迹来进一步优化,允许最佳的直线路径到达轨道(如果第一个物体保持恒定轨迹)。

英文:

That would be both variable and dependent on the relative movement of the first, which is non-deterministic (because you are controlling it). It would be simpler to continuously update the second's target position and incrementally determine the path (bearing, distance) to that position.

So if for example your desired angular velocity about the first were 5 degrees per second, and you were updating position every 100ms, that is an increment per iteration of 0.05degrees. So given the current angle theta at time t, and the first's position x1,y1, then the target position of the second x2’,y2’ would be:

  • x2’ = x1 + r cos(theta)
  • y2’ = y1 + r sin(theta)

So at time t and current position x2,y2; you determine the distance and bearing from x2,y2 to x2’,y2’, at a velocity determined by the distance and the time increment (100ms) and execute that.

At time t + n (where n is the update interval - 100ms in my example), you calculate a new target from the current position (not the previous target, which may not have been achieved), and the updated angle theta.

This approach has the advantage that if the starting position is not in the orbit, it will "catch up" (subject to some maximum velocity limit) to reduce the error tending to zero until it is "captured".

Essentially this is a process of "given the current position of the first, where should the second be" then aiming to reach that position.

You could refine this by, given the current trajectory of the first, predicting its position at t+n and targeting that position. But given a sufficiently small value of n, that is probably an unnecessary refinement.

One refinement that may be necessary is in the initial capture. The above proposal may lead to somewhat erratic behaviour attempting to achieve a moving target about a moving target. In that case if the distance between the two >> r then you should not update theta over time, but rather set it to the angle between the two until near r.

You might further refine that by calculating a "collision point" trajectory, allowing an optimal straight-line path to reach the orbit (if the first remains in a constant trajectory).

huangapple
  • 本文由 发表于 2023年5月28日 15:13:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76350362.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定