ROS2-Path-Planning-and-Maze-Solving
ROS2-Path-Planning-and-Maze-Solving copied to clipboard
avoid bad image message
In addition, considering the error when transferring the information and other noise, we mutate some of the image message and there will be a crash like following:
maze_solver:
Traceback (most recent call last):
File "/opt/ros/foxy/lib/python3.8/site-packages/cv_bridge/core.py", line 191, in imgmsg_to_cv2
res = cvtColor2(im, img_msg.encoding, desired_encoding)
RuntimeError: OpenCV(4.2.0) ../modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'
It's because of a mutation of the message's width and height data, causing the cvtColor2 memset a zero-size src to transfer. Although it may be hard to happen in a stable simulation environment, we hope it can be addressed as a robust feature.
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.