I want to send a service message with a dict type. I check in the document and I do not see it
Could I send a message by a dict type? Anh how to do it?
i don’t think i fully understand your question, but i try to interprete. If i did not answer the question you asked, please try to reformulate.
I understand you try to send a service message, in which a dict type (assumingly python) is carried.
If the size is fixed of your dict - i would suggest to create your own custom service.
If you go in a package, from your workspace you can create a folder for the new service with:
See for reference
In this directory, you can create your service file.
If you want to create a dict in there, you have to options:
- you can define the dict values one by one, for example:
# the answer
- If you are dealing with flexible type, it is more complicated. As far as i am concerned, the default Python-Dict cannot be send, so for flexible schema
a potential solution could be dealing with one array for the keys and one for the data.
This could help, but i would not recommend this, since i think it is not good engineering practice.
If you create your service, you have to make sure, to include in your package.xml
Add in your CMakeslist.txt
# Do not just add this line to your CMakeLists.txt, modify the existing line
find_package(catkin REQUIRED COMPONENTS
Further you have to add in your CMakeLists.txt the command to build the service.
Now you should be able, to use the service.
I hope i understood your question correct and i could help.
I understood my case totally
I will choose option number 1 because it is easier
Thanks for your help.
Glad i could help.
Feel free to ask, if theres another issue
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.