google-deepmind / mujoco

Multi-Joint dynamics with Contact. A general purpose physics simulator.
https://mujoco.org
Apache License 2.0
7.73k stars 767 forks source link

Spherical robot internal joint configuration. #1474

Open LinShuang22 opened 5 months ago

LinShuang22 commented 5 months ago

Hi, @yuvaltassa I see the earlier issue #1310. I have a modeling issue similar to his, and I discussed it with you in that previous question.

My model is a spherical robot driven by an internal differential drive system. To avoid internal collisions, following the suggestions from the previous issue, I've made the car as a direct child body of the spherical shell. Now, the overall motion is not driven by the actual wheels and internal friction of the spherical shell. Instead, I directly make the internal car rotate around the sphere's center to achieve roll and turn, consequently driving the motion of the spherical shell.

I attempted to link the sum and difference of the two wheels with the overall turn and roll joints of the internal car using equality constraints. This visually gives the impression that the wheels are rolling internally.

This looks very promising, and everything behaves normally when the turn and roll joints run individually. However, when I move both joints simultaneously, the trajectory of the sphere deviates from expectations. For instance, when both turn and roll are in motion, such as at turn=0.0001 and roll=0.002 (values adjusted via gear), the trajectory of the sphere exhibits a wavelike pattern instead of the expected circular motion.

This appears to be a sequencing issue with the turn and roll joints. The joints of the car are not bound to its own coordinate system; when the roll joint rotates, the turn joint doesn't change accordingly.

How can I adjust the model to make the trajectory of the sphere match the expectations?

minimal XML ```XML ```

Here is a screenshot / video, illustrating my question: turn=0.0001, roll=0.002 图片

https://github.com/google-deepmind/mujoco/assets/119031680/9f8f80dd-d42f-4301-b9f2-8d5bf0755447

Balint-H commented 5 months ago

Cool model! A potential approach that could work well is using a single ball joint instead. Setting up actuators for ball joints is sometimes tricky, but in this case they seem to be doing what you are looking for. As far as the wheel rolling illusion goes, I hope it can be configured again with some tendon approach (or via script). Let me know if I misunderstood the desired behaviour.

Modified XML ```xml ```

https://github.com/google-deepmind/mujoco/assets/41113387/a12090f4-c1f4-411e-a8e1-510495162b3a

LinShuang22 commented 5 months ago

@Balint-H Thank you! The trajectory of the model you've demonstrated is indeed what I'm looking for! I learned from the XML Reference that the method of connecting the motion of the internal chassis with two wheels using tendon and equality seems to only apply to hinge and slide joints, and is not suitable for ball joints. Does this mean I cannot achieve the linkage between the wheels and the chassis in the XML file? Do I have to implement wheel animations through a Python script?

Balint-H commented 5 months ago

An Important thing I wanted to also mention about the ball joint approach, is that it also permits rotations in the direction normal to the wheel surfaces, which would not normally happen a lot. This can partially be mitigated by adding a velocity acutator like this:

<velocity name="roll_resist" joint="ball" ctrlrange="0 0" group="4" gear="0 10 0" kv="10"/> (might need to increase gearing and kv, and use implicit as the integrator option ) A velocity actuator is used as it will always be in the child body's reference frame, which is why the ball joint actuation works as well (position actuator would not work due to the unconstrained range of motion).

Connecting the rolling of the ball with the rolling of the wheels is likely only possible via script, since tendons don't support ball joints. Although, at least for fixed tendons, I don't think why a ball joint DoF may not be coupled with a scalar joint in principle, for purposes of actuation, so this could be a potential feature to consider implementing.