## Connect two moving objects with rigid link

Typically: "How do I... ", "How can I... " questions
sample
Posts: 14
Joined: 27 Mar 2017, 21:30

### Connect two moving objects with rigid link

Hi coppelia!

My scene is given on the pictures below.
I have two modules, capable of moving in only one direction. What I want to accomplish is when these two modules are close to each other, I want them to align and form rigid connection. When connection is established I want them to continue motion together. I have tried solutions with magnets and I don't find them good enough because of the misalignment between the modules.

Is there any way to accomplish this?
Thank you!

https://imgur.com/44Yxd2F
https://imgur.com/ZPgM0DU

coppelia
Posts: 7441
Joined: 14 Dec 2012, 00:25

### Re: Connect two moving objects with rigid link

Hello,

if you want to force attachement of the two modules, then you could use a construction similar to following:

Code: Select all

Shape1 --> dummyA

shape2 --> forceSensor --> dummyB
When you want the two shapes to be rigidly connected at the position/orientation of their respective dummies, then use simSetLinkDummy. Make sure that the link type for each dummy was previously set to dynamics, overlap constraint. Practically, this will achieve a loop closure as described here.

Cheers

sample
Posts: 14
Joined: 27 Mar 2017, 21:30

### Re: Connect two moving objects with rigid link

That's the exactly what I was trying to accomplish. Thank you!

sample
Posts: 14
Joined: 27 Mar 2017, 21:30

### Re: Connect two moving objects with rigid link

Hi Coppelia, I have an additional question!
Is it possible (in similar fashion) to form rigid connection with the floor (not with the predefined spot but rather anywhere on the floor). To be more precise, when one half of the robot is rotated and base is facing floor (second image) I want that face to form rigid connection with the floor. I know it is possible to accomplish this using magnet, but I am trying to avoid that. Thank you!

image 1: neutral state

https://imgur.com/a/R8d1j

image 2: rotated blue half

https://imgur.com/a/IihqY

coppelia
Posts: 7441
Joined: 14 Dec 2012, 00:25

### Re: Connect two moving objects with rigid link

You can use the exact same approach. You will however have to correctly place the dummy attached to the floor before creating the connection.

Cheers

sample
Posts: 14
Joined: 27 Mar 2017, 21:30

### Re: Connect two moving objects with rigid link

coppelia wrote:
04 Feb 2018, 16:07
You can use the exact same approach. You will however have to correctly place the dummy attached to the floor before creating the connection.

Cheers
Hi Coppelia,

in simulations I do not know in advance where the connection will occur. Having that in mind, placing dummy on a preset location is not an option. Is there any way around it? I want my module to connect (attach itself) to the floor when quadratic side is facing the floor.

It would be ideal if I could establish rigid link with ResizableFloor_5_25 dummy, but it is not possible because in that case force sensor attached to my robot is not dynamically enabled (warning sign). Is this possible in any way?
Next option would be to place new dummy on the floor, make it a child object of the ResizableFloor_5_25-element, and to change it's position in respect to corresponding dummy on the robot (to match their positions when certain criteria is met). This solution works, but since I am using max floor dimension (25x25) I would have to add 25 dummies (one for each floor element), detect the matching one for the current robot position, re-position it, and form the link using simsetlinkdummy with that exact dummy. This might work but it is not elegant solution... Is there an easier way to do this?

coppelia
Posts: 7441
Joined: 14 Dec 2012, 00:25

### Re: Connect two moving objects with rigid link

Not sure why your solution is not elegant with the 25X25 sized floor: you are not required to attach the dummy to the floor just below. The dummy could also hang over the void, but still be attached to one floor element (basically constantly stay attached to one floor element, and only moving the dummy position just before attachement). Maybe I haven't understood your real problem..

Cheers

sample
Posts: 14
Joined: 27 Mar 2017, 21:30

### Re: Connect two moving objects with rigid link

coppelia wrote:
07 Feb 2018, 18:01
Not sure why your solution is not elegant with the 25X25 sized floor: you are not required to attach the dummy to the floor just below. The dummy could also hang over the void, but still be attached to one floor element (basically constantly stay attached to one floor element, and only moving the dummy position just before attachment). Maybe I haven't understood your real problem..

Cheers
Hi, I have managed to establish link but I get weird repellent force when the robot rotates to desired position. Basically robot gets rejected by the floor. It's easier to see than to explain, so here is my scene:

dummy_m2(attached to robot) should connect to Dummy (attached to floor element) and provide attraction force (like connection to the ground) required for robot to stand up (goal is to put red part above the blue one).

What's causing this repellent force?
Is dummy - dummy link set properly?

coppelia