问题描述
我正在控制一个机器人到 x,y
网格上的各个点。机器人从随机位置开始,我可以控制它的速度和角速度。
目前,我正在使用旋转机器人直到机器人与目标目标之间距离的 atan2
的技术,如下所示:
dx = target_position.x - robot_position.x
dy = target_position.y - robot_position.y
angle = atan2(dy,dx)
angle = wrap_to_pi(angle) # Wrap the angles to the range [-π,π] radians.
if angle - robot_angle <= some_error_factor:
increase_linear_velocity() # note this is pseudo code
当机器人永远不必靠近坐标系上的 x=0
时,这可以很好地让我到达目标位置。我知道 atan2
附近 pi
存在不连续性,但我的问题是我如何环绕角度或控制机器人,因为目前当 x
接近 0 时,机器人只会旋转无法在错误因素下说您指向位置
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)