核心公式:M*qacc + qfrc_bias = qfrc_applied + ctrl
M:惯性矩阵
qacc:加速度
qfrc_bias :科里奥利矩阵和重力矩阵之和:qfrc_bias =C+G
qfrc_applied :广义力
ctrl:其他控制输入,可以是电机扭矩
1 关节与 motor教程
MuJoCo Lec3 - Controlling a one-link pendulum (Spring 2022)-JNgO
Mujoco的auctor有4种模式:
1 motor 模式:This element creates a direct-drive actuator
这种模式,看起来像是直接输出扭矩的模式。
如果我们用这种模式,设定一个值,auctor会将这个值映射成一个力,一直作用于关节
这种模式下,简单的pd实现:
<actuator>
<motor joint="pin" name="torque" gear="1" ctrllimited="true" ctrlrange="-100 100" />
<position name="position_servo" joint="pin" kp="10" />
<velocity name="velocity_servo" joint="pin" kv="0" />
</actuator>
.......
int actuator_no = 0;
m->actuator_gainprm[10*actuator_no+0] = 1;
d->ctrl[0] = -10*(d->qpos[0]-0)-1*d->qvel[0];//PD control
2位置模式:直接让驱动器转动到指定位置
This element creates a position servo.
但是注意了,auctor最后的位置不一定是你要的,因为会有稳态误差,所以官方建议是跟速度模式一起使用
3速度模式
4肌肉模式
根据视频教程,1需要单独使用,2,3模式好像可以组合起来用
gainprm: real(10), “1 0 … 0”
Gain parameters. The built-in gain types (except for muscle) use only the first parameter, but we provide additional parameters in case user callbacks implement a more elaborate model. The length of this array is not enforced by the parser, so the user can enter as many parameters as needed. These defaults are not compatible with muscle actuators; see muscle below.
这个参数存放在mjMode->actuator_gainprm
motor, pos servo,vel servo都可以设置增益系数,增益系数
是10x1,但只用到第一个,就是xml里的kp,kv,其他的留给用户扩展使用
比如我们要访问pos servo的增益系数,假设pos servo在xml的声明顺序是第2个,则它的下标是1:
int no = 1;
//no*10表示找到这个auctor对应的开始,+1表示设置pos的增益系数
m->actuator_gainprm[no*10+1]这个就是访问pos的增益系数
biasprm: real(10), “0 … 0”
Bias parameters. The affine bias type uses three parameters. The length of this array is not enforced by the parser, so the user can enter as many parameters as needed. These defaults are not compatible with muscle actuators; see muscle below.
2 关节与外力
外力讲解笔记
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)