我正在用Android手机中的摄像头跟踪球,并通过蓝牙将x,y位置,球半径(x,y位置是屏幕android手机中的像素)发送到我的stm32f板上。我将手机和stm32f1套件组装在移动机器人中。现在,我希望我的机器人以固定的距离移动到球上。
例如:我设定距离为10厘米。当我向前移动球时,我的机器人将球向前移动,并且始终保持10cm的距离
最佳答案
以下是一些伪代码,可以帮助您入门:
while (TRUE) do
get x, y position of ball
get x, y position of self
calculate distance between self and ball (hint: use Pythagoras)
if (distance < 10 cm)
move away from ball
else if (distance < 10 cm)
move towards ball
end
现在您要做的就是用C编写代码。