ROSMonitoring icon indicating copy to clipboard operation
ROSMonitoring copied to clipboard

How can i verify multiple topics at once ?

Open zekeriyyaa opened this issue 4 years ago • 5 comments

Hi, thanks for your labor.

Suppose that there are two different topics such as topic1 and topic2. I want to verify both topics at once. I used a property like the given below. It was enough but not anymore. ( { topic : topic1 } -> { data : XXX } ) and ( { topic : topic2 } -> { data : YYY } )

Now, i want to write a property that include both data coming from different topics such as { data1 : XXX } and { data2 : YYY }.

How can i use both data coming from different topics in my property?

zekeriyyaa avatar Apr 22 '22 09:04 zekeriyyaa

Hi, Thanks for your message. Very interesting question. If I am getting it right, you want to specify a property that requires both data1 and data2 to be present at the same time. The simplest way is to tackle this at the source, which means, you can create a topic that collects both topic1 and topic2, then you pass that topic to the monitor. At that point, inside the property, you can refer to both data1 and data2, just because you have both info in your event. The reason for this is that you are really asking for the two events to be observed at the same time. Since ROSMonitoring handles messages one by one, if you want to handle multiple info from multiple messages, you can do that by merging the messages and then checking them inside the oracle. Let me know if this answers your question, and above all if you have other questions/comments. Thanks.

AngeloFerrando avatar Apr 22 '22 10:04 AngeloFerrando

Yes, you are getting it right. I'm aware of ROSMonitoring handles messages one by one, and I already applied what you said by merging messages. But it isn't sufficient for my use case anymore.

To be clarify, for 2 robotic arms, i want to verify that these robotic arms don't collide at all. So, i have to get their position info and compare them each other. But these 2 robotic arm are independent and each has its own ROS topics. it isn't possible to merge all data into a ROS topic. But my property required such data coming from different topic.

The monitor send just one of the messages that you specified config file to oracle in a moment. When the second topic is published, the monitor sends it also to oracle. I'm planning to edit "monitor" in this way:

  • define global dict variable "messages" to be stored all topics' content (data, topic, time, verdict? )
  • when the new topic is came, update it's the previous value
  • while sending the current data to oracle, currently you are using a variable "dict", but i will send "messages" . In this way, i will send every topics' updated content at once.

But there are still a problem caused by the "key" (dict["topic"] ....). Because you are using "time", topic" etc. for each topic. So, if i want to store all content, i have to add a prefix to my "keys" (messages["prefix_topic"]..).

zekeriyyaa avatar Apr 22 '22 17:04 zekeriyyaa

Hi, That is very interesting indeed. Yes, that would be an interesting solution. In this way, if I got it right, you would keep track of the latest values for the topics. Consequently, every time the monitor would send a message to the oracle, instead of just sending the message, it would now send multiple messages merged into one with more information (the two positions in this specific case).

I am not sure I am understanding your doubt about the key used in dict. Can you make an example?

Thanks.

AngeloFerrando avatar Apr 22 '22 20:04 AngeloFerrando

You know the dict type has key-value architecture. In your monitor code, currently, each message is sent as dict type one by one with some keys (topic, time, data ..) There is no problem if you send messages separately but when it comes to merging them into one dict type "messages", i have to specify different "key" for them. Because if i dont, "key" will be duplicated.

I can handle it using a prefix for each topic. The solution could be like: messages["robot1_distance"]=value messages["robot2_distance"]=value

No worry about it. I got my answer already. Thanks for all your answer.

zekeriyyaa avatar Apr 22 '22 20:04 zekeriyyaa

Hi, Perfect, thanks for explaining what you did. Makes sense to me. For anything else, do not hesitate to contact us. Cheers

AngeloFerrando avatar Apr 26 '22 07:04 AngeloFerrando