akash.garg101 Posted July 1, 2009 Posted July 1, 2009 Hi guyz, I am trying to write an autolisp program to generate the configuration space of a robotic manipulator. For this I generate a drawing of my robot of different values of the various degrees of freedom. I also take the various obstacles in the path of the robot as inputs. Now what I need to do is check for interference between each of the position of the robot and the obstacles. This is where I am stuck. When I try to use the interference command from the program and give the 2 objects as arguments if the objects interfere it further asks me whether to generate an interference object or not and if they dont intersect it simply moves on to the next step. What I need to know is how can I give inputs automatically(through the code) depending on the action of the previous command. How can I write an autolisp code to simply detect if the two objects interfere or not? In the end I need to generate a simple list with each row containing the values of the dofs and whether ther is obstruction at that position or not. Thanks in advance Quote
Lee Mac Posted July 1, 2009 Posted July 1, 2009 All I can think of is the IntersectWith method - but I welcome others to chime in. Just curious, is this for some kind of school project? Lee Quote
Freerefill Posted July 1, 2009 Posted July 1, 2009 It depends heavily on the shape of the object. For simple shapes, you don't need the IntersectWith method, you can rely on other checks. A good example is my GrPlayground program, specifically the Laser Defense game. I needed to check if a certain point was within a given circle, which was composed of vectors. Instead of a complicated method forcing me to balance precision versus performance, I did something easier: since I had the radius of the circle and the centerpoint, I could just check to see if the distance between the two points was less than the radius of the circle. It's also quite easy to perform a simple check to determine if a point is within a "polar" (for lack of a better word.. it just means all the lines are vertical or horizontal) rectangle. Here's a code that I use for it: (defun inRec(point listy / ); (and (bween (car point) (apply 'min (mapcar '(lambda (x) (car x)) listy)) (apply 'max (mapcar '(lambda (x) (car x)) listy))) (bween (cadr point) (apply 'min (mapcar '(lambda (x) (cadr x)) listy)) (apply 'max (mapcar '(lambda (x) (cadr x)) listy)))) ); Returns 'T' if <point> is within a rectangle defined by <listy> (defun bween(in1 chkD chkU / ); (and (numberp in1) (numberp chkU) (numberp chkD) (> chkU chkD) (> in1 chkD) (< in1 chkU)) ); Checks to see if in1 is a number between chkU and chkD where "listy" is a list of points defining the four corners of the rectangle, and "point" is.. well, a point. You will note that there are no checks in this function.. so either add some in, or use at your own risk. ... oh yeah, forgot the 'bween' function... that just checks to see if a number is between two other numbers. Other methods, without using IntersectWith, could involve creating a selection set to see if it returns true, if so, that means there is some object within that object (though, I can't tell you if the processing time is going to kill you). You can expand upon this, like, for example, checking to see if two rectangles are intersecting.. you just need to run each of the four points of one rectangle against the four points of the other. I'm sure there are other solutions, just keep in mind that, really, it's only difficult because AutoCAD is not a gaming environment, so the kinds of things you'd expect to be simple and common in other robust languages (like this) are simply not available. Just keep your mind open, take a deep breath and think about exactly what it is you have and what it is you need to do in order to check it. I'm sure the answer will come to you. Edit: By the by, not that I'm trying to push this on anyone *shifty eyes* but GrPlayground does have a unique setup, and it reports the FPS (frames per second) of the program. I'd imagine it shouldn't be to hard to create a small function for it that would get a few dozen selection sets and check them for a point, then create another function to apply a different intersection check, and comparing the respective FPS to see just which one is 'faster' Edit edit: And no, Lee. World domination. Quote
akash.garg101 Posted July 1, 2009 Author Posted July 1, 2009 Thanks for the quick replies However the 'IntersectWith' command in my version of Autocad (Autocad 2008 ) doesn't seem to work. The obstacles that I have to check interference with are not simple but are complicated 3D shapes formed by the union of a number of primary shapes. I tried using the 'intersect' command instead but that doesn't solve my purpose as it deletes the remaining object, something that I don't want. N Freerefill cud u plz emphasize a bit more on how I can use selection sets....I m a newbie 2 autocad N ya this isn't exactly a school project...its kinda hobby project I'm doin 2 learn more abt robotics n planning in robotics Thanx once again for ur help guyz Quote
Freerefill Posted July 1, 2009 Posted July 1, 2009 I'm not sure if you can create a 3D selection set.. so that might not work for this. For more help on selection sets, check out the "ssget" function in the AutoLISP help file, or you can try here: http://www.jefferypsanders.com/autolispintr_sele.html Thinking about it now, a Fence selection set might do the trick, but again, I haven't tried any selection sets in three dimensions, so that would be hit-or-miss. I also haven't done much at all with three-dimensional intersections, but the points passed to my rectangle check function can be 3D points, and it stands to reason that it can therefore be expanded to include a third dimension, thereby checking to see if a point is within a rectangular block. Something like this, I'd imagine (note: untested): (defun inRec(point listy / ); (and (bween (car point) (apply 'min (mapcar '(lambda (x) (car x)) listy)) (apply 'max (mapcar '(lambda (x) (car x)) listy))) (bween (cadr point) (apply 'min (mapcar '(lambda (x) (cadr x)) listy)) (apply 'max (mapcar '(lambda (x) (cadr x)) listy))) (bween (caddr point) (apply 'min (mapcar '(lambda (x) (caddr x)) listy)) (apply 'max (mapcar '(lambda (x) (caddr x)) listy)))) ); Returns 'T' if <point> is within a rectangle defined by <listy> More complex shapes would require more complex checks. And again, don't be afraid to think outside the box. Not having much experience with AutoCAD in 3D, I can't say specifically what you could try.. but, clever use of output could save you a lot of time and trouble. Good luck on world domi- er, I mean, your robot Quote
scj Posted July 1, 2009 Posted July 1, 2009 See "AutoCAD in motion" at http://www.black-cad.de I did a collision check using the interfere command too. In case of interest I can send the AutoLISP-sample. Regards Jochen Quote
Freerefill Posted July 1, 2009 Posted July 1, 2009 Off the topic a bit.. I'm really glad this question was asked. I probably never would have heard of the "interfere" command, or the "intersect" command, and from there, I never would have realized that you could use "subtract" on regions, not just 3D solids. ... Scorched Earth, anyone? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.