[PYTHON] Set spinning_friction in pybullet

This time, we will experiment with a parameter called spinning_friction. According to the quickstart guide, the difference from the previous rolling friction is as follows. I don't know if it's correct, but I understood it as a coefficient of friction with different orientations.

environment

What i did

Set spinning_friction in the urdf file.

I want to know the effect of the parameters, so I will make 3 sets. --a set <spinning_friction value =" 0.004 "/> in test_box07a.urdf <spinning_friction value =" 0.001 "/> in test_sphere05a.urdf --b set <spinning_friction value =" 0.004 "/> in test_box07b.urdf <spinning_friction value =" 0.004 "/> in test_sphere05b.urdf -C set <Spinning_friction value =" 0.001 "/> in test_box07c.urdf <spinning_friction value =" 0.004 "/> in test_sphere05c.urdf

The urdf file of a set is as follows. (B set, c set) And in test‗sphere05a.urdf, visual is box and collision is sphere.

test_box07a.urdf


<robot name="robot_name">
  <link name="link_name">
    <contact>
      <lateral_friction value="1.0"/>
      <rolling_friction value="0.0"/>
      <spinning_friction value="0.004"/>
    </contact>
    <inertial>
      <origin xyz="0.0 -1.0 -0.1" rpy="0.0 0.0 0.0"/>
      <mass value="0.0"/>
      <inertia ixx="0.0" ixy="0.0" ixz="0.0" iyy="0.0" iyz="0.0" izz="0.0"/>
    </inertial>
    <visual>
      <origin xyz="0.0 -1.0 -0.1" rpy="0.0 0.0 0.0"/>
      <geometry>
        <box size="0.8 0.8 0.2"/>
      </geometry>
      <material name="red">
        <color rgba="1.0 0.0 0.0 1.0"/>
      </material>
    </visual>
    <collision>
      <origin xyz="0.0 -1.0 -0.1" rpy="0.0 0.0 0.0"/>
      <geometry>
        <box size="0.8 0.8 0.2"/>
      </geometry>
    </collision>
  </link>
</robot>

test_sphere05a.urdf


<robot name="robot_name">
  <link name="link_name">
    <contact>
      <lateral_friction value="1.0"/>
      <rolling_friction value="0.0"/>
      <spinning_friction value="0.001"/>
    </contact>
    <inertial>
      <origin xyz="0.0 -1.0 0.5" rpy="0.0 0.0 0.0"/>
      <mass value="1.0"/>
      <inertia ixx="0.1" ixy="0.0" ixz="0.0" iyy="0.1" iyz="0.0" izz="0.1"/>
    </inertial>
    <visual>
      <origin xyz="0.0 -1.0 0.5" rpy="0.0 0.0 0.0"/>
      <geometry>
        <box size="0.4 0.4 0.4"/>
      </geometry>
      <material name="l_red">
        <color rgba="1.0 0.5 0.5 1.0"/>
      </material>
    </visual>
    <collision>
      <origin xyz="0.0 -1.0 0.5" rpy="0.0 0.0 0.0"/>
      <geometry>
        <sphere radius="0.2"/>
      </geometry>
    </collision>
  </link>
</robot>

applyExternalTorque

shpere05aid = p.loadURDF("test_sphere05a.urdf")
p.applyExternalTorque(shpere05aid, -1, [0,0,100], flags=p.LINK_FRAME)

I wanted to make it move like a top, so I use applyExternalTorque. Obtain the unique id at the time of loadURDF and give it to applyExternalTorque. The next -1 is base, [0,0,100] is torque, and flags = p.LINK_FRAME is the flag that gives torque in the local coordinate system.

The entire script is below.

import pybullet as p
import time
from PIL import Image

phisicsClient = p.connect(p.GUI)
p.setGravity(0,0,-10)
p.loadURDF("test_box07a.urdf")
p.loadURDF("test_box07b.urdf")
p.loadURDF("test_box07c.urdf")
sphere05aid = p.loadURDF("test_sphere05a.urdf")
sphere05bid = p.loadURDF("test_sphere05b.urdf")
sphere05cid = p.loadURDF("test_sphere05c.urdf")
p.applyExternalTorque(sphere05aid, -1, [0,0,100], flags=p.LINK_FRAME)
p.applyExternalTorque(sphere05bid, -1, [0,0,100], flags=p.LINK_FRAME)
p.applyExternalTorque(sphere05cid, -1, [0,0,100], flags=p.LINK_FRAME)

camera_img = p.getCameraImage(320,320)
imgs = [Image.fromarray(camera_img[2])]

for i in range(1200):
    p.stepSimulation()
    if i % 10 == 0:
        camera_img = p.getCameraImage(320,320)
        imgs.append(Image.fromarray(camera_img[2]))
    time.sleep(1./240.)
p.disconnect()

imgs[0].save("test_pybullet_09.gif", save_all = True, append_images = imgs[1:], duration=10, loop = 0)

Execute

The execution result is the following GIF animation. From the front, a set, b set, c set. test_pybullet_09.gif

The a set and c set kept spinning longer, and the b set was shorter than them. This time, it seems that the magnitude of friction is determined by the sum of the parameters given to the two sides. ∵a set: 0.004 + 0.001 = 0.005 b set: 0.004 + 0.004 = 0.008 c set: 0.001 + 0.004 = 0.005 However, it seems that lateral_friction also has an effect, so I do not know how to use it ...

Recommended Posts

Set spinning_friction in pybullet
Set ulimit in supervisor
Dynamically set env.hosts in fabric
Methods available in set type
Set up Nunjucks in Node.js
Set python test in jenkins
Set opset to embed in ONNX
To set default encoding to utf-8 in python
Associate the table set in python models.py
Set default values before commit in sqlalchemy.orm
Set up Pipenv in Pycharm in Windows environment