简体   繁体   English

错误:ValueError:缓冲区的维数错误(预期为 1,得到 2)

[英]Error:ValueError: Buffer has wrong number of dimensions (expected 1, got 2)

I wanted to call the function: emptymatrix=np.zeros((sim.data.nv,sim.data.nv))我想打电话给 function:emptymatrix=np.zeros((sim.data.nv,sim.data.nv))
mjp.cymj._mj_fullM(model, emptymatrix, sim.data.qM) in mujoco so that I can Convert sparse inertia matrix M into full matrix so that I can calclulate the torque but I have this error:raceback (most recent call last): File "kuka.py", line 58, in mjp.cymj._mj_fullM(sim.model,emptymatrix,sim.data.qM) File ".local/lib/python3.8/site-packages/mujoco_py/generated/wrappers.pxi", line 5061, in mujoco_py.cymj._mj_fullM mujoco 中的 mjp.cymj._mj_fullM(model, emptymatrix, sim.data.qM) 这样我就可以将稀疏惯性矩阵 M 转换为完整矩阵,这样我就可以计算扭矩但是我有这个错误:raceback(最后一次调用) : 文件“kuka.py”,第 58 行,在 mjp.cymj._mj_fullM(sim.model,emptymatrix,sim.data.qM) 文件“.local/lib/python3.8/site-packages/mujoco_py/generated/wrappers .pxi”,第 5061 行,在 mujoco_py.cymj._mj_fullM
ValueError: Buffer has wrong number of dimensions (expected 1, got 2) ValueError:缓冲区的维数错误(预期为 1,得到 2)
If someone could help me I ll be so grateful.如果有人可以帮助我,我将不胜感激。

mujoco_py's implementation of mj_fullM expects your emptymatrix to be a vector of length nv*nv, rather than a square matrix. mujoco_py 的mj_fullM实现期望您的emptymatrix矩阵是长度为 nv*nv 的向量,而不是方阵。

See these lines from robosuite :robosuite 中看到这些行:

mass_matrix = np.ndarray(shape=(len(self.sim.data.qvel) ** 2,), dtype=np.float64, order="C")
mujoco_py.cymj._mj_fullM(self.sim.model, mass_matrix, self.sim.data.qM)
mass_matrix = np.reshape(mass_matrix, (len(self.sim.data.qvel), len(self.sim.data.qvel)))
self.mass_matrix = mass_matrix[self.qvel_index, :][:, self.qvel_index]

If you make use of the new MuJoCo python bindings ( pip install mujoco ), mujoco.mj_fullM takes the square matrix as you'd expect.如果您使用新的 MuJoCo python 绑定( pip install mujoco ), mujoco.mj_fullM会像您期望的那样采用方阵。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 熊猫:“ ValueError:缓冲区的维数错误(预期1,得到0) - Pandas: "ValueError: Buffer has wrong number of dimensions (expected 1, got 0) ValueError:如果在语句中,则缓冲区的维数错误(预期为1,得到2) - ValueError: Buffer has wrong number of dimensions (expected 1, got 2) on if in statement Pandas ValueError:缓冲区的维数错误(预期为 1,得到 2) - Pandas ValueError: Buffer has wrong number of dimensions (expected 1, got 2) Cython ValueError:缓冲区的维数错误(预期2,得3) - Cython ValueError: Buffer has wrong number of dimensions (expected 2, got 3) 缓冲区的维数错误(预期为 1,得到 2) - Buffer has wrong number of dimensions (expected 1, got 2) pandas 中的错误:“缓冲区的维数错误(预期为 1,得到 2)” - Error in pandas: "Buffer has wrong number of dimensions (expected 1, got 2)" ValueError:使用Seaborn时,缓冲区的维数错误(预期为1,为2) - ValueError: Buffer has wrong number of dimensions (expected 1, got 2) when using seaborn 在创建 pandas DataFrame ValueError: Buffer has wrong number of dimensions (expected 1, got 2) - during creation of pandas DataFrame ValueError: Buffer has wrong number of dimensions (expected 1, got 2) df.loc - ValueError:缓冲区的维数错误(预期为 1,得到 0) - df.loc - ValueError: Buffer has wrong number of dimensions (expected 1, got 0) pd.insert ValueError:缓冲区的维数错误(预期为 1,得到 2) - pd.insert ValueError: Buffer has wrong number of dimensions (expected 1, got 2)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM