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

Handling empty data #21

Open
arikrundquist opened this issue Dec 17, 2024 · 1 comment
Open

Handling empty data #21

arikrundquist opened this issue Dec 17, 2024 · 1 comment

Comments

@arikrundquist
Copy link

The stop_reconstruction service returns a boolean for whether or not it was successfully able to construct a mesh. The current implementation only returns false if the start_reconstruction service had not yet been called (actually, looking at the code, I don't think the internal state is ever reset -- it looks like calling start followed by multiple stops might not be detected, though I haven't tried it to verify).

Except for that particular case of not calling the start service, the stop service is assumed to succeed and always returns true. However, there are cases where the mesh generation can fail -- in particular, if no data is received from the camera or there is an issue converting camera data to the correct frame, the industrial reconstruction node will crash with numpy complaining about attempting to take the minimum of an empty array.

The industrial reconstruction node should be robust against issues like this, and should gracefully handle any errors by returning false to indicate that the mesh generation failed.

@BrendanMitchellSisu
Copy link

Minimal steps to reproduce

  1. Launch industrial reconstruction: ros2 launch industrial_reconstruction reconstruction.launch.xml depth_image_topic:=/empty/topic1 color_image_topic:=/empty/topic2 camera_info_topic:=/empty/topic3
  2. Start mesh generation: ros2 service call /start_reconstruction industrial_reconstruction_msgs/srv/StartReconstruction
  3. Attempt to save generated mesh: ros2 service call /stop_reconstruction industrial_reconstruction_msgs/srv/StopReconstruction "mesh_filepath: '/home/<user>/Desktop/my_mesh.ply'"

Result

The industrial_reconstruction node dies with the following output:

[industrial_reconstruction-1] [INFO] [1734460460.647706532] [industrial_reconstruction]: Generating mesh
[industrial_reconstruction-1] [Open3D WARNING] Write PLY failed: mesh has 0 vertices.
[industrial_reconstruction-1] Traceback (most recent call last):
[industrial_reconstruction-1]   File "/opt/ros/humble/lib/industrial_reconstruction/industrial_reconstruction", line 33, in <module>
[industrial_reconstruction-1]     sys.exit(load_entry_point('industrial-reconstruction==0.0.1', 'console_scripts', 'industrial_reconstruction')())
[industrial_reconstruction-1]   File "/opt/ros/humble/lib/python3.10/site-packages/industrial_reconstruction/industrial_reconstruction.py", line 359, in main
[industrial_reconstruction-1]     rclpy.spin(industrial_reconstruction)
[industrial_reconstruction-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/__init__.py", line 226, in spin
[industrial_reconstruction-1]     executor.spin_once()
[industrial_reconstruction-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 739, in spin_once
[industrial_reconstruction-1]     self._spin_once_impl(timeout_sec)
[industrial_reconstruction-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 736, in _spin_once_impl
[industrial_reconstruction-1]     raise handler.exception()
[industrial_reconstruction-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/task.py", line 239, in __call__
[industrial_reconstruction-1]     self._handler.send(None)
[industrial_reconstruction-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 437, in handler
[industrial_reconstruction-1]     await call_coroutine(entity, arg)
[industrial_reconstruction-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 391, in _execute_service
[industrial_reconstruction-1]     response = await await_or_execute(srv.callback, request, srv.srv_type.Response())
[industrial_reconstruction-1]   File "/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/executors.py", line 107, in await_or_execute
[industrial_reconstruction-1]     return callback(*args)
[industrial_reconstruction-1]   File "/opt/ros/humble/lib/python3.10/site-packages/industrial_reconstruction/industrial_reconstruction.py", line 268, in stopReconstructionCallback
[industrial_reconstruction-1]     mesh_msg = meshToRos(cropped_mesh)
[industrial_reconstruction-1]   File "/opt/ros/humble/lib/python3.10/site-packages/src/industrial_reconstruction/utility/ros.py", line 59, in meshToRos
[industrial_reconstruction-1]     z_min, z_max = vertices[:, 2].min(), vertices[:, 2].max()
[industrial_reconstruction-1]   File "/home/brendan/.local/lib/python3.10/site-packages/numpy/core/_methods.py", line 45, in _amin
[industrial_reconstruction-1]     return umr_minimum(a, axis, None, out, keepdims, initial, where)
[industrial_reconstruction-1] ValueError: zero-size array to reduction operation minimum which has no identity
[ERROR] [industrial_reconstruction-1]: process has died [pid 2125271, exit code 1, cmd '/opt/ros/humble/lib/industrial_reconstruction/industrial_reconstruction --ros-args -r __node:=industrial_reconstruction --params-file /tmp/launch_params_3g3zu7vk --params-file /tmp/launch_params_o3pq6qfz --params-file /tmp/launch_params_hw3cpln1 --params-file /tmp/launch_params_lswu4gnr --params-file /tmp/launch_params_apx3h5ta'].

The stop_reconstruction service call hangs and never returns.

Expected Result

The stop_reconstruction service call returns a response with success=False to indicate that no mesh could be generated. The industrial_reconstruction node does not crash.

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

2 participants