google-deepmind / mujoco

Multi-Joint dynamics with Contact. A general purpose physics simulator.
https://mujoco.org
Apache License 2.0
7.82k stars 780 forks source link

Simulate a flexible rod #1058

Closed fukangl closed 12 months ago

fukangl commented 12 months ago

Hi, I am new to Mujoco and am currently attempting to simulate a soft robot arm in Mujoco. Is there a reference or guide available that can help me construct a model of a flexible metal rod(as shown in the red color part of the picture) in Mujoco?

IMG_3364

yuvaltassa commented 12 months ago

https://www.youtube.com/watch?v=4DvGe-BodFU

https://github.com/google-deepmind/mujoco/blob/main/model/plugin/elasticity/coil.xml

fukangl commented 11 months ago

Hi @yuvaltassa ,

I employed four slider joints to manage the tendon's motion. The actuator settings are as follows. However, there is an unexpected behavior where moving one slider in a particular direction causes the other sliders to move as well. Is there a solution to rectify this issue?

<actuator >
        <!--        -->
        <position name="slider_d11" joint="slider_d11" ctrllimited="false"  ctrlrange="-0.3 0.3"  kp="100"/>
        <position name="slider_d12" joint="slider_d12" ctrllimited="false"  ctrlrange="-0.3 0.3"  kp="100"/>
        <position name="slider_d21" joint="slider_d21"  ctrllimited="false" ctrlrange="-0.3 0.3"  kp="100"/>
        <position name="slider_d22" joint="slider_d22"  ctrllimited="false" ctrlrange="-0.3 0.3"  kp="100"/>
</actuator>

Screenshot from 2023-09-26 17-16-07

Here is a video

https://github.com/google-deepmind/mujoco/assets/68177540/6fbe45cc-a808-4966-9fc2-20e1cf059350

fukangl commented 11 months ago

Another question is that, in the real-world model, the tendon is anchored to a single disk and passes through a series of holes located in the bottom disks. The interaction between the tendon and the hole's surface is primarily characterized by pressure and friction.

In our simulation model, we assign a geom and a site at the location of each hole. The tendon is then constrained to traverse through these geoms. These geoms are separated by sites. However, this will make the pulling forces between the disks in the simulation.

Is there a method to enable the tendon to pass through multiple geoms without requiring the insertion of sites between them? Alternatively, are there strategies to avoid the pulling forces between the disks in the simulation?

yuvaltassa commented 11 months ago

First of all, this is a very cool model!

  1. Regarding your message from 2 days ago, it's not clear to me what is the problem that you're trying to fix. Sounds like maybe you want higher gains in your actuators?

  2. Regarding "Is there a method to enable the tendon to pass through multiple geoms without requiring the insertion of sites between them?", the answer is no. (This makes the tendon path not analytically computable).

  3. "Alternatively, are there strategies to avoid the pulling forces between the disks in the simulation?" It's not clear to me what you are asking, how could the pulling forces be avoided, this seems to not make physical sense.

Here's what I propose. Delete all the geoms in the path of your tendons, use only sites. I think this will help you reason about your model, also it's not at all clear that you need the geoms at all as the holes are so small.

fukangl commented 11 months ago

Hi @yuvaltassa , Thank you for your reply!

1.For the first question, our objective is to maintain the static position of other actuators while controlling the movement of a single actuator in one direction. For instance, when we command one actuator to move 10cm in a specific direction (as depicted in the image on the right below), it is essential that the remaining actuators remain stationary (see the image on the left below).

Screenshot from 2023-09-28 11-39-53

  1. If we route the tendon through multiple sites on the disks, it will cause these disks to be pulled, which differs from real-world behavior. In reality, the tendon should only exert pulling force on the disk to which one of its ends is connected. The interaction between the tendon and other disks is primarily characterized by the pressure and friction applied to the holes.
yuvaltassa commented 11 months ago
  1. I recommend tweaking actuator gains and possibly adding damping (in case high gains lead to instability).
  2. The tendons are not "tied" to sites on the path, they are only way points. A site on the path is like a hole of 0 radius, so I'm not sure I understand what you're saying.
fukangl commented 11 months ago

So, What kinds of forces does the tendon exert on the disks with holes?

yuvaltassa commented 11 months ago

It can only push on it sideways (no friction). More generally, think about the change in qpos that would cause a change to the length of the tendon. That (and only that) is the direction of force that the tendon can apply.

fukangl commented 11 months ago

We choose to affix one end of the tendon to a specific site within a body. To actuate the tendon, we reset the position of the body. Our objective is to maintain a constant length for the tendon throughout this operation. However, an issue arises as the length of the tendon falls outside the designated range (e.g., range="0.455 0.47"), with the sensor monitoring value measuring approximately 0.42. Are there any solutions to address this problem?

fukangl commented 11 months ago

When we employ equality constraints to regulate the length of the tendon, it appears that the tendon's length still exceeds the specified range. Could you please provide some guidance on how to address this issue?

yuvaltassa commented 11 months ago

Constraints in MuJoCo are not hard constraints. Use the appropriate attributes to make them as hard as you like (note that these apply both to the bilateral (equality) and unilateral (spatial) solver parameters). Probably the easiest thing is to make the range a bit smaller. I'm sure your physical tendon can also stretch a bit. You can try to do some careful system identification to get constraint parameters that match your tendon material.

fukangl commented 11 months ago

We first use the sensor to read the initial length of the tendon and want to keep it as constant. For example the length=0.50, we make the range is "0.50 0.51". BUt when we drive the tendon, its length will be ~ 0.46.

yuvaltassa commented 11 months ago

Surely there is a force on the tendon that is fighting with the constraint?

Make a model that only has the tendon and play with the solver parameters of whatever constraint you are using to understand the relationship. You basically have a nonlinear elastic force-length relationship that you can tune.