google-deepmind / google-deepmind/mujoco

Scalar Joint with 3D Path (Curved Rail/Track Support)

Open
#2,452 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
15.2k
Forks
1.8k
Avg merge
10d 16h
Merged PRs (30d)
25

Description

### The feature, motivation and pitch

I propose a joint type that creates motion DoFs along a 3D path, similar to a roller coaster rail, [bead maze](https://en.wikipedia.org/wiki/Bead_maze), or [curved robot 7th axis](https://www.hepcomotion.com/product/curved-rails-and-track-system-components/mhd-7th-axis-track-system/). This would allow 1-DoF movement along arbitrary curved trajectories without having application-side logic to implement it.

If not in the kinematic tree, this feature would also be super helpful if implemented as a constraint.

### Alternatives

Currently, I implement this behavior with an under-constrained body and actuator control. This introduces additional gain tuning and also requires the model to be developed in Python (or c++) instead of in `simulate`. Nor does it guarantee strict adherence to the path as a kinematic constraint would.

[rail.zip](https://github.com/user-attachments/files/18949974/rail.zip)

mjcf model

```xml
























```

python

```python
import mujoco
import mujoco.viewer
import numpy as np
import time
import os

PATH = os.path.join(os.path.dirname(__file__), 'rail.xml')

def helix(j):
"""This could be any scalar -> 3D mapping. Here we use a helix."""
theta = 2 * np.pi * j * 2
x = np.cos(theta)
y = np.sin(theta)
z = 0.5 * j
return np.array([x, y, z])

model = mujoco.MjModel.from_xml_path(PATH)
data = mujoco.MjData(model)

viewer = mujoco.viewer.launch_passive(model, data)

while viewer.is_running():
target_pos = helix(data.actuator("joystick").ctrl.item())
data.actuator("actuator_x").ctrl = target_pos[0]
data.actuator("actuator_y").ctrl = target_pos[1]
data.actuator("actuator_z").ctrl = target_pos[2]

mujoco.mj_step(model, data)
viewer.sync()
time.sleep(model.opt.timestep)

```

https://github.com/user-attachments/assets/be6c87f5-867c-4216-bb7e-0e1a543d2bdf

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.