Setting Minimum distance from object- 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: Setting Minimum distance from object (/Thread-Setting-Minimum-distance-from-object) |
Setting Minimum distance from object-AbdullahShafique27-02-19-2023 我甲肝病毒e been trying to figure out a way to set a minimum distance from my tool to a part as it moves through a program. As the parts that are used are complex and varying diffrent sizes of objects are used I want to automate this process. I assumed that RoboDK would have some sort of constraint built in for this but it seems not, so I have decided to try creating a py script. my code it below
Code:
from robolink import *
I seem to be having problems with the third last line of my code that startsdirectionas I get an error as such: direction = (tool_pose_global.Pos() - object_pose.Pos()) / distance TypeError: unsupported operand type(s) for -: 'list' and 'list' my simulation is trying to scan an object on a turntable with a camera from a set distance from the surface of the complex object as it moves from a front facing orientation with respect to the object to an almost top downviewwith respect to the object as seen in the attached picture. I am not very good with programming ingeneraland this is my first attempt in RoboDK. I am not sure if my code will even work if this error is fixed so I was wondering if anyone could help, or if there might be an easier way to do this. RE: Setting Minimum distance from object-Albert-02-20-2023 You are using add/subract/multiply operators on a 3-dimensional list of values (3D vectors). You should use the required functions to perform these operations on 3D vectors. Example:
Code:
delta_vector = subs3(tool_pose_global.Pos(), object_pose.Pos())
//www.sinclairbody.com/doc/en/PythonAPI/robodk.html#robodk.robomath.subs3 RE: Setting Minimum distance from object-AbdullahShafique27-02-21-2023 我甲肝病毒e changed my code slightly to incorpirate the new information you gave me as below
Code:
from robolink import *
But now I am getting the error:Minimumdistance1.py", line 32, in if newdist TypeError: ' I am assuming this means it cant compare the dist < min_distance as they are stored asdifferenttypes, but I am unsure how as Ibelievethey are both scalar types from the codesnippetsbelow
Code:
newdist = mult3(dist,1.0)
I think I am getting closer to a final script but the last few lines are causing me some problems. any advice would be great RE: Setting Minimum distance from object-Albert-02-22-2023 You are using a vector as if it was the norm. You can calculate the norm of a vector by using the norm function:
Code:
distance = norm(vector)
In your example:
Code:
dist_norm = norm(dist)
RE: Setting Minimum distance from object-AbdullahShafique27-02-22-2023 我甲肝病毒e further modified my code and now there are no errors when doing the quick program check. However when I set the minimum distance to larger than 760 I get a weird response as seen in the video attached. I am sure this has to do with the fact that my TVP is offset from the flange by 760mm, and the targets for the movement are based around the TCP changing angles around the parts reference frame which will change if the minimum distance is larger than the initial offset of 760mm. I am unsure of if this is a problem with my code or I am going to have to use another way other than targets to define my path as it will change depending on the minimum distance I set and the scanning program I have made. My code is below if there are any obvious problems with it but I cant seem to see any.
Code:
from robolink import *
|