Skip to content

Commit

Permalink
musculoskeletal dog creation
Browse files Browse the repository at this point in the history
  • Loading branch information
vittorione94 committed Sep 9, 2024
1 parent f2f0e23 commit 00b1761
Show file tree
Hide file tree
Showing 606 changed files with 90,956 additions and 1,003 deletions.
7 changes: 4 additions & 3 deletions dm_control/_render/pyopengl/egl_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,13 @@ def _platform_init(self, unused_max_width, unused_max_height):
"""Initialization this EGL context."""
num_configs = ctypes.c_long(0)
config_size = 1
config = EGL.EGLConfig()
# ctypes syntax for making an array of length config_size.
configs = (EGL.EGLConfig * config_size)()
EGL.eglReleaseThread()
EGL.eglChooseConfig(
EGL_DISPLAY,
EGL_ATTRIBUTES,
ctypes.byref(config),
configs,
config_size,
num_configs)
if num_configs.value < 1:
Expand All @@ -117,7 +118,7 @@ def _platform_init(self, unused_max_width, unused_max_height):
'desired attributes: {}'.format(EGL_ATTRIBUTES))
EGL.eglBindAPI(EGL.EGL_OPENGL_API)
self._context = EGL.eglCreateContext(
EGL_DISPLAY, config, EGL.EGL_NO_CONTEXT, None)
EGL_DISPLAY, configs[0], EGL.EGL_NO_CONTEXT, None)
if not self._context:
raise RuntimeError('Cannot create an EGL context.')

Expand Down
17 changes: 16 additions & 1 deletion dm_control/autowrap/header_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ def _nested_if_else(if_, pred, else_, endif, match_if_true, match_if_false):
return ifelse


def _nested_ifn_else(ifn_, pred, else_, endif, match_if_true, match_if_false):
"""Constructs a parser for (possibly nested) if...(else)...endif blocks."""
ifnelse = pp.Forward()
ifnelse << pp.Group( # pylint: disable=expression-not-assigned
ifn_ +
pred("predicate") +
pp.ZeroOrMore(match_if_true | ifnelse)("if_false") +
pp.Optional(else_ +
pp.ZeroOrMore(match_if_false | ifnelse)("if_true")) +
endif)
return ifnelse


# Some common string patterns to suppress.
# ------------------------------------------------------------------------------
(LPAREN, RPAREN, LBRACK, RBRACK, LBRACE, RBRACE, SEMI, COMMA, EQUAL, FSLASH,
Expand Down Expand Up @@ -189,7 +202,9 @@ def _nested_if_else(if_, pred, else_, endif, match_if_true, match_if_false):
UNCOND_DECL = DEF_FLAG | DEF_CONST | TYPE_DECL

# Declarations inside (possibly nested) #if(n)def... #else... #endif... blocks.
COND_DECL = _nested_if_else(IFDEF, NAME, ELSE, ENDIF, UNCOND_DECL, UNCOND_DECL)
COND_DECL = _nested_if_else(
IFDEF, NAME, ELSE, ENDIF, UNCOND_DECL, UNCOND_DECL
) | _nested_ifn_else(IFNDEF, NAME, ELSE, ENDIF, UNCOND_DECL, UNCOND_DECL)
# Note: this doesn't work for '#if defined(FLAG)' blocks

# e.g. "mjtNum gravity[3]; // gravitational acceleration"
Expand Down
229 changes: 229 additions & 0 deletions dm_control/blender/fake_core/bpy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
# Copyright 2023 The dm_control Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================

"""Fake Blender bpy module."""

from __future__ import annotations # postponed evaluation of annotations

from typing import Any, Collection, Sequence

from dm_control.blender.fake_core import mathutils

# pylint: disable=invalid-name
# pylint: disable=missing-class-docstring


class WindowManager:

def progress_begin(self, start: int, end: int):
pass

def progress_update(self, steps_done: int):
pass

def progress_end(self):
pass


class context:

@property
def window_manager(self) -> WindowManager:
return WindowManager()

@staticmethod
def evaluated_depsgraph_get():
pass


class types:

class Constraint:

@property
def name(self):
pass

@property
def owner_space(self):
pass

class Scene:
pass

class Object:

@property
def name(self) -> str:
raise NotImplementedError()

@property
def parent(self) -> types.Object | None:
pass

@property
def parent_bone(self) -> types.Bone | None:
pass

@property
def data(self):
pass

@property
def pose(self):
pass

@property
def matrix_world(self) -> mathutils.Matrix:
raise NotImplementedError()

@matrix_world.setter
def matrix_world(self, _) -> mathutils.Matrix:
raise NotImplementedError()

def select_set(self, _):
pass

def to_mesh(self):
pass

def evaluated_get(self, _) -> types.Object:
pass

@property
def mode(self) -> str:
return 'OBJECT'

@property
def type(self):
pass

def update_from_editmode(self):
pass

class Bone:

@property
def name(self) -> str:
raise NotImplementedError()

@property
def parent(self) -> types.Bone | None:
pass

@property
def matrix_local(self) -> mathutils.Matrix:
raise NotImplementedError()

@property
def matrix(self) -> mathutils.Matrix:
raise NotImplementedError()

class bpy_struct:
pass

class Context:

@property
def scene(self) -> types.Scene:
pass

class Light:

@property
def type(self):
pass

@property
def use_shadow(self):
pass

@property
def color(self) -> mathutils.Color:
raise NotImplementedError()

@property
def linear_attenuation(self):
pass

@property
def quadratic_attenuation(self):
pass

class LimitRotationConstraint(Constraint):
pass

class LimitLocationConstraint(Constraint):
pass

class Material:

@property
def name(self) -> str:
raise NotImplementedError()

@property
def specular_intensity(self):
pass

@property
def metallic(self):
pass

@property
def roughness(self) -> float:
raise NotImplementedError()

@property
def diffuse_color(self) -> Sequence[float]:
raise NotImplementedError()

class Mesh:

@property
def name(self) -> str:
raise NotImplementedError()

def calc_loop_triangles(self):
pass

@property
def uv_layers(self) -> Any:
raise NotImplementedError()

@property
def loop_triangles(self) -> Collection[Any]:
raise NotImplementedError()

@property
def vertices(self) -> Any:
raise NotImplementedError()


class ops:

class object:

@staticmethod
def select_all(action):
pass

class export_mesh:

@classmethod
def stl(
cls, filepath, use_selection, use_mesh_modifiers, axis_forward, axis_up
):
pass
Loading

0 comments on commit 00b1761

Please sign in to comment.