10-21-2020, 08:54 PM
Hi Michael,
Here are a few suggestions to improve your code and workflow:
1. One important detail is that you are updating the joint values for a cartesian target. Cartesian targets prioritize the Cartesian data. Updating the joint values won't change the target but may change the configuration flags. Therefore, if you want to define a rotation for a target you could better do something like this:
2. I recommend you to link each target to your robot. This way, when you update the pose of the target, the joint values are updated accordingly (using the active tool and active reference, you can update the active tool and references using setPoseFrame and setPoseTool on a robot respectively).
3. You can convert the Mat joints object returned by the Joints function to a list by calling list(). Example:
4. You could automatically recalculate all joint targets by calling:
This is useful if you change the coordinate system or the tool of a program and you want to access updated joint values later.
You could also use InstructionListJoints function to obtain a full detailed list of the robot path in the joint space.
5. The variable pi is used by RoboDK to set the pi number (math.pi) and it may lead to confusion I updated it ito p_i.
I made some minor edits to the sample file you provided to reflect some of these suggestions, I have not tested it.
Let me know if anything is confusing.
Albert
Here are a few suggestions to improve your code and workflow:
1. One important detail is that you are updating the joint values for a cartesian target. Cartesian targets prioritize the Cartesian data. Updating the joint values won't change the target but may change the configuration flags. Therefore, if you want to define a rotation for a target you could better do something like this:
Code:
target.setPose(p_i * rotz(rotate_deg*pi/180))
2. I recommend you to link each target to your robot. This way, when you update the pose of the target, the joint values are updated accordingly (using the active tool and active reference, you can update the active tool and references using setPoseFrame and setPoseTool on a robot respectively).
Code:
target = RDK.AddTarget('T%i' % i, frame, robot)
# target.setAsCartesianTarget() # This is the default behavior, not needed
target.setPose(pose_i) # this recalculates the robot joints if it is a Cartesian target
joints = target.Joints().list() # get the robot joints for the last pose provided
3. You can convert the Mat joints object returned by the Joints function to a list by calling list(). Example:
Code:
抢劫otJoints = robot.Joints().list() # get current robot joint angles as a list of float
抢劫otJoints[5] = rotationTool # set the joint 6
抢劫ot.setJoints(robotJoints) # set the robot joint angle 6 to the rotation value
4. You could automatically recalculate all joint targets by calling:
Code:
program.setParam("RecalculateTargets")
This is useful if you change the coordinate system or the tool of a program and you want to access updated joint values later.
You could also use InstructionListJoints function to obtain a full detailed list of the robot path in the joint space.
5. The variable pi is used by RoboDK to set the pi number (math.pi) and it may lead to confusion I updated it ito p_i.
I made some minor edits to the sample file you provided to reflect some of these suggestions, I have not tested it.
Let me know if anything is confusing.
Albert