google-deepmind / google-deepmind/mujoco
[Bug Report / C#] Suspected bug list of MjBindings.cs
- Dominant language
- C++
- Stars
- 15.2k
- Forks
- 1.8k
- Avg merge
- 10d 16h
- Merged PRs (30d)
- 25
Description
At first, thanks to the MjBindings.cs file, it is easy to use in C#.
In the meantime, I think there seem to be some bugs in the MjBindings.cs file.
The suspected bugs found are as follows (please check it)
[DllImport("mujoco", CallingConvention = CallingConvention.Cdecl)]
**[return: MarshalAs(UnmanagedType.LPStr)]**
public static unsafe extern **string** mj_id2name(mjModel_* m, int type, int id);
=> I failed to use "mj_id2name" method, so I modified it as follows:
[DllImport("mujoco", CallingConvention = CallingConvention.Cdecl)]
public static unsafe extern **IntPtr** mj_id2name(mjModel_* m, int type, int id);
**If string return is still OK, please let me know a sample code if possible. :)**
//------------------------------------------------------------------------------------
[DllImport("mujoco", CallingConvention = CallingConvention.Cdecl)]
public static unsafe extern **mjuiThemeSpacing_*** mjui_themeSpacing(int ind);
[DllImport("mujoco", CallingConvention = CallingConvention.Cdecl)]
public static unsafe extern **mjuiThemeColor_*** mjui_themeColor(int ind);
Looking at the original C code, the return types are not a pointer. Thus, these codes were modified as follows.
[DllImport("mujoco", CallingConvention = CallingConvention.Cdecl)]
public static unsafe extern **mjuiThemeSpacing_** mjui_themeSpacing(int ind);
[DllImport("mujoco", CallingConvention = CallingConvention.Cdecl)]
public static unsafe extern **mjuiThemeColor_** mjui_themeColor(int ind);
I think it's a bug caused by a typo.
Contributor guide
Assessment
This issue has not been assessed yet.