ROS Toolbox read scan block ouput zero all the time.

5 vues (au cours des 30 derniers jours)
Zike Wang
Zike Wang le 23 Jan 2023
Commenté : Josh Chen le 30 Jan 2023
I tried to use the new ROS Toolbox read-scan block to get the lidar sensor distance info to do APF obstacle avoiding. I followed the example and can get the scan plot. However, if I changed the simulink model to my own algorithm, the read scan block output zeros all the time, causing my APF not working. It is the same Gazebo and ROS environment and I am thinking if it is a bug that this block does not work if the simulink model is running without a stop. I notice the comment on the read-scan example matlab function " % Read Scan block will output all zeros until the Subscriber blocks". I could not figure out what does that means, I did have a subscriber block with the scan topic and sensor_msgs/LaserScan message type selected.

Réponses (1)

Josh Chen
Josh Chen le 23 Jan 2023
Hi Zike,
It does not matter if you have a "stop" or not in the Simulink model.
When referring to the comment on the read-scan example, do you mean the comment inside 'plotXY' MATLAB Function? From my side, I am seeing it contains two lines as:
% Read Scan block will output all zeros until the Subscriber blocks
% outputs a message.
As the comment mentioned, if the subscriber block receives no message, Read Scan block will always output all zeros.
In your own model, can you verify if the message coming out from "Subscribe" block actually represents an valid message? You can do this by connecting the "Msg" output port of "Subscribe" block to a "bus selector" block and use a "Display" block to view contents of the message.
Hope this helps,
Josh
  2 commentaires
Zike Wang
Zike Wang le 30 Jan 2023
Hi Josh,
Thank you for the answer! I tried to work around it and it seems the Simulink having trouble compiling as different release versions with ROSTOOL box? I found someone else simulink file where the 'ROS' Tab is activated but mine is not (maybe I did something wrong on the configurations), and the bus selector is working well given 640 data and the first 360 is the actual data, same for the "read scan" block. Although the value from both methods output slight different results, I am happy about it.
To answer your concerns, yes, I was able to get message from "Subscribe" block but the values are all zeros.
Josh Chen
Josh Chen le 30 Jan 2023
Hi Zike,
The 'ROS' Tab in Simulink will appear only after you configure the hardware board to 'ROS' or 'ROS 2'. To do so, you can navigate to 'APPS>Robot Operating System (ROS)' and select "Robot Operating System (ROS)" from the pop-up window. However, also note that anything under 'ROS' tab is not required if you are just running simulation. They are mainly designed for code generation workflow.
If you see all zeros as output message from "Subscribe" block, that means there is no valid message. We always return the default all zeros message in this case to ensure consistent output for downstream blocks.
One possible thing to check is whether you are connecting to the same network, e.g., when running "rosinit", did you connect to the same network where those messages been published? Please feel free to create a help ticket and discuss more with our fantasic technical support team if you need help subscribing to the topic.
Thanks,
Josh

Connectez-vous pour commenter.

Catégories

En savoir plus sur Specialized Messages dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by