ArduCAM / ArduCAM_USB_Camera_Shield

This is the repository for ArduCAM USB Camera Shield
126 stars 69 forks source link

AR0135 Error Capturing Image and USB Data Length Error #110

Open jjpaulson opened 5 years ago

jjpaulson commented 5 years ago

Hello,

I just got an AR0135 camera sensor with a wide angle lens to use in a visual inertial odometry system, and I am getting what I think are some sort of buffer issues when capturing images. I am using the ROS driver for the camera (in ROS melodic on Ubuntu 18.04) along with the USB 3.0 Camera Shield connected to a confirmed USB 3.0 port. I am using the config file for the AR0135 posted on its software guide, just modified into json format. I am able to get a good stream of video for a little bit, but after an extended period of time I end up getting these 'Error capture image, rtn_val = 65316' and 'USB_CAMERA_DATA_LEN_ERROR' errors along with a messed up video. Furthermore, doing anything that tries to display or use the image data, like image_view or running the visual odometry software I am trying to use, seems to almost immediately cause these errors to occur, which seems very weird to me since they should just be subscribing to the data being published to that topic from the camera.

I have tried decreasing the PLL value in the register as suggested in another issue, but that did not seem to have any effect. I also tested the camera in Windows, and it does seem to be better, but I do still get 'bad frame received' errors when the camera is running for more than a few minutes. Any help would be much appreciated. I have attached a few pictures of the errors in the terminal and what the affected images look like.

ar0135_bad_image ar0135_data_len_error ar0135_error_capture_image

glddiv commented 5 years ago

Hello @jjpaulson, please try this configuration file, it works fine on my ubuntu16.04. If it doesn't work, try reducing the value of register 0x3030 in the "register_parameter_dev3_inf2" block and the "register_parameter_dev3_inf2" block. AR0135_1280x964_8bit.zip

jjpaulson commented 5 years ago

Thank you for the help. I tried your config file, and needed to add the TRANS_LVL parameter to it, but that did not fix either of the errors. I then reduced the value of register x3030 in the "register_parameter_dev3_inf2" and "register_parameter_dev3_inf3" blocks by quite a bit and this did help quite a bit. The camera works for some time and I have not seen the USB_CAMERA_DATA_LEN error at all, but after some time, I still get the "Error capture image, rtn_val = 65318" that ends up crashing the camera video. Should I try dropping the 0x3030 values even lower? I brought them down to 0x000e and 0x0025 in the inf2 and inf3 blocks respectively from their original values.

Edit: So after leaving the camera just running for 10 minutes, it ended up crashing with a "USB_CAMERA_DATA_LEN_ERROR RECEIVE_LENGTH:1230848" followed by a bunch of "Error capture image, rtn_val = 65318." Now, I am just straight up not able to launch the camera again as it immediately errors out. It only starts working again after unplugging it and plugging it back in.

Edit 2: During one of the errors where the terminal was spitting out "Error capture image", I was able to call a read_reg on register 0x3030 and got back a value of 19029, which is insanely large. So it seems like something is overwriting the value set in the config with this large number which crashes the camera.

glddiv commented 5 years ago

@jjpaulson Can you try another computer? I can't reproduce this problem on my computer.

jjpaulson commented 5 years ago

@glddiv Sorry, I do not have another Linux machine around with all of the ROS stuff set up. I did, however, get around my problems by converting the provided C++ code (that was working on its own) into a ROS node itself. This seems to be working fine. I don't know what's happening with the provided python code. Thanks for your help though.

ArduCAM commented 5 years ago

python code is not as efficent as the C++ code. The problem looks like the capture process is not fast enough to get the data before it is flushed with the incoming data.

jjpaulson commented 5 years ago

@ArduCAM Yeah that is what I am assuming as well. The C++ Ros code has been much more reliable in preventing these errors and has been able to run continuously for hours. However, I am getting the occasional issue of several "Error capture image" errors followed by the capture crashing. Then, when I try to run the same code again, the capture can begin successfully, but it then crashes immediately. It only starts working again after unplugging the camera and plugging it back in. I am wondering if this problem is more of a USB issue than the software, since this problem showed up with the python code as well. Camera_Error_1 Camera_Error_2