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

[Bug][Mac]: unsupported operand type(s) for +: 'NoneType' and 'float' #694

Open
guotong1988 opened this issue Feb 8, 2025 · 0 comments
Open
Labels
bug Something isn't working

Comments

@guotong1988
Copy link

guotong1988 commented Feb 8, 2025

Bug Description

try to run advanced_hybrid_robot.py on MacBook [CPU]

Steps to Reproduce

import numpy as np
import genesis as gs


########################## init ##########################
gs.init(seed=0, precision="32", logging_level="debug")

######################## create a scene ##########################
dt = 3e-3
scene = gs.Scene(
    sim_options=gs.options.SimOptions(
        substeps=10,
    ),
    viewer_options=gs.options.ViewerOptions(
        camera_pos=(1.5, 1.3, 0.5),
        camera_lookat=(0.0, 0.0, 0.0),
        camera_fov=40,
    ),
    rigid_options=gs.options.RigidOptions(
        dt=dt,
        gravity=(0, 0, -9.8),
        enable_collision=True,
        enable_self_collision=False,
    ),
    mpm_options=gs.options.MPMOptions(
        dt=dt,
        lower_bound=(0.0, 0.0, -0.2),
        upper_bound=(1.0, 1.0, 1.0),
        gravity=(0, 0, 0),  # mimic gravity compensation
        enable_CPIC=True,
    ),
    vis_options=gs.options.VisOptions(
        show_world_frame=True,
        visualize_mpm_boundary=False,
    ),
)

########################## entities ##########################
scene.add_entity(morph=gs.morphs.Plane())

robot = scene.add_entity(
    morph=gs.morphs.URDF(
        file="urdf/simple/two_link_arm.urdf",
        pos=(0.5, 0.5, 0.3),
        euler=(0.0, 0.0, 0.0),
        scale=0.2,
        fixed=True,
    ),
    material=gs.materials.Hybrid(
        mat_rigid=gs.materials.Rigid(
            gravity_compensation=1.0,
        ),
        mat_soft=gs.materials.MPM.Muscle(  # to allow setting group
            E=1e4,
            nu=0.45,
            rho=1000.0,
            model="neohooken",
        ),
        thickness=0.05,
        damping=1000.0,
    ),
)

ball = scene.add_entity(
    morph=gs.morphs.Sphere(
        pos=(0.8, 0.6, 0.1),
        radius=0.1,
    ),
    material=gs.materials.Rigid(rho=1000, friction=0.5),
)

########################## build ##########################
scene.build()

########################## run ##########################



def run_sim(scene, robot):
    scene.reset()
    for i in range(1000):
        dofs_ctrl = np.array(
            [
                1.0 * np.sin(2 * np.pi * i * 0.001),
            ]
            * robot.n_dofs
        )

        robot.control_dofs_velocity(dofs_ctrl)

        scene.step()

gs.tools.run_in_another_thread(fn=run_sim, args=(scene, robot))
scene.viewer.start()

Relevant log output

Traceback (most recent call last):
  File "/Users/guotong/Downloads/Genesis-0.2.1/examples/tutorials/advanced_hybrid_robot.py", line 41, in <module>
    robot = scene.add_entity(
            ^^^^^^^^^^^^^^^^^
  File "/Users/guotong/Downloads/Genesis-0.2.1/genesis/utils/misc.py", line 38, in wrapper
    return method(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/guotong/Downloads/Genesis-0.2.1/genesis/engine/scene.py", line 359, in add_entity
    entity = self._sim._add_entity(morph, material, surface, visualize_contact)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/guotong/Downloads/Genesis-0.2.1/genesis/engine/simulator.py", line 149, in _add_entity
    entity = HybridEntity(
             ^^^^^^^^^^^^^
  File "/Users/guotong/Downloads/Genesis-0.2.1/genesis/engine/entities/hybrid_entity.py", line 70, in __init__
    part_soft = func_instantiate_soft_from_rigid(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/guotong/Downloads/Genesis-0.2.1/genesis/engine/entities/hybrid_entity.py", line 427, in default_func_instantiate_soft_from_rigid
    part_soft = scene.add_entity(
                ^^^^^^^^^^^^^^^^^
  File "/Users/guotong/Downloads/Genesis-0.2.1/genesis/utils/misc.py", line 38, in wrapper
    return method(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/guotong/Downloads/Genesis-0.2.1/genesis/engine/scene.py", line 359, in add_entity
    entity = self._sim._add_entity(morph, material, surface, visualize_contact)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/guotong/Downloads/Genesis-0.2.1/genesis/engine/simulator.py", line 137, in _add_entity
    entity = self.mpm_solver.add_entity(self.n_entities, material, morph, surface)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/guotong/Downloads/Genesis-0.2.1/genesis/engine/solvers/mpm_solver.py", line 213, in add_entity
    entity = MPMEntity(
             ^^^^^^^^^^
  File "/Users/guotong/Downloads/Genesis-0.2.1/genesis/engine/entities/mpm_entity.py", line 26, in __init__
    super().__init__(
  File "/Users/guotong/Downloads/Genesis-0.2.1/genesis/engine/entities/particle_entity.py", line 69, in __init__
    self.sample()
  File "/Users/guotong/Downloads/Genesis-0.2.1/genesis/engine/entities/particle_entity.py", line 181, in sample
    particles_i += np.array(morph_i.pos)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'
[Genesis] [20:48:38] [INFO] 💤 Exiting Genesis and caching compiled kernels...

Environment

  • OS: Apple M3 Pro
  • CPU

Release version or Commit ID

tag v0.2.1

@guotong1988 guotong1988 added the bug Something isn't working label Feb 8, 2025
@guotong1988 guotong1988 changed the title [Bug]: unsupported operand type(s) for +: 'NoneType' and 'float' [Bug][Mac]: unsupported operand type(s) for +: 'NoneType' and 'float' Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant