Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling with -DmjUSESINGLE is broken due to type error in engine_collision_convex.c #2070

Closed
2 tasks done
PeterOGB opened this issue Sep 20, 2024 · 10 comments
Closed
2 tasks done
Assignees
Labels
bug Something isn't working

Comments

@PeterOGB
Copy link

Intro

New mujoco user here, I'm a retired software engineer with 40 years C/unix/linux experience.

I'm trying to integrate mujoco into an existing application that runs on a Raspberry Pi5 and uses openGLES for rendering and gclm for maths.

My setup

Raspberry Pi 5 running wayland on top of 64 bit PiOS (Debian 12).
cmake version 3.25.1
gcc (Debian 12.2.0-14) 12.2.0

What's happening? What did you expect?

I want to build mujoco with mjtNum as float rather than double so as to more easily into existing appliacation.

I've tried adding -DmjUSESINGLE to the initial cmake command but it has no effect and cmake actually warns that "Manually-specified variables were not used by the project: mjUSESINGLE".

I expected the resulting library to use floats, but it still uses doubles.

Steps for reproduction

clone mujoco
cd mujoco
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX="/usr/local" -DmjUSESINGLE=On

Minimal model for reproduction

No response

Code required for reproduction

No response

Confirmations

@PeterOGB PeterOGB added the bug Something isn't working label Sep 20, 2024
@yuvaltassa
Copy link
Collaborator

I think you can add it e.g. here ?

@PeterOGB
Copy link
Author

I did try adding it there but from memory it didn't seem to propagate to some of the dependencies. I'll try it again.

@PeterOGB
Copy link
Author

No, it doesn't work...
[ 9%] Building C object CMakeFiles/mujoco.dir/src/engine/engine_collision_convex.c.o
/home/petero/mujoco/src/engine/engine_collision_convex.c: In function ‘mjc_penetration’:
/home/petero/mujoco/src/engine/engine_collision_convex.c:50:21: error: passing argument 1 of ‘mju_sub3’ from incompatible pointer type [-Werror=incompatible-pointer-types]
50 | mju_sub3(dir->v, status.x1, status.x2);
| ~~~^~~
| |
| ccd_real_t * {aka double *}
In file included from /home/petero/mujoco/src/engine/engine_collision_convex.c:27:
/home/petero/mujoco/src/engine/engine_util_blas.h:83:28: note: expected ‘mjtNum *’ {aka ‘float *’} but argument is of type ‘ccd_real_t *’ {aka ‘double *’}
83 | MJAPI void mju_sub3(mjtNum res[3], const mjtNum vec1[3], const mjtNum vec2[3]);
| ~~~~~~~^~~~~~

Please reopen !

@yuvaltassa yuvaltassa reopened this Sep 20, 2024
@yuvaltassa
Copy link
Collaborator

Okay, in that case this a different bug. I will rename and assign.

@yuvaltassa yuvaltassa changed the title Using -DmjUSESINGLE with cmake has no effect Compiling with -DmjUSESINGLE is broken due to type error in engine_collision_convex.c Sep 20, 2024
@yuvaltassa
Copy link
Collaborator

So the issue is actually a documentation bug. The libccd dependency also needs to be compiled for float32. I'll remind myself how to do this and update the docs accordingly.

@yuvaltassa yuvaltassa self-assigned this Sep 20, 2024
@PeterOGB
Copy link
Author

I don't think it is a doc issue. libccd is not built separately, it's included in the mujoco tree, so I would have expected it to be reconfigured appropriately when using mjUSESINGLE.

@PeterOGB
Copy link
Author

My work-around fix was to change build/_deps/ccd-build/src/ccd/config.h after running cmake.

@yuvaltassa
Copy link
Collaborator

If you know cmake well (I don't), do you know how to properly propagate mjUSESINGLE to libccd's CCD_SINGLE in the cmake config?

We'd very much appreciate a PR for this!

@PeterOGB
Copy link
Author

Configuring libccd can be done by changing the value set(ENABLE_DOUBLE_PRECISION ON) to set(ENABLE_DOUBLE_PRECISION OFF) in mujoco/cmake/MuJoCoDependencies.cmake With this change (and setting mjUSESINGLE in top CMakeLists.txt) the library builds but the tests still don't build.

@traversaro
Copy link
Contributor

Configuring libccd can be done by changing the value set(ENABLE_DOUBLE_PRECISION ON) to set(ENABLE_DOUBLE_PRECISION OFF) in mujoco/cmake/MuJoCoDependencies.cmake With this change (and setting mjUSESINGLE in top CMakeLists.txt) the library builds but the tests still don't build.

@PeterOGB an proposal to simplify this process is available at #2278, feel free to provide feedback if you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants