Skip to content

More robust initialization against a delay of info #7

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Cryst4L9527
Copy link

@Cryst4L9527 Cryst4L9527 commented Oct 28, 2022

Hi! I'm a researcher on bug detection and software robustness focusing on robotic applications. It's our new idea to design a language-irrelevant algorithm, so we are trying to check and fix some python-based programs to prove our algorithm. Since your program is one of the best opensource codes in python for the ROS system, we did a test and found some crashes:

maze_solver:
Traceback (most recent call last):
  ...
  File "/root/ROS2-Path-Planning-and-Maze-Solving/path_planning_ws/install/maze_bot/lib/python3.8/site-packages/maze_bot/maze_solver.py", line 221, in maze_solving
    self.bot_localizer.localize_bot(self.sat_view, frame_disp)
  File "/root/ROS2-Path-Planning-and-Maze-Solving/path_planning_ws/install/maze_bot/lib/python3.8/site-packages/maze_bot/bot_localization.py", line 173, in localize_bot
    self.extract_bg(curr_frame.copy())
  File "/root/ROS2-Path-Planning-and-Maze-Solving/path_planning_ws/install/maze_bot/lib/python3.8/site-packages/maze_bot/bot_localization.py", line 92, in extract_bg
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.error: OpenCV(4.6.0) /io/opencv/modules/imgproc/src/color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function 'cv::impl::{anonymous}::CvtHelper<VScn, VDcn, VDepth, sizePolicy>::CvtHelper(cv::InputArray, cv::OutputArray, int) [with VScn = cv::impl::{anonymous}::Set<3, 4>; VDcn = cv::impl::{anonymous}::Set<1>; VDepth = cv::impl::{anonymous}::Set<0, 2, 5>; cv::impl::{anonymous}::SizePolicy sizePolicy = cv::impl::<unnamed>::NONE; cv::InputArray = const cv::_InputArray&; cv::OutputArray = const cv::_OutputArray&]'
> Invalid number of channels in input image:
>     'VScn::contains(scn)'
> where
>     'scn' is 1
maze_solver:
Traceback (most recent call last):
  ...
  File "/root/ROS2-Path-Planning-and-Maze-Solving/path_planning_ws/install/maze_bot/lib/python3.8/site-packages/maze_bot/maze_solver.py", line 223, in maze_solving
    self.bot_localizer.localize_bot(self.sat_view, frame_disp)
  File "/root/ROS2-Path-Planning-and-Maze-Solving/path_planning_ws/install/maze_bot/lib/python3.8/site-packages/maze_bot/bot_localization.py", line 173, in localize_bot
    self.extract_bg(curr_frame.copy())
  File "/root/ROS2-Path-Planning-and-Maze-Solving/path_planning_ws/install/maze_bot/lib/python3.8/site-packages/maze_bot/bot_localization.py", line 92, in extract_bg
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.error: OpenCV(4.6.0) /io/opencv/modules/imgproc/src/color.simd_helpers.hpp:94: error: (-2:Unspecified error) in function 'cv::impl::{anonymous}::CvtHelper<VScn, VDcn, VDepth, sizePolicy>::CvtHelper(cv::InputArray, cv::OutputArray, int) [with VScn = cv::impl::{anonymous}::Set<3, 4>; VDcn = cv::impl::{anonymous}::Set<1>; VDepth = cv::impl::{anonymous}::Set<0, 2, 5>; cv::impl::{anonymous}::SizePolicy sizePolicy = cv::impl::<unnamed>::NONE; cv::InputArray = const cv::_InputArray&; cv::OutputArray = const cv::_OutputArray&]'
> Unsupported depth of input image:
>     'VDepth::contains(depth)'
> where
>     'depth' is 6 (CV_64F)
maze_solver:
Traceback (most recent call last):
  File "/root/ROS2-Path-Planning-and-Maze-Solving/path_planning_ws/install/maze_bot/lib/maze_bot/maze_solver", line 11, in <module>
    load_entry_point('maze-bot==0.0.0', 'console_scripts', 'maze_solver')()
  File "/root/ROS2-Path-Planning-and-Maze-Solving/path_planning_ws/install/maze_bot/lib/python3.8/site-packages/maze_bot/maze_solver.py", line 272, in main
    rclpy.spin(node_obj)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/__init__.py", line 191, in spin
    executor.spin_once()
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 714, in spin_once
    raise handler.exception()
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/task.py", line 239, in __call__
    self._handler.send(None)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 429, in handler
    await call_coroutine(entity, arg)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 343, in _execute_timer
    await await_or_execute(tmr.callback)
  File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 118, in await_or_execute
    return callback(*args)
  File "/root/ROS2-Path-Planning-and-Maze-Solving/path_planning_ws/install/maze_bot/lib/python3.8/site-packages/maze_bot/maze_solver.py", line 245, in maze_solving
    bot_view = cv2.resize(self.bot_view, (int(frame_disp.shape[0]/2),int(frame_disp.shape[1]/2)))
AttributeError: 'maze_solver' object has no attribute 'bot_view'

Analysis:
There is a chance some of the messages such as /BotCamera/image_raw may have a delay in the real situation, also even in the simulation of gazebo, which is the reason of the crashes occurred when we tested.

Solution:
Therefore, I just change the logic of maze_solving: check first if a real bot_view and sat_view are received , then continue to do the rest things.

Hoping you can agree this merge.

@Cryst4L9527
Copy link
Author

Maybe you can just confirm this? Just a small change of codes for better robustness, it won't change the main functions of this program. Thank you~

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 this pull request may close these issues.

1 participant