Using the C++ SDK to write a ROS node for the MT9J001

  1. Where did you get the camera module(s)?

robotshop.de

  1. Model number of the product(s)?
    MT9J001

  2. What hardware/platform were you working on?
    Raspberry Pi 4

Hello,

I have got the MT9J001 to work with a Rev.D shield both using the C++ streaming demo and the Python ROS node.
However, the Python ROS node doesn’t work at full resolution (10MP), only with the cfg files at lower resolution.

The C++ demo works at full resolution, so I attempted to write a ROS node for it, but I cannot compile it in ROS. I get the following error:

/home/ubuntu/build_ws/src/camera/src/camera_node.cpp:35:1: error: ‘ArduCamCfg’ does not name a type
 ArduCamCfg cameraCfg;
 ^
/home/ubuntu/build_ws/src/camera/src/camera_node.cpp:51:18: error: ‘uint8’ was not declared in this scope
 cv::Mat JPGToMat(uint8* bytes, int length) {
                  ^
/home/ubuntu/build_ws/src/camera/src/camera_node.cpp:51:25: error: ‘bytes’ was not declared in this scope
 cv::Mat JPGToMat(uint8* bytes, int length) {
                         ^
/home/ubuntu/build_ws/src/camera/src/camera_node.cpp:51:32: error: expected primary-expression before ‘int’
 cv::Mat JPGToMat(uint8* bytes, int length) {
                                ^
/home/ubuntu/build_ws/src/camera/src/camera_node.cpp:51:44: error: expected ‘,’ or ‘;’ before ‘{’ token
 cv::Mat JPGToMat(uint8* bytes, int length) {
                                            ^
make[2]: *** [CMakeFiles/camera_node.dir/src/camera_node.cpp.o] Error 1
make[1]: *** [CMakeFiles/camera_node.dir/all] Error 2
make: *** [all] Error 2
cd /home/ubuntu/build_ws/build/camera; catkin build --get-env camera | catkin env -si  /usr/bin/make --jobserver-fds=6,7 -j; cd -

Should it be possible to do this?

Is there any error message? Maybe we can fix it.

I made some further investigation, the function that slows everything down in the Python ROS node is:

img_msg = bridge.cv2_to_imgmsg(image)

It seems to be a rclpy issue (see https://github.com/ros-perception/vision_opencv/issues/285)

The exact errors I will have to check later, it is something like USB_CAMERA_DATA_LEN_ERROR RECEIVE_LENGTH

In Python I tried to software trigger the camera. It works, but the frame rate is under 1Hz which really isn’t enough (I would like at least 2Hz).

I expect that the equivalent function in C++( sensor_msgs::ImagePtr msg = cv_bridge::CvImage(std_msgs::Header(), “bgr8”, image).toImag) is faster.

It is possible that a ROS wrapper for the C++ code would solve the problem. To do that, I would need to build a c++ code containing both Arducam libraries etc and ROS. My knowledge of make and catkin is currently not sufficient for this.

This error seems to be that the header file is not included correctly, you can check whether the header file search path is set correctly.