Hello VC World,
There is one servo controller that controls two joints in a component.
The first joint moves along the X-axis, and the other one moves along the Z-axis.
There are two Python scripts, and both of them may call the servo controller when necessary.
- The first script is a PythonProcessHandler that I use for PM-related tasks, such as sending Need requests.
- The second script is a Python behavior script that handles the internal process logic of the component, such as moving parts of the machine to perform certain operations.
I noticed that the joint.Move() operation gets canceled when Move() is called from another script.
So, I wrote a helper function to fetch the joint’s target and call Move() again in the second script.
This approach allows both joints to eventually reach their target positions, but the motion appears discontinuous.
The first joint suddenly stops and then moves again from velocity = 0.
My question is:
Is there a way to move a joint while another joint is already moving, when both joints are controlled by the same servo controller?
The helper function I wrote:
def JointGoTo(axis, position_name):
"""
Move the specified joint axis ('x' or 'z') to a named position.
Uses getJointTarget and move() to execute the joint movement.
If the joint is already moving, wait for it to finish before a new move command.
Example: JointGoTo('x', 'rest')
"""
axis = axis.lower()
position_name = position_name.lower()
if axis == 'x':
prop_dict = x_joint_location_props
joint_index = 0
_joint_index = 1
elif axis == 'z':
prop_dict = z_joint_location_props
joint_index = 1
_joint_index = 0
else:
raise ValueError("Axis must be 'x' or 'z'")
if position_name not in prop_dict:
raise ValueError("Unknown position '{}' for axis '{}'".format(position_name, axis))
pos = prop_dict[position_name].Value
# Use getJointTarget to get the current target position of the other joint before issuing moveJoint.
_pos = servo.getJointTarget(_joint_index)
servo.moveJoint(_joint_index, _pos)
servo.moveJoint(joint_index, pos)