Workspace visualization

Typically: "How do I... ", "How can I... " questions
Post Reply
jovan_s
Posts: 18
Joined: 01 Dec 2020, 10:19

Workspace visualization

Post by jovan_s »

Hello Coppelia,

I'm working on a scene with several UR5 robots, and I wanted to visualize their workspaces. Your scenes/workspace.ttt example proved very useful, but I do have 2 questions.
In that example you use a deprecated function to create a point cloud:

Code: Select all

if usePointCloud then
        sim.addPointCloud(0,255,base,0,5,points,{255,34,34,0,0,0,255,194,194,0,0,0},nil,normals)
end
The function still works but I can't find it anywhere in the documentation. I guessed what some of the arguments are, but I would love to know all of them. Since I have 2 UR5 robots, I tried applying the script to both. However, the point cloud is only drawn for the first one, and the error says:
139: One of the function's table size is not correct. (in function 'sim.addPointCloud')
stack traceback:
[C]: in function 'addPointCloud'
[string "UR5#0@childScript"]:139: in function 'doCalculation'
[string "UR5#0@childScript"]:158: in function <[string "UR5#0@childScript"]:154>
I gathered it has something to do with the deprecated function, but I'm not sure how to fix it. I know there are new functions available, but I would like to finish the codes with this one.

EDIT: I tried to do it with the new functions, sim.createPointCloud and sim.insertPointsIntoPointCloud and I still get the same error. I have 2 UR5 robots, each has a non-threaded child script that does the same thing, but only one point cloud is drawn. The second robot reports the above error. If I delete the first script, then the second robot script draws the point cloud without any problems. How could I resolve this issue?

One more thing: In the example, the result is a cloud of reachable points, so I just wanted to ask if there was a similar way to visualize the robot's singularities?

Cheers,
Jovan

coppelia
Site Admin
Posts: 8596
Joined: 14 Dec 2012, 00:25

Re: Workspace visualization

Post by coppelia »

Hello,

you are right, we forget to remove that deprecated function. And yes, you can use instead sim.createPointCloud and sim.insertPointsIntoPointCloud, or simply use drawing objects (i.e. sim.addDrawingObject and sim.addDrawingObjectItem). Drawing objects are automatically used instead of point clouds in that scene, if in the initialization section of the child script you specify

Code: Select all

usePointCloud=false
Not sure how you get the error message. Simply by duplicating the robot from the original scene? If I do that, I just get an error message about duplicate object names: simply remove object naming (sim.setObjectName) in line 149.

Cheers

jovan_s
Posts: 18
Joined: 01 Dec 2020, 10:19

Re: Workspace visualization

Post by jovan_s »

Hello,

I figured out what the problem was. I have a tree-structured kinematic chain, a sort of torso with 2 UR5 arms mounted at the top. The arms were connected via force sensors and were dynamic. As soon as I made each arm orphan the codes did work. However, I now have another problem. If I make them orphan, and leave them dynamic, then the program calculates the right point clouds, but in the end, the robot arms fall down! If I make them static, then the program crashes. Could you please give me an idea as to why this happens and how to fix it?

Also, is there a way to similarly draw the point cloud of the robot's singularities?

Cheers,
Jovan

coppelia
Site Admin
Posts: 8596
Joined: 14 Dec 2012, 00:25

Re: Workspace visualization

Post by coppelia »

it crashes or outputs an error? If it crashes, please post your scene so that we can replicate this.

My guess is that you are mixing up object handles, or something similar. Make sure to carefully read the section about how to access objects from associated code.
You can also try to make a minimalistic, self-contained scene that illustrates the problem.

Cheers

jovan_s
Posts: 18
Joined: 01 Dec 2020, 10:19

Re: Workspace visualization

Post by jovan_s »

Yes, it outputs the error, the same as above.

Here is my minimalistic scene:
https://www.dropbox.com/s/mauego992i3s6 ... e.ttt?dl=0

I was using CoppeliaSim Edu v.4.1.0.

As you can see, the point cloud is calculated for one UR5 robot, which is dynamic, but the arm then falls down. The script for the second robot, which is made static, outputs the error and does not calculate or draw the cloud. I'm not sure how to fix this. If I make the other robot dynamic as well then the point cloud is drawn, but the other arm falls down too.(I'm talking about making the whole UR5 object dynamic or static).

Also, one more thing, I tried making convex hulls for both robots, I expected they would intersect, as the point clouds themselves intersect. But it doesn't work that way. One hull is made rightly, while the other is around it or next to it, and doesn't encompass all of the points rightly. Is there a way to make convex hulls intersectable so I could see which part of the workspace is accessible to both robots?

Cheers

coppelia
Site Admin
Posts: 8596
Joined: 14 Dec 2012, 00:25

Re: Workspace visualization

Post by coppelia »

You have several problems with your scene. First, most manipulators have their base static by default. But they often also have the behaviour that if they are attached to another object, their base will become dynamic. This is the Set to dynamic if gets parent checkbox in the shape dynamics dialog. So, for the falling arm, simply select its base, then uncheck Body is dynamic.

Then, while trying to compute the collision free configurations, did you try to see if there is at least one collision-free configuration? Adding somethere in your script:

Code: Select all

print(#points) 
you'd have quickly noticed that there are no collision-free points! So what is the reason? Well, the manipulator base is constantly colliding with the torso (a tiny bit). So simply move the manipulator a bit away.

Also, why doing two collision checks?? In your code:

Code: Select all

                if sim.checkCollision(robotCollection1,sim.handle_all)~=0 or sim.checkCollision(robotCollection1,torsoCollection1)~=0 then
the second part is already covered by the first part (i.e. checking if the manipulator collides with any other object also checks if the manipulator collides with the torso)

Additionally, you'll also have to check for manipulator self-collisions:

Code: Select all

                if sim.checkCollision(robotCollection1,sim.handle_all)~=0 or sim.checkCollision(robotCollection1,robotCollection1)~=0 then
                    colliding=true
                end
But above will correctly play-out only if you have correctly tagged your manipulator collidable links with the collection self-collision indicator in the object common properties.

Cheers

Post Reply