Skip to content

reference_generator refactoring #5

@LockedFlysher

Description

@LockedFlysher

Problem Description

in mpc_utils.py

hip = jnp.tile(p, n_contact) + foot0 @ jax.scipy.linalg.block_diag(*([Ryaw] * n_contact)).T

The variable is named hip but actually computes foot positions in global coordinates, not hip joint positions. This causes:

  • Semantic mismatch and confusion
  • Poor code readability
  • Maintenance difficulties

What the calculation does

  • p: Robot base position in global frame
  • foot0: Foot positions in local coordinates
  • Ryaw: Base yaw rotation matrix
  • Result: Foot positions in global frame

Proposed Solution

Rename the variable to accurately reflect its purpose:

# Recommended
foot_global_pos = jnp.tile(p, n_contact) + foot0 @ jax.scipy.linalg.block_diag(*([Ryaw] * n_contact)).T

# Alternative
feet_world_positions = jnp.tile(p, n_contact) + foot0 @ jax.scipy.linalg.block_diag(*([Ryaw] * n_contact)).T

Labels

bug code quality good first issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions