[Hexapod] Too many objects to add in collision check

Typically: "How do I... ", "How can I... " questions
ravi
Posts: 73
Joined: 24 Oct 2016, 08:00

[Hexapod] Too many objects to add in collision check

Post by ravi » 27 Feb 2018, 03:48

Hi,

I am using Hexapod provided in Model Browser inside V-Rep. A screenshot of the robot can be seen here (https://www.dropbox.com/s/nbcbqffapgskg ... 2.png?dl=0).

The hexapod consists of 3 motors in each leg. I want to know if there is any collision of legs. The collision can be in various cases such as following-
  • One leg to another leg collision
  • Leg to center body collision
  • Leg to same leg collision
I am trying to add objects in "Collision Detection" module, in order to check any collision in between. But the problem is that there exist so many combinations as mentioned above that it seems too much troublesome.

Based on the various collisions as mentioned above, can you please tell me a better way to do the same? I just want to know if there is any collision.

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

Re: [Hexapod] Too many objects to add in collision check

Post by coppelia » 27 Feb 2018, 10:39

Hello,

if you just want to test for collision (but not react to collision) inside of your robot model, you can do following:
  • Create a collection that includes all collidable objects in your robot model. e.g. name it myRobotCollisionShapes
  • Then you can test collision of myRobotCollisionShapes VS myRobotCollisionShapes.
  • from code, you could do: sim.checkCollision(myRobotCollisionShapes,myRobotCollisionShapes)
Testing a collection against itself will basically test each item in the collection against each other items (i.e. an item will not be tested against itself obviously, since that doesn't make sense)

Cheers

ravi
Posts: 73
Joined: 24 Oct 2016, 08:00

Re: [Hexapod] Too many objects to add in collision check

Post by ravi » 27 Feb 2018, 12:04

Thank you very much. I followed your suggestion and made a collection. Please see the screenshot below-
https://www.dropbox.com/s/u5yj2e13qh31w ... n.png?dl=0

I am using remote API in Python. I am wondering how do I call the sim.checkCollision function from remote API? Any suggestions, please?

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

Re: [Hexapod] Too many objects to add in collision check

Post by coppelia » 28 Feb 2018, 09:16

Call that function in the sensing phase of a non-threaded child script, and set a signal (e.g. sim.setIntegerSignal). Then you can stream back the signal value to your remote API client via simxGetIntegerSignal.

Cheers

ravi
Posts: 73
Joined: 24 Oct 2016, 08:00

Re: [Hexapod] Too many objects to add in collision check

Post by ravi » 28 Feb 2018, 13:24

Thank you very much. I followed your suggestion. However, I am getting signal 1 everytime, which means it is detecting collision every time (in every position)

Code: Select all

vrep.simxGetIntegerSignal(self.clientID, self.collisionSignal, vrep.simx_opmode_buffer)[1]
I suspect about the shapes added in the collection. Please see the screenshot below showing the shapes in collection-

https://www.dropbox.com/s/gwlrsgo9wdso7 ... n.png?dl=0

Is it looking fine to you? I am worried.

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

Re: [Hexapod] Too many objects to add in collision check

Post by coppelia » 01 Mar 2018, 10:07

If you are checking for collision between visible shapes, then it will very often happen that they slightly collide. You can visualize the exact location where they collide by creating a collision object with the collection-collection pair, checking the Comp. coll. contour (shapes only) box and running the simulation.
Make sure to remove that collision object afterwards, since it will otherwise waste computation time if you always check twice for collision (once explicitely, once implicitely via the collision object)

Cheers

ravi
Posts: 73
Joined: 24 Oct 2016, 08:00

Re: [Hexapod] Too many objects to add in collision check

Post by ravi » 01 Mar 2018, 12:20

The collision detection module turned entire hexapod red. Please see the screenshot below-
https://www.dropbox.com/s/o0rtdkwqq7076vx/red.png?dl=0

Please see the objects in the collection below-
https://www.dropbox.com/s/1mw5a9qd9wq4h ... n.png?dl=0

My objective is to find the collision (if any) such as-
  • One leg to another leg collision
  • Leg to center body collision
  • Leg to same leg collision
The reason, why I am checking collision is related to my custom made controller. The controller sometimes generates a set of joint angles which lead to a collision. I want to mark such set of joint angles as invalid. Note that it is an intended behavior of this controller to generate invalid joint angles sometimes.

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

Re: [Hexapod] Too many objects to add in collision check

Post by coppelia » 02 Mar 2018, 09:59

Your collection seems to be strange, since it also includes joints (and joints an not collidable objects).

If you look carefully at your screenshot, you will see that several consecutive shapes are colliding (notice the white collision contour in the scene).

Cheers

ravi
Posts: 73
Joined: 24 Oct 2016, 08:00

Re: [Hexapod] Too many objects to add in collision check

Post by ravi » 03 Mar 2018, 14:40

I made sure that none of the joint is selected while defining my collection of collidable objects. I tried various other combinations but didn't work.

Please see the below the scene file:
https://www.dropbox.com/s/p1einbv44uddf ... 2.ttt?dl=0

Any workaround, please?

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

Re: [Hexapod] Too many objects to add in collision check

Post by coppelia » 05 Mar 2018, 07:28

You didn't understand what I wrote previously: start your simulation and carefully look at the robot: you'll notice that it is red, but there are white collision contours visible!! Those collision contours represent collisions between adjacent shapes.
You either need to modify the shapes, or shift them a little bit until they do not collide anymore.

You can even see it when simulation is not running: each motor's black axis will collide with the robot's white shapes.

Cheers

Post Reply