Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGs REPORT #212

Open
jindadu00 opened this issue Dec 21, 2024 · 1 comment
Open

BUGs REPORT #212

jindadu00 opened this issue Dec 21, 2024 · 1 comment

Comments

@jindadu00
Copy link

jindadu00 commented Dec 21, 2024

hello, I met some bugs when I tried to simulate the motion of Allegro Hand.

  1. I cannot load the URDF files running code
import genesis as gs
import numpy as np
gs.init(backend=gs.gpu)

scene = gs.Scene(show_viewer=True)
plane = scene.add_entity(gs.morphs.Plane())

allegro = scene.add_entity(
    gs.morphs.URDF(
        file  = 'allegro_hand_description/allegro_hand_description_left.urdf',
        pos   = (0.0, 0.0, 0.5),
        euler = (0, 90, 0),
    ),
)

and raised an ERROR

**The above is omitted**
  File "/home/xxx/anaconda3/envs/genesis/lib/python3.9/site-packages/genesis/ext/urdfpy/urdf.py", line 144, in <listcomp>
    v = [t._from_xml(n, path) for n in vs]
  File "/home/xxx/anaconda3/envs/genesis/lib/python3.9/site-packages/genesis/ext/urdfpy/urdf.py", line 1942, in _from_xml
    kwargs["trans_type"] = node.find("type").text
AttributeError: 'NoneType' object has no attribute 'text'

The URDF files is downloaded from "allegro_hand_description_left.urdf".

  1. I finally managed to load the MJCF which is downloaded from "wonik_allegro" but the PD control seemed strange. My code is
import genesis as gs
import numpy as np
gs.init(backend=gs.gpu)

scene = gs.Scene(show_viewer=True)
plane = scene.add_entity(gs.morphs.Plane())

allegro = scene.add_entity(
    gs.morphs.MJCF(
        file  = 'wonik_allegro/left_hand.xml',
        pos   = (0.0, 0.0, 0.5),
        euler = (0, 90, 0),
    ),
)

scene.build()


jnt_names = [
    'ffj0','ffj1','ffj2','ffj3',
    'mfj0','mfj1','mfj2','mfj3',
    'rfj0','rfj1','rfj2','rfj3',
    'thj0','thj1','thj2','thj3',
]
dofs_idx = [allegro.get_joint(name).dof_idx_local for name in jnt_names]
print(dofs_idx)
# set positional gains
allegro.set_dofs_kp(
    kp             = np.array([4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500]),
    dofs_idx_local = dofs_idx,
)
# set velocity gains
allegro.set_dofs_kv(
    kv             = np.array([4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500, 4500]),
    dofs_idx_local = dofs_idx,
)
# set force range for safety
allegro.set_dofs_force_range(
    lower          = np.array([-100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100]),
    upper          = np.array([ 100,  100,  100,  100,  100,  100,  100,  100,  100, -100, -100, -100, -100, -100, -100, -100]),
    dofs_idx_local = dofs_idx,
)

pos0  = np.zeros(16)
pos1 = np.ones(16) * 0.1
pos2 = np.ones(16) * 0.2
pos3 = np.ones(16) * 0.3


# PD control
for i in range(1250):
    if i == 0:
        allegro.control_dofs_position(
            pos1,
            dofs_idx,
        )
    elif i == 250:
        allegro.control_dofs_position(
            pos2,
            dofs_idx,
        )
    elif i == 500:
        allegro.control_dofs_position(
            pos3,
            dofs_idx,
        )
    elif i == 750:
        # control first dof with velocity, and the rest with position
        allegro.control_dofs_position(
            pos1[1:],
            dofs_idx[1:],
        )
        allegro.control_dofs_velocity(
            pos1[:1],
            dofs_idx[:1],
        )
    elif i == 1000:
        allegro.control_dofs_force(
            pos0,
            dofs_idx,
        )
    # This is the control force computed based on the given control command
    # If using force control, it's the same as the given control command
    print('control force:', allegro.get_dofs_control_force(dofs_idx))

    # This is the actual force experienced by the dof
    print('internal force:', allegro.get_dofs_force(dofs_idx))

    scene.step()

There is only 9 dofs (the dof of Allegro is 16) is controled while the control force of other dofs is max/min whose logs are like:

[Genesis] [23:30:45] [INFO] Running at 59.94 FPS.
control force: tensor([  -0.8241,   -0.8601,   -0.8363,   -0.8277,   -0.8241,   -0.8601,
          -0.8363,   -0.8277,   -0.8274, -100.0000, -100.0000, -100.0000,
        -100.0000, -100.0000, -100.0000, -100.0000], device='cuda:0')
internal force: tensor([  -0.8359,   -0.8359,   -0.8359,   -0.8359,   -0.8359,   -0.8359,
          -0.8359,   -0.8359,   -0.8355,  -99.1898,  -99.0691,  -99.0581,
        -100.0113,  -99.0642,  -99.2019,  -99.0663], device='cuda:0')
[Genesis] [23:30:45] [INFO] Running at 59.94 FPS.
control force: tensor([  -0.8159,   -0.8519,   -0.8281,   -0.8194,   -0.8159,   -0.8519,
          -0.8281,   -0.8194,   -0.8194, -100.0000, -100.0000, -100.0000,
        -100.0000, -100.0000, -100.0000, -100.0000], device='cuda:0')
internal force: tensor([  -0.8275,   -0.8275,   -0.8275,   -0.8276,   -0.8275,   -0.8275,
          -0.8275,   -0.8276,   -0.8273,  -99.1892,  -99.0689,  -99.0562,
        -100.0092,  -99.0619,  -99.1997,  -99.0630], device='cuda:0')

[doge] The recording is like

4bd8dfb585e073dd206ca7844861864b.mp4

Sincerely looking forward to your respond.

@ziyanx02
Copy link
Collaborator

  • The control force reaches the limit due to high values of kp and kv. With kp=4500, even a slight deviation from the default position (e.g., 0.03 radius or 2 degrees) results in a torque greater than 100.
  • I suggest checking dofs_idx to verify if all joints are actuated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants