Skip to content

Jt/port - #40

Open
JoshuaTchou wants to merge 16 commits into
portfrom
jt/port
Open

Jt/port#40
JoshuaTchou wants to merge 16 commits into
portfrom
jt/port

Conversation

@JoshuaTchou

Copy link
Copy Markdown
Collaborator

Issue ticket number and link

Fixes # (issue)

Describe your changes

Hardcoded njmax and opt.ccd_iterations for MiniCheetah instances because run-time warnings were telling me to increase the values. This is done in mujoco_backend_base.py._load_model().

Instructions for reviewers

The desired behavior is that the runtime warnings disappear and the values njmax and ccd_iterations are actually changed when training MiniCheetah or subclasses

Checklist before requesting a review

  • This is expected to break regression tests.
  • [x ] I have assigned a reviewer
  • I have added the PR to the project, and tagged with with priority
  • If it is a core feature, I have added tests.
  • [ x] I have set up pre-commit hooks with ruff, or run ruff format . manually

@JoshuaTchou
JoshuaTchou requested a review from sheim June 24, 2026 17:06
Comment thread gym/envs/base/mujoco_backend_base.py Outdated
from gym import LEGGED_GYM_ROOT_DIR
from gym.envs.base.sim_backend import SimBackend

from gym.envs.mini_cheetah.mini_cheetah_config import MiniCheetahCfg

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't want to add code specific to a single robot to a file that should be general across the entire framework. Instead, we should set default value or read the values from the config if they exist.

c[:, 1] = torch.clamp(c[:, 1] + self.increment_y, max=self.max_vel_sideways)
elif keycode == KEY_PERIOD:
c[:, 1] = torch.clamp(c[:, 1] - self.increment_y, min=-self.max_vel_sideways)
c[:, 1] = torch.clamp(

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update unrelated to the PR

Comment thread pyproject.toml Outdated
dependencies = [
"mujoco>=3.6",
"torch",
"torch>=2.0",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this needed? Or what was the issue?

@sheim sheim left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some issues, especially with things implemented in the environment directly instead of through configs. See comments.

Comment thread gym/envs/mini_cheetah/mini_cheetah.py Outdated
super().__init__(
gym, sim, cfg, sim_params, sim_device, headless, backend=backend
)
self.states_to_log = [

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to have specific things like this in the environment class, this leads to having to update code ad hoc, instead of changing things in the config file. The point is to use the getters/setters, so that the environment implementation is agnostic (unaware) of any details like how the policy is implemented, how plotting/logging is handled etc.

Comment thread gym/envs/mini_cheetah/mini_cheetah.py Outdated
import torch

from gym.envs.base.legged_robot import LeggedRobot
# from learning.utils.logger.SaveStates import (

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zap stale commented code

Comment thread gym/envs/base/mujoco_warp_backend.py Outdated

self.root_states[...] = (
self._root_states_t
) # fixes root_states from not being updated

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zap comment.

Comment thread gym/envs/base/mujoco_backend_base.py Outdated
spec = self._load_urdf_spec(asset_path)
spec.compiler.balanceinertia = True

# Disable fusing links connected with rigid joints

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean Code: avoid comments, they get stale and obsolete and eventually lead to more confusion than clarity. Instead, code should be readable.

In this case, I would put the False into a config setting with a name that makes it obvious what it is, e.g. fuse_rigid_joints = False (in the config file) and here spec.compiler.fusestatic = myconfig.fuse_rigid_joints

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh there is a setting for this in the config file already, config.asset.collapse_fixed_joints

Comment thread gym/envs/base/mujoco_backend_base.py Outdated
@@ -94,6 +94,9 @@ def _load_model(self, cfg) -> mujoco.MjModel:
spec = self._load_urdf_spec(asset_path)
spec.compiler.balanceinertia = True

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to the comment below. No idea what this does.

tau_ff = 4 * [18, 18, 28]
commands = [3, 1, 3]

class mjspec_attributes:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be named in a more readable way.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, should probably live in legged_robot_config.py.

Comment thread learning/runners/on_policy_runner.py Outdated
logger.toc("runtime")
logger.print_to_terminal()

# save_to_log_buffers(self.env, self.env.states_to_log)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zap

Comment thread learning/runners/on_policy_runner.py Outdated
self.save()
self.save()

# save_histogram_from_env(self.env, self.env.states_to_log)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zap

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

Successfully merging this pull request may close these issues.

2 participants