フィルターのクリア

How can I subscribe to Image topic on ROS Matlab and obtain the RGB image?

7 ビュー (過去 30 日間)
Pedro Gusmao
Pedro Gusmao 2014 年 9 月 8 日
回答済み: Shantanu 2023 年 2 月 2 日
Hello,
Please, how can I extract an image from a ROS Image Message followed by an imshow? I have already subscribed to the correct topic but message.getData() gives me a SlicedChannelBuffer object. Thanks,
Pedro

回答 (1 件)

Shantanu
Shantanu 2023 年 2 月 2 日
%Connect to Remote Machine
ip="Your IP Address";
rosinit(ip);
%Command Velocity Publisher
robotCmd = rospublisher("/cmd_vel","DataFormat","struct") ;
velMsg = rosmessage(robotCmd);
%Camera Subscriber
img_sub = rossubscriber("/camera/rgb/image_raw","DataFormat","struct");
%Publish a constant angular velocity
velMsg.Angular.Z=0.5;
send(robotCmd,velMsg);
% Start timer
tic;
figure
while toc < 20
%Image
im = receive(img_sub);
image = rosReadImage(im);
imshow(image);
end
velMsg.Angular.Z=0.0;
send(robotCmd,velMsg);
rosshutdown;
disp("Network Shutdown");

カテゴリ

Help Center および File ExchangeROS 2 Network Access in Simulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by