ROS Subscribe Block - Signal Selector
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ben Isaac
le 21 Mar 2019
Réponse apportée : Ben Isaac
le 22 Mar 2019
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.
0 commentaires
Réponse acceptée
Plus de réponses (1)
Cam Salzberger
le 21 Mar 2019
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
0 commentaires
Voir également
Catégories
En savoir plus sur Specialized Messages dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!