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

Error while running the roadmap example in the README #50

Open
ssfc opened this issue Mar 5, 2024 · 3 comments
Open

Error while running the roadmap example in the README #50

ssfc opened this issue Mar 5, 2024 · 3 comments

Comments

@ssfc
Copy link

ssfc commented Mar 5, 2024

Firstly thanks a lot for releasing such high-quality code. Kindly, I have question about errors I am facing while running roadmap example in the README.

After running python3 ../tools/annotate_roadmap.py ../test/mapf_simple1_roadmap_to_annotate.yaml mapf_simple1_roadmap_annotated.yaml I am facing the following output

Namespace(map='../test/mapf_simple1_roadmap_to_annotate.yaml', out='mapf_simple1_roadmap_annotated.yaml', radius=0.3)
Traceback (most recent call last):
  File "/home/ssfc/libMultiRobotPlanning/build/../tools/annotate_roadmap.py", line 106, in <module>
    main()
  File "/home/ssfc/libMultiRobotPlanning/build/../tools/annotate_roadmap.py", line 32, in main
    roadmap = add_edge_conflicts(args.radius, roadmap)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ssfc/libMultiRobotPlanning/build/../tools/annotate_roadmap.py", line 39, in add_edge_conflicts
    conflicts = compute_edge_conflicts(radius, roadmap)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ssfc/libMultiRobotPlanning/build/../tools/annotate_roadmap.py", line 89, in compute_edge_conflicts
    if collision.precheck_bounding_box(E, p0, p1, q0, q1):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ssfc/libMultiRobotPlanning/tools/collision.py", line 21, in precheck_bounding_box
    box_p += np.stack([-np.diagonal(E), np.diagonal(E)])
numpy.core._exceptions._UFuncOutputCastingError: Cannot cast ufunc 'add' output from dtype('float64') to dtype('int64') with casting rule 'same_kind'

Any recommendations to overcome this error is highly appreciated

@yucswx
Copy link

yucswx commented Mar 5, 2024 via email

@whoenig
Copy link
Owner

whoenig commented Mar 5, 2024

Which version of Python and numpy are you using? The error indicates that box_p is an integer type, while E is a floating point type, so a likely fix would manually set the dtype of box_p initially.

@ssfc
Copy link
Author

ssfc commented Mar 6, 2024

Which version of Python and numpy are you using? The error indicates that box_p is an integer type, while E is a floating point type, so a likely fix would manually set the dtype of box_p initially.

The bug is fixed! Thanks for your advice. The python version I am using is Python 3.11.5. I modify function precheck_bounding_box as follows and the roadmap visualization can run successfully now.

def precheck_bounding_box(E, p0, p1, q0, q1):
    """Check if the bounding boxes spanning the two line segments overlap.
    Returns True if the bounding boxes overlap, False otherwise."""
    box_p = np.stack([np.min([p0, p1], axis=0), np.max([p0, p1], axis=0)]).astype(np.float64)
    box_q = np.stack([np.min([q0, q1], axis=0), np.max([q0, q1], axis=0)]).astype(np.float64)
    box_p += np.stack([-np.diagonal(E), np.diagonal(E)])
    box_q += np.stack([-np.diagonal(E), np.diagonal(E)])
    return np.logical_and(box_p[1, :] > box_q[0, :],
                          box_q[1, :] > box_p[0, :]).all()

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

No branches or pull requests

3 participants