필터 지우기
필터 지우기

ROS Subscribe Block - Signal Selector

조회 수: 4 (최근 30일)
Ben Isaac
Ben Isaac 2019년 3월 21일
답변: Ben Isaac 2019년 3월 22일
Hi there,
I am using ROS Subscribe block in simulink to access ROS messages from a Vicon system. I have created custom ROS messages for the Vicon markers and I can view the X,Y,Z positions online via: rostopic echo /vicon/markers. However, when I try to use a display block in Simulink to display the X,Y,Z positions, I get the error shown in the second snapshot shown below. The error suggests that I need to use a Signal Selector before using a Bus Selector. However, I am not sure what the signal indexing format is. Could you please provide some guidance? Thank you.
Screenshot from 2019-03-21 13-28-16.png
Screenshot from 2019-03-21 13-29-01.png
Screenshot from 2019-03-21 13-34-59.png

채택된 답변

Ben Isaac
Ben Isaac 2019년 3월 22일
Hey Cam,
Thanks for your response! It fixed the problem.
Cheers,
Ben

추가 답변 (1개)

Cam Salzberger
Cam Salzberger 2019년 3월 21일
Hey again, Ben,
The issue is that the Markers_ field is, presumably, an array. For a MATLAB equivalent, it'd be like if you had a structure:
s = struct('a',[struct('x', 1, 'y', 2, 'z', 3), struct('x', 4, 'y', 5, 'z', 6)])
And then tried to do:
>> s.a.x
ans =
1
ans =
4
MATLAB can handle this because it just gives out multiple answers. Simulink cannot because it expects a strict structure (pun intended) to its signals. What you've tried to do, and is the correct thing to do, is to pick out the array field, pick out which elements you want, then pick out the fields you want to display from there. See attached image for an illustration.
This is similar to doing s.a(1).x in MATLAB. If you need to get this into an array, it's a bit more troublesome. There are some tips for working with arrays of buses in the documentation. You might also consider passing it into a MATLAB function block to operate on. Alternatively, if you just want to quickly check that your data is coming in appropriately, consider the Simulink Data Inspector, which can handle arrays of buses.
-Cam

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by