Repository navigation
Are Mimic joints supported in mjlab? #664
|
Hello, thanks for your wonderful job, but i am now wondering if mimic-joint-gripper like Robotiq85 gripper support in mjlab, if yes, how can i create an actuator to control it? |
Replies: 6 comments 2 replies
|
Hello! You can use it with a tendon and equality constraint. You can find the Robotiq 2F-85 with those properties here : https://github.com/google-deepmind/mujoco_menagerie/blob/main/robotiq_2f85%2F2f85.xml#L165-L178 |
|
Hi, @saikishor, thanks for your quick response! I encountered an issue when using a tendon-based actuator in my MuJoCo XML. XML Definition<tendon>
<fixed name="split">
<joint joint="right_driver_joint" coef="0.5"/>
<joint joint="left_driver_joint" coef="0.5"/>
</fixed>
</tendon>
<equality>
<connect anchor="0 0 0" body1="right_follower" body2="right_coupler"
solimp="0.95 0.99 0.001" solref="0.005 1"/>
<connect anchor="0 0 0" body1="left_follower" body2="left_coupler"
solimp="0.95 0.99 0.001" solref="0.005 1"/>
<joint joint1="left_driver_joint" joint2="right_driver_joint"
polycoef="0 1 0 0 0"
solimp="0.95 0.99 0.001"
solref="0.005 1"/>
</equality>
<actuator>
<general
class="2f85"
name="fingers_actuator"
tendon="split"
forcerange="-5 5"
ctrlrange="0 255"
gainprm="0.3137255 0 0"
biasprm="0 -100 -10"/>
</actuator>Actuator Initialization CodeGRIPPER_ACTUATOR = XmlPositionActuatorCfg(
target_names_expr=(".*fingers_actuator",),
)ProblemThe system cannot find I get the following error: It seems that only joint names are being registered, but not the QuestionIs Any clarification would be greatly appreciated. Thanks! |
I'm not sure about this part. Maybe you can give it a shot. I'll let the maintainers answer to this |
|
Thanks for your quick response @saikishor . After digging into the source and understanding that XML actuators are matched strictly by Instead of trying to wrap the tendon-based Here is the minimal setup that seems to work correctly on my side: from mjlab.actuator import XmlPositionActuatorCfg, IdealPdActuatorCfg
GRIPPER_JOINT_PATTERN = (r".*right_driver_joint",)
def _make_gripper_pd_cfg() -> IdealPdActuatorCfg:
return IdealPdActuatorCfg(
target_names_expr=GRIPPER_JOINT_PATTERN,
stiffness=200.0,
damping=5.0,
effort_limit=5.0,
armature=0.001,
frictionloss=0.0,
)In def configure_spec_for_pd(spec: mujoco.MjSpec) -> None:
for actuator in tuple(spec.actuators):
if re.search(r"fingers_actuator$", actuator.name):
spec.delete(actuator)Then I register only the PD actuator in the articulation: ARTICULATION = EntityArticulationInfoCfg(
actuators=(
GRIPPER_ACTUATOR,
),
soft_joint_pos_limit_factor=0.95,
)Does this align with the intended design philosophy of mjlab when dealing with tendon-driven actuators? Or would you recommend extending Thanks again for the guidance! |
|
Hi, After some debugging, I found the root cause of the issue. The actuator lookup logic originally checked: actuator.target == target_nameHowever, this does not work correctly for actuators defined directly in the XML and using tendon-based actuators. Because its target(tendon) is not the target_name(joint). To make it work, I modified the actuator: With these changes, the actuator defined in the XML works as expected. Hope this helps anyone encountering a similar issue. |
|
Hi @CumulusAlpha, thanks for the detailed investigation! I want to clarify the intended usage. mjlab has two families of actuator configs: XML wrappers (e.g. Approach 1 (preferred): define the actuator in config Remove the XML actuator in import mujoco
from mjlab.actuator import IdealPdActuatorCfg
from mjlab.actuator.actuator import TransmissionType
def get_spec() -> mujoco.MjSpec:
spec = mujoco.MjSpec.from_file(...)
for actuator in list(spec.actuators):
if actuator.name == "fingers_actuator":
spec.delete(actuator)
return spec
IdealPdActuatorCfg(
target_names_expr=("split",),
transmission_type=TransmissionType.TENDON,
stiffness=200.0,
damping=5.0,
effort_limit=5.0,
)Approach 2: wrap the existing XML actuator If you want to preserve the original actuator gains from the menagerie model, you can wrap the existing from mjlab.actuator import XmlPositionActuatorCfg
from mjlab.actuator.actuator import TransmissionType
XmlPositionActuatorCfg(
target_names_expr=("split",), # the tendon name, not the actuator element name
transmission_type=TransmissionType.TENDON,
)Note that |
Good question. mjlab does not have a wrapper for
<general>actuators, and we don't plan to add one at this time. The reason is that<general>allows arbitrary gain/bias configurations, so there is no clean semantic for what the control input represents. The Xml* wrappers only cover the standard MuJoCo shortcuts where the control input has a clear meaning (desired position, desired velocity, desired force).The Robotiq's
<general>actuator is really just a PD controller with a rescaled control range. The [0, 255] input range exists (if I recall correctly) to match the real hardware interface, but under the hood the physics are: