ROS Toolbox read scan block ouput zero all the time.

조회 수: 5 (최근 30일)
Zike Wang
Zike Wang 2023년 1월 23일
댓글: Josh Chen 2023년 1월 30일
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.

답변 (1개)

Josh Chen
Josh Chen 2023년 1월 23일
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
Zike Wang
Zike Wang 2023년 1월 30일
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 2023년 1월 30일
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

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

카테고리

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

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by