Simulink ROS Kinetic Gazebo Turtlebot image always black
6 ビュー (過去 30 日間)
古いコメントを表示
Hello, I want to use Simulink to display image from virtual Turtlebot camera inside Gazebo environment. I use ROS Kinetic on Ubuntu 16.04 and Gazebo 7.9 with Turtlebot model (i launch it with roslaunch turtlebot_gazebo turtlebot_world.launch)
I have all my ROS environment running and configured correctly. I can connect Matlab/Simulink to ROS without any issue. I start ros master on the Ubuntu machine then in matlab i type:
rosinit('<master_ip>')
d = rosdevice
and i see all my ROS information, i configured everything in Simulink and everything works as intended, i can type
rostopic list
in Matlab and it matches what i see in Ubuntu with ROS, i can run a Simulink model that sends messages to topic /mobile_base/commands/velocity and Turtlebot inside Gazebo reacts to commands, all perfect.
The issue starts when I'm trying to display in Simulink image from camera by subscribing to /camera/rgb/image_raw topic. The displayed image is all black and block "Read Image" shows error code 1.
I checked in Ubuntu/ROS the image using rosrun image_view image_view image:=/camera/rgb/image_raw/ and it shows correct image all right.
I thought maybe something is wrong with my model so i decided to do this example step by step, exactly as described (including the step where i set max array size to be greater than 921,600 pixels) https://www.mathworks.com/help/robotics/ug/_mw_5e2d4386-0dfb-42f6-999a-0be47c23dc68.html and yet in the end the image output is also all black.
Help will be appreciated.
0 件のコメント
回答 (1 件)
MathWorks Robotics and Autonomous Systems Team
2017 年 12 月 6 日
As mentioned by you, you are noticing an error code of 1, as per documentation:
https://www.mathworks.com/help/robotics/ref/readimageblock.html#output_argument_d119e68481
ErrorCode 1 means, wrong image encoding set on the block.
Double-click the block icon in your model > then select the topics using a separate window from the Block mask by clicking on "Configure using ROS ..."
This displays a list of image/ compressed image topics on your ROS network, and then when you select the topic, it auto-updates the image encoding setting on the block.
Confirm the image encoding, on your Linux machine, on the topic by printing the "rostopic info /camera/rgb/image_raw/encoding"
For e.g.,
user@ubuntu:~/Documents$ rostopic echo -n 1 /camera/depth/image_raw/encoding 32FC1 ---
Which means, in the ReadImage block the encoding needs to be 32FC1 to be able to process it correctly.
Using the "Configure using ROS ..." will help you pick the topic and encoding in one go.
Thanks
3 件のコメント
deelaka dheeraratne
2020 年 3 月 3 日
Hi,
I had the same issue my image came out black when using Simulink ReadImage block and I found out that the length of the data given out from the ROS image topic was limited to 128 in Simulink. This was because under the simulation tab, the VariableSize Messages the maximum length was set to 128. I increased it to the length of the RGB image HxWx3 and it worked it’s worth checking this.
参考
カテゴリ
Help Center および File Exchange で Network Connection and Exploration についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!