I am tryng to build my application and my goal is to add a set of waypoints in order to save their coordinates but i do not want to move across them (i know that it sounds a bit tricky but i have coded a proper urcap that will do the magic).
The only option that i have found up to now is to insert an IF FALSE statement and add inside a moveNode with the waypoints: by doing in this way i am able to achieve my goal.
This latest option could work but i do not think that it is the best one.
The If-statement has the advantage of being easier accessible from within the program. But it is visible, as you mention yourself. I would go with this myself, though.
You could also make a subprogram and place the waypoints here? It can be hidden and you would not need an if-statement. Or just a folder which also has the Hide feature, but you would need the If here…
If a move and a bunch of waypoints are added as children into a custom node the children should not be called if you use the writer.writeChildren() call.
soby leaving this out you jump across all child nodes.
Also kinda of an ugly solution as its resluts in the ilusstion that a move is happening and that you (the user) have some control over it.
I would recommend looking into the customAPI sample for this purpose.
As a solution using this would properly give you the prettiest result.
I was wondering too about the possible implementations of these other two options.
The subProgram option could be good due to the fact that the user could have a specific place where to add a move with some waypoints but due to the structure of a subprogram this will never be executed unless a call is issued.
In this way i could have access to the name of these waypoints.
The folder option, as correctly pointed out by you, still needs the if false statement, otherwise the move instruction will be executed.
I’m really confused by this question. If you already have a URCAP and you just want to store positional data, without actually moving across them, why don’t you just make an arrayList of Pose variables or store the positions to the datamodel with a button on your Custom Instruction 2. Why do you need a list of waypoints present in your program at all?
What about collecting all of the waypoints in one move command and then simply commenting that command out?
Its just one button you have to press, no if stuff, and the list will automatically collaps, if you comment it out.
I have already tested this approach and it faces a little problem: if i comment out these points, they are not present inside the script when it is written out, hence i do not have access to the pose of the waypoints that were commented out.
What you’re describing is not strange at all. You’re describing the most basic data structure: a list
A database (list) of waypoints is exactly what I’m talking about doing. You don’t need one node per Pose you want to store. You can store any number of Poses inside the installation contribution if you want. You can make an arrayList whose size is dynamic. Click a button to trigger the getRobotMovementPosiiton() or whatever it is, and use its onOK() method to increment the list’s size and store the Pose/Joint Posiitons into the data model with something like:
Just use some iterator to generate a unique string for the model data (in this case using the size of the list itself should guarantee that as you add positions, they are stored uniquely)
You can use a comboBox to display the “database” as a dropdown list of positions, and even include a “Move Here” button, which uses the currently selected index of the dropdown box to pull from the arrayList of poses.
The generateScript() method can then iterate through the arrayList with a simple for() loop and write all the positional information at the top of the script. Being in the installation node, this would be written out once, at the very beginning, essentially making them global variables.
I pulled this straight out of my CAP. Pretend instead of being Set Home position, it was just a generic Set Position button.
Here I have 10 unique Positions stored in the installation. I can access them from any of my other program node contributions if I need, I can even populate the list from the other contributions if I needed to.
I have a question related to this topic: suppose to have the same setup of the previous case. I have a main custom instruction 1 inside which i have a movep and two custom instructions.
In this situation, i want my custom instruction 2 to be executed after the movements inside the move p instruction.
This custom instruction 2 will perform some movements base on the previous points inside the move. In order to achieve this, i need to pass a list of poses (the ones inside the move p) to the custom instrutcion 2. (this pose list is dynamic).
custom instruction 1
move p
– way 1
– way 2
– way N
custom Instruction 2
custom instruction 3
The problem with this, i that i cannot find a way in order to build up this array of poses. I had a look at this WaypointNode getPose() example but unfortunately i could not make it work.
You will need to follow that example and use a traverse() function. In the example, the visit is passed a “WaypointNode programNode” so it will only run the code on each node it finds that is of this type. As another example, if you called
@Override public void visit(final URCapProgramNode programNode, final int index, final int depth)
You would be running code for every instance of a URCAP node that you’ve found (ie custom instruction 2, custom instruction 3). You will likely need to call both versions of the visit(). One to operate on the built-in waypoint nodes, calling getPose to build the array of poses, and another using URCapProgramNode to find custom instruction 2, at which point you can store the array into this node. Then you can access this arrayList of poses from that node’s contribution.