Universal Robots Forum

Add and set waypointNodes

Hello all,

I would like to make a basicNode that is a move node. To this I would like to be able to add several waypointnodes.
I want the user to add and set these waypoints themselves, but I can’t figure out how to do this.

I have used the following examples to figure out how it works but I still can’t figure it out:

  • ellipseProgramNode
  • visionTemplate - PartsFoundAndReachableProgram

The creation of a MoveNode is copied from the visionTemplate

I want to let the user add waypoints to it which he/she will give another position.
I tried the following for this purpose:

When a button is clicked:

While opening the view:

Obviously this doesn’t work and I think the problem is with the waypoint not being configured this way.But I can’t figure out how this works.

Apologies for the probably simple question, I still have a lot to learn in programming.

Kind regards,

Zoë Hermans

What specifically is not working? Do you see the main MoveP get added to the tree, but not the waypoints of said MoveP?

Hello Eric,

Thank you for wanting to help me again.
The moveP is created and the waypointNode is also added to the MoveP in this way, but I can’t get the user to capture the position in this waypointNode.

I do know that you can have the position retrieved by the user with robotPositionCallback2, but I don’t know how to add this value to the created waypointNode. Looking at the examples I think it has something to do with the configuration, but I only find preset waypoints in them.

Kind regards,

Zoë Hermans

Looks like you are correct in that you have created a Waypoint, but have not configured it. You have correctly used robotCallback2() to pull the Pose of the robot, but you now need to load this into the Waypoint. I confess I have not used a CAP to generate existing nodes (we make them all custom) but I would check out the docs here:

https://plus.universal-robots.com/urcap-basics/api-reference-docs/

Specifically one of these:

The first takes a JointPositions, qNear, tcpOffset, and a blendParameters. This is because it is the Move type that will respect joint positions.

The second is more similar to a MoveL, in that it just takes the TCP to the desired pose, regardless of joint angles (for example, a joint at -180 is the same as a joint at +180). This is a little simpler to build, as it only needs the Pose (which you’ve pulled from robotCallback2) and a BlendParameters. I’m not sure exactly what this is, but there’s probably a Factory to create one, and you can likely just put a blend radius into its constructor, and then pass this newly created “BlendParameters” as the second argument to your createFixedPositionConfig() function.

Let me know if that works, or you get stuck somewhere else, and I can try to dive a little deeper myself.

Hello Eric,

The ultimate goal is to create a waypoint in response to a digital input. The moment this is high, a waypoint should be created and the position of the robot should be stored in this waypoint.

In the meantime I also tried to create a custom moveNode/waypointNode in this way.

But as soon as I want to work with variable from the robotCallback here, I cannot use this variable in the writerAppendLine. In doing so, I also want to get numbers from another programNode to fill in the variable speed, for example.

On top of that, I wonder if this way is suitable for the ultimate goal.

In other words, I am stuck.

To give a little more information about my programmer level, i am a student and only have basic knowledge about front-end programming. i know i am going way out of my league with this, but this is what i would like to do en learn.

Thank you for your help!

Kind regards,

Zoë

When you are taking variables from the Java side to the Script side you need to add them like you would for a String.
For example in your generate script shown above:

public void generateScript(ScriptWriter writer) {
    Pose position = getPose(); 
    double acceleration = 2.0;
    double speed = 1.0;
    double blend = 1.0;

    //Doing this makes the script try to pull values from variables with those named defined on the script side
    writer.appendLine("movep(position, a=acceleration, v=speed, r=blend)");  

    //Doing this takes the variables you just defined above
    writer.appendLine("movep(" + position + ", a=" + acceleration + ", v= " + speed + ", r= " + blend + ")"); 
}
    

Though I would also note those values are pretty high for 2.0m/s^2, 1.0m/s, and a blend of 1.0 m.

Also, a pose on the script side is defined as p[0.2,0.3,0.5,0.0,0.0,3.14]
[0.2,0.3,0.5,0.0,0.0,3.14] would be used as joint positions and forward kinematics would be used to find the corresponding pose.

Hello Nrivas,

Thank you for your solution. The way it was solved actually speaks for itself, but I didn’t come up with it. The numbers are indeed out of proportion, it was mainly to quickly test the function.

Thank you again for your help!

Kind regards,

Zoë