ROS Subscribe Block - Signal Selector

1 次查看(过去 30 天)
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 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by