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

Creating a minimal example to tackle 'ValueError: The truth value of an array with more than one element is ambiguous' when building JaxSimModelData instance #176

Closed
4 tasks done
lorycontixd opened this issue Jun 13, 2024 · 9 comments · Fixed by #177

Comments

@lorycontixd
Copy link

lorycontixd commented Jun 13, 2024

This issue starts from my robot implementation which uses code from #156 , where building a JaxSimModelData instance inside a loop raises the following error:

Traceback (most recent call last):
File "/mnt/c/Users/lconti/Documents/programming/dev/element_lower-leg-morphology-optimization/src/passive_walker/3-Learner/learner_grid.py", line 661, in
main()
File "/mnt/c/Users/lconti/Documents/programming/dev/element_lower-leg-morphology-optimization/src/passive_walker/3-Learner/learner_grid.py", line 619, in main
soft_contacts_params=js.contact.estimate_good_soft_contacts_parameters(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 4, in eq
File "/home/lorenzoconti/miniforge3/envs/pw_learning/lib/python3.12/site-packages/jax/_src/array.py", line 258, in bool
core.check_bool_conversion(self)
File "/home/lorenzoconti/miniforge3/envs/pw_learning/lib/python3.12/site-packages/jax/_src/core.py", line 654, in check_bool_conversion
raise ValueError("The truth value of an array with more than one element"
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

As of now, I tried recreating a minimal working example that attempts to recreate the problem, but this example runs correctly.

Code

Code link here.

Code file (txt): minimal.txt

Conda env

requirements.txt

File diff

diff.txt

Next step is to add more lines from the original file to try to break the code with the traceback found above.

CC: @flferretti

Tasks

@flferretti
Copy link
Collaborator

Hi @lorycontixd, can you please post the result from diff -u working_version.py non_working_version.py? Thanks a lot

@lorycontixd
Copy link
Author

Hi @lorycontixd, can you please post the result from diff -u working_version.py non_working_version.py? Thanks a lot

I updated the original comment with the output of the diff. I have a feeling the code block has a length limit so I uploaded a file for it.

@lorycontixd
Copy link
Author

Added joint initial positions & link forces

Result: still no breaking of the code

@lorycontixd
Copy link
Author

Added frame convention switch:

Result: still no breaking of the code

@diegoferigo
Copy link
Member

@lorycontixd can you please add snippets of MRE in code boxes wrapped by a details HTML environment? The repositories you linked are mostly private and people reading this issue have no access.

@lorycontixd
Copy link
Author

@lorycontixd can you please add snippets of MRE in code boxes wrapped by a details HTML environment? The repositories you linked are mostly private and people reading this issue have no access.

Sure, do code boxes have a maximum limit? Because the code is 400+ lines and most of the times I have difficulties wrapping code in the appropriate boxes.

@diegoferigo
Copy link
Member

There are no significant limits AFAIK. However, in order to help other people providing you support, the shorter the MRE is, the better.

@lorycontixd
Copy link
Author

lorycontixd commented Jun 13, 2024

I updated the original comment to state that the code makes use of #156 @diegoferigo

@flferretti
Copy link
Collaborator

Closed by #177

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants