Undefined function 'readImage' for input arguments of type 'double'. in PickandPlaceWorkflowInGazeboUsingROSExample.mlx
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Viet Nguyen
am 28 Mär. 2020
Kommentiert: Cam Salzberger
am 2 Apr. 2020
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 Kommentar
Walter Roberson
am 28 Mär. 2020
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()
Akzeptierte Antwort
Cam Salzberger
am 30 Mär. 2020
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 Kommentare
Cam Salzberger
am 2 Apr. 2020
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Network Connection and Exploration finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!