Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Unexpected behavior of Robolink.AddPoints()

#1
Robolink.AddPoints() gives a misleading error message.

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.
  • 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 agree that a list phrased that way is 1x3.
    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)
    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:
    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.
#2
Thank you for your feedback. I confirm that the reference object should be an object or a tool (not the parent). This allows you to add points to an existing object.
Another option is to create an empty object using AddFile and passing an empty string. You can then add points to that object. Example:
Code:
from robodk import robolink
RDK = robolink.Robolink(args=['-NEWINSTANCE','-EXITLASTCOM'])
pts = RDK.AddFile("", RDK.ActiveStation())
pts.setName("Test Name")
pts.AddPoints([[0,0,0]], True)
  




Users browsing this thread:
1 Guest(s)