Simulink ROS Kinetic Gazebo Turtlebot image always black
12 views (last 30 days)
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:
d = rosdevice
and i see all my ROS information, i configured everything in Simulink and everything works as intended, i can type
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.
MathWorks Robotics and Autonomous Systems Team on 6 Dec 2017
As mentioned by you, you are noticing an error code of 1, as per documentation:
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"
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.