whoenig / libMultiRobotPlanning

Library with search algorithms for task and path planning for multi robot/agent systems
MIT License
802 stars 218 forks source link

Error while running the roadmap example in the README #50

Open ssfc opened 7 months ago

ssfc commented 7 months ago

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 commented 7 months ago

您好!       您发送的邮件已收到。谢谢。 祝您生活愉快!

whoenig commented 7 months ago

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 commented 7 months ago

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()