10-30-2023, 08:55 PM
Robolink.AddPoints() gives a misleading error message.
provokes the following error:
After dragging an stl (my_obj) into my workstation, things work properly:
I infer this means that the Item passed to the reference_object keyword argument must be of type robolink.ITEM_TYPE_OBJECT.
Code:
from robodk import robolink
RDK = robolink.Robolink(args=['-NEWINSTANCE'])
pts = RDK.AddPoints([[0,0,0]], reference_object=RDK.ActiveStation())
provokes the following error:
Code:
WARNING: Invalid curve, a 3xN (or 6xN) list of points must be provided
After dragging an stl (my_obj) into my workstation, things work properly:
Code:
my_obj = RDK.Item('my_obj')
>>> my_obj.Valid()
True
>>> pts = RDK.AddPoints([[0,0,0]], reference_object=my_obj)
>>> pts.Valid()
True
I infer this means that the Item passed to the reference_object keyword argument must be of type robolink.ITEM_TYPE_OBJECT.
- The error message `WARNING: Invalid curve, a 3xN (or 6xN) list of points must be provided` is misleading as it implies the issue was with the Nx3 list.
- While the keyword argument name does imply it, updating the documentation here to state that the Item passed to reference_object must have ITEM_TYPE_OBJECT, even when add_to_ref=False, would be helpful.
- robomath and numpy both agree that a list phrased that way is 1x3.Code:
>>> from robodk import robomath
>>> A = robomath.Mat([[0,0,0]])
>>> A
Matrix: (1, 3)
[[ 0, 0, 0 ]]
>>> import numpy as np
>>> np.shape([[0,0,0]])
(1, 3)
robomath and numpy both also agree that phrasing a list the opposite way swaps the dimensions. Based on this, the warning message should have the opposite dimensions compared to the current wording:Code:>>> pts = RDK.AddPoints([[0],[0],[0]], reference_object=my_obj)
WARNING: Invalid curve, a 3xN (or 6xN) list of points must be provided
>>> A = robomath.Mat([[0],[0],[0]])
>>> A
Matrix: (3, 1)
[[ 0 ],
[ 0 ],
[ 0 ]]
>>> np.shape([[0],[0],[0]])
(3, 1)
Code:WARNING: Invalid curve, a Nx3 (or Nx6) list of points must be provided
- In the future, it would be nice to be able to add points to the right parent immediately on item creation with the itemparent keyword argument. This would bring it in line with other methods that return new Items like Robolink.AddFrame and Robolink.AddTarget. The current workaround is to create the points then set their parent on the next line.