Undefined function 'readImage' for input arguments of type 'double'. in PickandPla​ceWorkflow​InGazeboUs​ingROSExam​ple.mlx

조회 수: 2 (최근 30일)
When running the PickandPlaceWorkflowInGazeboUsingROSExample.mlx file along with the virtual machine from https://www.mathworks.com/help/robotics/examples/pick-and-place-workflow-in-gazebo-using-ros.html. I come across:
Undefined function 'readImage' for input arguments of type 'double'.
However, readImage is a function that exists and is defined and I can run the example from: https://www.mathworks.com/help/ros/ref/readimage.html
I have looked at the input from the example file:exampleCommandDetectPartsROSGazebo.m and it crashes on:
% Read image from simulated Gazebo camera
rgbImg = readImage(coordinator.ROSinfo.rgbImgSub.LatestMessage);
Where readImage should be a ROS msg, but
coordinator.ROSinfo.rgbImgSub.LatestMessage = [] which is of type double.
Am I running the example wrong? shouldn't coordinator.ROSinfo.rgbImgSub.LatestMessage be of type ROS image message?
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 3월 28일
I would think that it needs a character vector, but at that point the latest character vector is empty. It is common for routines to return [] when they do not succeed, as commonly people just test isempty()

댓글을 달려면 로그인하십시오.

채택된 답변

Cam Salzberger
Cam Salzberger 2020년 3월 30일
Hello Viet,
Techncially, "readImage" is a method for an object of class ros.msg.sensor_msgs.Image (and CompressedImage). There isn't really a big distinction, other than that you'll see this error if you try to call it with any input that is not an object of the required type.
Walter is likely on the right track here. The LatestMessage property of a subscriber is empty until it receives a message. Likely there was simply a timing issue with the virtual machine or the Gazebo communication, and that line ran before the message was received. Like Walter suggested, I'd suggest putting an if ~isempty(sub.LatestMessage) call in to check before you run anything that depends on the message. Or use "receive" on the subscriber to wait for the next message to come in (works best if messages are sent on that topic on a regular interval).
-Cam
  댓글 수: 3
Viet Nguyen
Viet Nguyen 2020년 3월 31일
after applying both of what Cam and Walter suggested I was able to get the code to run using ~isempty(). The pick and place job is not operating still however is not executing and terminates after 3 failed attempts to receive a ROS message. Is it possible to get in contact with the person who created this example? I was unable to use:
receive(coordinator.ROSinfo.rgbImgSub);
because coordinator.ROSinfo.rgbImgSub seems to be a deleted ROS subcriber. What can cause for a ROS subscriber to be deleted? This leads me to think now that the ROS network set up from the example is not operating as the example is supposed to be. I don't know if anyone else has had luck running the script but any guidance would be appreciated.
Cam Salzberger
Cam Salzberger 2020년 4월 2일
Hey Viet,
Contacting technical support is probably your best bet at this point. They will be able to interact with you more efficiently to get information about what is going on with your system.
-Cam

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Specialized Messages에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by