我必须让 NAO 机器人从形状的每个点的 (x, y) 坐标开始在白板上绘制一些形状。
因此,例如,我有一个正方形的 (x, y) 坐标列表:
square = [[251, 184], #point 1
[22, 192], #point 2
[41, 350], #point 3
[244, 346]] #point 4
现在我必须将这些坐标提供给 NAO 机器人以便在白板上绘图。问题是为了移动NAO机器人的手臂,Aldebaran给出了从这里提取的以下示例代码(我在这里只粘贴了部分代码,您需要理解):
effector = "LArm"
space = motion.FRAME_ROBOT
axisMask = almath.AXIS_MASK_VEL # just control position
isAbsolute = False # Since we are in relative, the current position is zero
currentPos = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
# Define the changes relative to the current position
dx = 0.03 # translation axis X (meters)
dy = 0.03 # translation axis Y (meters)
dz = 0.00 # translation axis Z (meters)
dwx = 0.00 # rotation axis X (radians)
dwy = 0.00 # rotation axis Y (radians)
dwz = 0.00 # rotation axis Z (radians)
targetPos = [dx, dy, dz, dwx, dwy, dwz]
# Go to the target and back again
path = [targetPos, currentPos]
times = [2.0, 4.0] # seconds
如您所见,我在白板上只有 (x, y) 点的坐标,但是 NAO 机器人需要设置更多的变量。我知道首先我必须将坐标从像素转换为米,转换如下:
1 pixel (px) = 1/3779.52755905511 meter [m]
然后,似乎我必须向坐标添加一维才能获得(x,y,z)坐标。
当然,要画一条线,应该将 currentPos 设置为第一个点,将 targetPos 设置为第二个点。因此,在转换之后:
(251, 184) pixels coordinates = (0.066, 0.047) meters coordinates
(22, 192) pixels coordinates = (0.035, 0.011) meters coordinates
因此:
currentPos = [0.066, 0.047, 0.0, 0.0, 0.0, 0.0]
dx = 0.035 # translation axis X (meters)
dy = 0.011 # translation axis Y (meters)
dz = 0.00 # translation axis Z (meters)
dwx = 0.00 # rotation axis X (radians)
dwy = 0.00 # rotation axis Y (radians)
dwz = 0.00 # rotation axis Z (radians)
即使这是正确的,我也不确定。我怎么解决这个问题?