How to describe the values of external axes of motion statements with PythonScri

Hi,

I learned how to use a Python script to create motion statements from the lesson.
(Python Robotics - 2 - Write a Robot Program)

However, I do not know how to program the value of the external axis of the robot on a rail with PythonScript.
What kind of code can I write statements with external axis values?

Have you done the third lesson in the Python Robotics course?

http://academy.visualcomponents.com/lessons/joints-degrees-freedom/?display_lessons=1

But let’s get you in the right spot, my friend.

  1. Go to "vcPositionFrame" in Python API reference.

    In Properties, you will notice there are these three properties: JointValues, InternalJointValues, and ExternalJointValues which are all read-only. They are the getters.

    In Methods, you will notice there are these two methods: setJoints and setExternalJoints, which do different things. setJoints() can set one, multiple or all joints of a position. setExternalJoints() can only set external joints, so no chance of changing internal joint value.


  2. So you must use a method to set the external joint value of a motion statement. The properties I mentioned can be used as getters, thereby you can modify the list of values as needed and call the methods with the new list of values as the argument.
NB! I do not remember which version number, but I think setJoints() had a bug where the external joint values were not being set with that method, so you had to manually call the setExternalJoints() method to workaround the issue. Not sure if it was fixed in 4.1.

Does this help?

Thank you for your reply.
I am sorry that the reply was delayed.
I finished Python Robotics - 3. I understood how to approach Python to external axes.

But I still do not understand well.

For example, when creating a new motion statement from python with VC_STATEMENT_PTPMOTION in Figure 1, the value of XYZABC can be easily defined.

However, looking at the created statement, the robot should be attached to the linear rail, but there is no value for E1. (fig 2)

When you touch up this statement, the value of the E1 axis will appear. (fig 3)

When creating a motion statement from python, what kind of code should be added after VC_STATEMENT_PTPMOTION so that this E1 axis value can also be entered at the same time?

fig.1

 

 

 

 

 

 

 

fig.2

 

fig.3

A vcMotionStatement is a vcPosititonStatement, which is also a vcStatement. For built-in motion statements, PTP and LIN, there is only one position, which is a vcPositionFrame. There can be only one position for these built-in types!

In your code, you know how to access and edit that position. However, you must also set the external joint values of that position. Why? The API is not going to assume you want to use the external joint values but not the TCP location of robot when creating a motion statement from scratch/via API.

So create a list of the desired joint values, and then pass that list as an argument when calling setExternalJoints() using the vcPositionFrame object.

If you manipulate the robot controller to the desired joint values and touch-up the position, the external joint values will populate.

But all is not lost. What you can try to do is this:

  1. Create the motion statement.
  2. Immediately after that, use the vcMotionStatement.readIn() method.
  3. Do what you did before, edit the position.
  4. Of course, if you do not like the external joint values, edit them.
 

That might be a bug. I’ll forward it to devs. The workaround that zesty suggested works though.

from vcScript import *
comp = getComponent()
executor = comp.findBehaviour('Executor')
r = executor.Program.MainRoutine
s = r.addStatement(VC_STATEMENT_LINMOTION)
s.readIn()
print s.Positions[0].ExternalJointValues

 

zesty, eme, thank you so much! !
I was able to solve the problem by using the vcMotionStatement.readIn () method!