Create Targets from Quaternion- Printable Version +- RoboDK Forum (//www.sinclairbody.com/forum) +-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN) +--- Forum: RoboDK API (//www.sinclairbody.com/forum/Forum-RoboDK-API) 从四元数(+ -线程:创建目标/Thread-Create-Targets-from-Quaternion) |
Create Targets from Quaternion-Dustin Hendriks-08-23-2022 Hi all, I am struggling to create robottargets within a python script from quaternions. When I create a target with the "New target"-button in RoboDK and paste the Quaternion it works fine. But I have 364 targets that need to be created and I would like to do this with a python script but I don't know how the code should look like. I hope someone can help me with that. I already have written a small script, but this only transfers the xyz-coordinates to RoboDK but not the orientation. I attached a 4x4 Matrix (quaternion) of one of my poses, and the script I have written. RE: Create Targets from Quaternion-Albert-08-23-2022 It looks like you already have a 4x4 matrix in the text file you provided. You can create this matrix (Mat) by directly providing the all components of your matrix using a list of lists in Python:
Code:
poselist = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]
The opposite of Pose_2_ABB would be a function that takes 7 values (xyz,q1,q2,q3,q4) and returns a pose (4x4 matrix). This function could look like this:
Code:
def ABB_2_Pose(xyzq1234):
RE: Create Targets from Quaternion-Dustin Hendriks-08-25-2022 Hello Albert, thanks for the quick answer! Right now I am trying to implement the first solution you provided, but somehow my program doesn't recognize the robomath module. First the program gave me the following error: NameError: name 'robomath' is not defined Than I tried to import robomath with: from robodk import robomath But that gave me the error: ImportError: cannot import name 'robomath' from 'robodk' (/home/robi/.local/lib/python3.8/site-packages/robodk/robodk.py) I am using RoboDK version 5.3.0 Any ideas how to fix that? Best regards Dustin RE: Create Targets from Quaternion-Albert-08-25-2022 Try using this code at the top of your script for RoboDK imports:
Code:
from robolink import *
This should work for all versions. You can then access all functions directly like this:
Code:
pose = Mat(4)
|