google-deepmind / mujoco

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

How to comprehend gear attribute in actuator(motor)? #179

Closed Coder-RG closed 2 years ago

Coder-RG commented 2 years ago

I am trying to figure out how to assign the gear attribute to motor in my quadrotor model. I found some code online where the gear values were set as 0 0 1 0 0 0.1. As I understand this, the first three values specify the force along the principal axis and the next three specify the torque. However, when I changed the torque value from 0.1 to 1. Then it did not show any difference.

Here is the actuator code I am using. The code works well but changing the last value from 0.1 to 1 does not have any effect, at least not noticeable.

    <actuator>
        <motor ctrllimited="true" ctrlrange="0.0 1.0" gear="0 0. 1. 0. 0. -1" site="motor1"/>
        <motor ctrllimited="true" ctrlrange="0.0 1.0" gear="0 0. 1. 0. 0. 1" site="motor2"/>
        <motor ctrllimited="true" ctrlrange="0.0 1.0" gear="0 0. 1. 0. 0. -1" site="motor3"/>
        <motor ctrllimited="true" ctrlrange="0.0 1.0" gear="0 0. 1. 0. 0. 1" site="motor4"/>
    </actuator>
MotorCityCobra commented 2 years ago

What is the scale of your model?
Try 100, 1,000, 10,000, 100,000 etc.

I don't know why gear would have more than one value, but wait for the developer to chime in. He usually answers all questions here.

Did you make the meshes yourself? If you make your units MKS then gear="1" will be 1 Newton Meter.
The scale depends on the scale of your meshes or your model!

Coder-RG commented 2 years ago

What is the scale of your model? Try 100, 1,000, 10,000, 100,000 etc.

Did you make the meshes yourself? If you make your units MKS then gear="1" will be 1 Newton Meter. The scale depends on the scale of your meshes or your model!

I don't know anything about the scale. However, the main body of my model is a box of size='.1 .1 .01', make of it what you may. I did not make the meshes myself. I have only used the XML format to create the whole model.

I don't know why gear would have more than one value, but wait for the developer to chime in. He usually answers all questions here.

This is what the official documentation states(which I don't understand):

This attribute scales the length (and consequently moment arms, velocity and force) of the actuator, for all transmission types. It is different from the gain in the force generation mechanism, because the gain only scales the force output and does not affect the length, moment arms and velocity. For actuators with scalar transmission, only the first element of this vector is used. The remaining elements are needed for joint, jointinparent and site transmissions where this attribute is used to specify 3D force and torque axes.

I am certain that the last value 0.1 is the spin. Since opposite rotors have the same spin, i.e two rotors are clockwise(0.1) and two anticlockwise(-0.1).

MotorCityCobra commented 2 years ago

What happens when you use just one value for the gear? i.e. gear="100"

Coder-RG commented 2 years ago

What happens when you use just one value for the gear? i.e. gear="100"

It went completely sideways, i.e. in the +x direction. At least earlier it was behaving like a quadrotor.😂

MotorCityCobra commented 2 years ago

In the simulator screen click rendering and click Actuator to see where your actuator is.

You might want to do this with the example models to learn how to put the joint exactly where it needs to be. You can make meshes in Solidworks and get the x, y, z from them. It takes work to learn and get right.

34563456347

Coder-RG commented 2 years ago

I did! But I don't really have a problem with the placement. Rather, the actual gear values. Currently, the rotor works as it is supposed to. However, I am trying to understand what each value means.

I don't really have time to learn Solidworks. I am happy with the simple model I am able to create.

MotorCityCobra commented 2 years ago

You say you don't have a problem with the placement and you also said it went "completely sideways".
When you render the Actuator does your joint look like that? Is your joint in the center of the Actuator cone / cylinder?

Like I said, you'll probably want to wait for @yuvaltassa , the developer who usually answers the questions in here.

Coder-RG commented 2 years ago

What I meant was after using a single value for gear as you said, the model did not perform the way it was expected. This means it is expecting other values in the gear attribute as mentioned in the doc.

The rotor of a drone produces thrust in the upward direction. Supplying a single value to gear meant it produced force along the x-axis.

yuvaltassa commented 2 years ago

Did you figure this out? The 6th number in the gear vector should indeed change the torque value along the z direction. Perhaps it is being cancelled out by the other motors applying negative torque?

If you still need help, please post a full loadable model and we will inspect.