Hi everyone,
I’m working on a program node contribution that generates a set of child nodes upon construction; some of those children are fixed waypoints. My problem is that when I create the second instance, fixed waypoints get created as Waypoint_1
, Waypoint_2
, etc instead of using the suggested name and a prefix.
Software version: Polyscope 5.3; SDK 1.6.1.
Robot generation: N/A
Steps to reproduce:
Minimal code:
// This code is unside UndoableChanges#executeChanges; the code is executed in a class that extends ProgramNodeContribution in its constructor.
// We assume that the root node and the node factory are already available using APIProvider and ProgramModel.
MoveNode customMoveJ = nodeFactory.createMoveNodeNoTemplate();
customMoveJ.setConfig(customMoveJ.getConfigBuilders().createMoveJConfigBuilder().build());
TreeNode customMoveJTreeNode = rootTreeNode.addChild(customMoveJ);
WaypointNode customWaypoint = nodeFactory.createWaypointNode("custom_waypoint");
System.out.println("Adding custom waypoint: " + customWaypoint.toString());
TreeNode customWaypointTreeNode = customMoveJTreeNode.addChild(customWaypoint);
System.out.println("Added custom waypoint: " + customWaypointTreeNode.getProgramNode().toString());
Expected behavior:
The first time I create the program node, I should see the following output:
Adding custom waypoint: custom_waypoint
Added custom waypoint: custom_waypoint
The second time I create the program node, I should see the following output:
Adding custom waypoint: custom_waypoint
Added custom waypoint: custom_waypoint_1
And in the program tree, I should see a MoveJ
with a child waypoint called custom_waypoint_1
.
Actual behavior:
The first time I create the program node, I see the following output:
Adding custom waypoint: custom_waypoint
Added custom waypoint: custom_waypoint
The second time I create the program node, I see the following output:
Adding custom waypoint: custom_waypoint
The new name Waypoint_1 is already registered. // This is printed by SDK code, not user code.
Added custom waypoint: Waypoint_1
And in the program tree, I see a MoveJ
with a child waypoint called Waypoint_1
.
Extra info: If after creating the two instances, I delete the nodes using Polyscope’s UI and create a new one once again, the waypoint is created and added correctly to the program tree.
I’ve also seen that in the ellipse sample, generating a set of fixed waypoints works as expected when more than one instance of the root node are created. However, I could not find the error in my code so far, and the code is quite simple.
Is there something obvious that I’m missing, or could this be a genuine bug?
Any help and hints are greatly appreciated; thanks in advance!
@jbm @ajp I’m sorry to bump this thread, but this issue is a blocker for our use case of having more than one template instance in the same robot program. Do you think this is a genuine bug, or am I doing something wrong? Would you suggest a workaround?
Please let me know if you need more information about the problem.
Thanks again!
Hi @jubeira,
Apologies for the delayed response on this. I am afraid I don’t know the Java API well enough to assist and Jacob has moved to a new role so won’t be spending as much time on the forum. @mmi Do you have any insight on this?
@jubeira postfix would exceed maximum allowed waypoint name length of 15 characters.
My bad; in the example I posted I modified the names for simplicity.
In the real code I’m using dropoff_pose
and dropoff_pose_N
, which are both less than 15 characters long, but I still get the same behavior. Could it be something else?
I tried to reproduce it with no success. I tried on 5.3, and latest development version.
Could you come up with minimum sample to reproduce?
In fact if name clash is detected, then suggested name is shortened instead of being replaced with default name. So you should get
custom_waypoi_1
Could you come up with minimum sample to reproduce?
Yes, I can work on it. I’ll upload it here once I have it.
For what it’s worth, I’m creating the waypoints inside a MoveJ
that is a child of a custom URCap node; not sure if that changes anything.
It’s the same for ellipse, so it doesn’t.
@mmi here’s the code based on the vision template; I basically changed variable waypoints for fixed waypoints (see diff wrt. master
branch if necessary). The second time I insert a template I see something like this:
And in the console:
Creating fixed waypoint: approach
Creating fixed waypoint: target
Creating fixed waypoint: approach
Creating fixed waypoint: target
ERROR [AWT-EventQueue-0] 10:11:59 12/08/19 ProgramAndInstallationObjectsNameServer.updateName(line:437): The new name Waypoint_1 is already registered.
ERROR [AWT-EventQueue-0] 10:11:59 12/08/19 ProgramAndInstallationObjectsNameServer.updateName(line:437): The new name Waypoint_2 is already registered.
I’m using SDK 1.6 and Polyscope 5.3.1. Here’s a link to the built sample.
.
Now I can reproduce it with prebuild urcap.
It looks like a problem that was fixed in 5.4.0. Quickly trying it out with ursim shows that it fails in 5.3.0, and works fine in 5.4.0. Could you try with 5.4.0 to confirm?