Is it possible to parse json file based on ROS2 msg file
Hi,
I am planning to have a json file that will tell ros2 channel and ros2 message type. So Is there a way that this json file can be parsed at compiled at runtime, though it can be done at runtime? Or are there any better methods available to do so?
Alternatively, We can have an application that takes JSON file and parse them to generate a valid json file.
Thanks in advance!
I'm not entirely sure what you are trying to do, but at least for the topic name, you should be able to use the remapping functionality (so you don't have to specify it in JSON). That is, you can run your node like:
ros2 run my_package my_node --ros-args -r topic_name:=new_topic_name
And your topic will show up as
new_topic_name
.If you are trying to accomplish something else, can you give some more details of what it is you are trying to accomplish?
Hi,
To give more context here is some more details * I will have few ros2 nodes with custom messages define in msg(.msg) folder * I will have a different topic and msg defined for different usecase. * To be dynamic, I will provide this configuration using a JSON file * The application shall read this json file and configure the ros2 nodes, channels, and message types * But, all this will happen in runtime
So, I wanted to know if during build time or while generating the JSON file if I can validate the message types that I specify in the arguments
Ex JSON file { "Topic": "/nodes/MyTopic1", "Message":"my_message1" }
Where I have 2 messages defined in IDL msg/my_message1 msg/my_message2
Here, "my_message1" is valid message type, however if I give "MyMessage1", this is not a valid message type in my project.
Thanks in advance!
Here are some things I would do differently:
Instead of using a JSON file to configure all of this, I have two different suggestions: 1. Write two separate nodes, one that deals with ...(more)